A Unique Developer

cfmap tag for Google Map

I really impressed with CFMAP tag in ColdFusion 9. It eliminates javascript code for google map api. Now google map integration is so easy that will finish in just two steps 1. Get google map API key for your domain. 2. Use CFMAP tag and render map in HTML page.

After getting API key we need to tell coldfusion about our MAP API key either by giving in cfajaximport tag or application.cfc file. You can specify api key in cfajaximport tag if you are want to use this in single page only but if planning to use google map in site wide then better idea to specify in Application.cfc. Below are both way to specify key.

<cfajaximport params="#{googlemapkey='ABQIAAAABvdd0PabCkL4zGc4TF1t6hT2yXp_ZAY8_uf....'}#" />OR<cfset this.googlemapkey="ABQIAAAABvdd0PabCkL4zGc4TF1t6hT2yXp_ZAY8_uf.....">

I really like rendering map using address rather than specifying Longitude and Latitude. In most of the case we have address and it become so easy with CFMAP tag. I have been using some custom tags for google api but in some cases I required to modify custom tag to reach my needs or need to add javascript code for extra functionality. CFMAP tag comes with lots of attiributes wich make it very flexible. Below is simple example to render map using address.

<cfajaximport params="#{googlemapkey='ABQIAAAABvdd0PabCkL4zGc4TF1t6h....'}#"/><cfmap name="gmap02"     centeraddress="Sola Road, Ahmedabad 380061"     doubleclickzoom="true"     scrollwheelzoom="true"     showscale="false"     zoomlevel="12"    tip="My Map"/> 

And output will be

CFMAP example

It is really simple, isn't it?