Most mobile devices are fitted with a geolocation device, or the location can be determined using secondary information such as IP or even falling back to user input. This is exposed for the modern web developer to use in applications via the HTML5 geolocation API at http://www.w3.org/TR/geolocation-API/.
As with the desktop notifications, the user must give permission for the page to use their location. A further little hurdle is that location features do not work on Dartium. To try out this feature of the application, use pub build
to create the JavaScript version and use another browser:
The Locate button on the page will attempt to obtain the user's position and draw it on the page by adding it to the featurePlotter
class instance:
locateUser(Event evt) async { Geoposition geoPos = await window.navigator.geolocation.getCurrentPosition(); MapIndicator mapIndicator; var pos = featPlotter.toPoint(geoPos.coords.longitude, geoPos.coords.latitude); mapIndicator...