Watching for change in location

Using the watchPosition function, you can constantly watch and get notification whenever the location of the device changes.

Method summary

watchPosition(callback, options)

  • returns – watchID (String)
  • params
    •  callback (function), options (object)

For instance,

<cffunction access="public" name="watchpos" returntype="void" >
/*Populating the content of the <div> with the ID divId*/
document.getElementById('divId').innerHTML="Watch Id: "+watchId;


<cffunction access="public" name="wtchposcallback" returntype="void" >
<cfargument name="position">
alert("Longitude "+position.coords.longitude+" Latitude


Note: We have used alert() in the above example. alert() may not work on iOS devices.


See Using the Geolocation APIs

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy