HTML5 canvas encoding HTML5 in-line SVG encoding Geolocation API

52 Copyright © 2012 Open Geospatial Consortium. complete encoding for OWS Context in HTML5, but parts of HTML5 could be included in an OWC Context encoded in XML. Particularly interesting for presenting geospatial features on a web browser are the “canvas” and the “SVG inline”.

7.3.1 HTML5 canvas encoding

The HTML5 element is used to draw graphics, on the fly, via scripting usually JavaScript. The element is only a container for graphics; you must use a script to actually draw the graphics. A canvas is a drawable region defined in HTML code with height and width attributes. Canvas has several methods for drawing paths, boxes, circles, characters, and adding images. This means that an OWS Context document could contain vector features expressed in canvas language as a direct content that can be later used by a JavaScript engine to render the objects. owc:offering owc:content type=textjavascript [CDATA[ var c=document.getElementByIdmyMap; var ctx=c.getContext2d; ctx.fillStyle=FF0000; ctx.fillRect0,0,150,75; ]] owc:content owc:offering

7.3.2 HTML5 in-line SVG encoding

HTML5 natively supports in-line SVG, thus eliminating the need for an object element and allowing HTML5 web browsers to render SVG without the need of external Adobe plugins. This means that an OWS Context document could contain vector features expressed in SVG as a direct content that can be later shown in a web browser. entry svg xmlns=http:www.w3.org2000svg version=1.1 width=600 height=400 defs marker id=TriangleYellow viewBox=0 0 10 10 refX=0 refY=5 markerUnits=strokeWidth markerWidth=4 markerHeight=3 orient=auto path d=M 0 0 L 10 5 L 0 10 Z stroke-width=0 fill=yellow Copyright © 2012 Open Geospatial Consortium. 53 marker defs text x=30 y=80 font-family=Verdana font-size=30 fill=yellowBarcelonatext path d=M 200 75 L 250 75 L 340 150 fill=none stroke=yellow stroke-width=7 marker-end=urlTriangleYellow svg entry

7.3.3 Geolocation API

HTML5 includes a Geolocation API that can be used to get the geographical position of the user. Since this can compromise user privacy, the position is not available unless the user approves it. Geolocation is much more accurate for devices with GPS. The getCurrentPosition method to get the users position is: script function getLocation { if navigator.geolocation { navigator.geolocation.getCurrentPositionshowPosition; } else{alertGeolocation is not supported by this browser.;} } function showPositionposition { alertLatitude: + position.coords.latitude + brLongitude: + position.coords.longitude } script This functionality allows us to develop a web browser that moves us to our current position after uploading an OWS Context document. In fact, during OWS-9 we incorporated this code in our MiraMon Web Map client. 54 Copyright © 2012 Open Geospatial Consortium. Figure 2 — Button “Locate” implements the javascript getCurrentPosition function and return a value in the Barcelona Region

7.4 How to develop extensions