In ColdFusion 10, you can now show the users location on a Google map created with the CFMAP tag. The CFMAP and CFMAPITEM tags now have a boolean attribute showuser. When set to true the browser would ask for the users permission and then display users geo-location on the map. This is now supported in most of the modern browsers. In cases where the browser doesn’t support Geo-location API then the values provided in centeraddress or centerlatitude\centerlongitude attributes will be used to add a marker in the Google map.
Here’s an example:
As mentioned earlier, the attribute showuser is available in CFMAPITEM tag as well:
Here a marker is added to the map that indicates the users location. In any case if the user denies the access to its location then the marker is added at the specified address or latitude\longitude.
Here’s an example:
<cfmap
showuser="true"
centeraddress="Sydney, Australia">
</cfmap>
<!--- or this --->
<cfmap
showuser="true"
centerlatitude="-33.52"
centerlongitude="151.13">
</cfmap>
Once the user provides the permission to the site to display it's location, a map showing the users' location is presented:As mentioned earlier, the attribute showuser is available in CFMAPITEM tag as well:
<cfmap
centeraddress="Sydney, Australia">
<cfmapitem
showuser="true"
address="Perth, Australia">
</cfmapitem>
<cfmapitem
address="Melbourne, Australia">
</cfmapitem>
</cfmap>
Output: Here a marker is added to the map that indicates the users location. In any case if the user denies the access to its location then the marker is added at the specified address or latitude\longitude.
Comments
Post a Comment