Coldfusion and Google Maps

Is anyone working with Coldfusion and Google Maps? I am trying to pass marker information (latitude and longitude) to a map based on information in a database.  I will have several markers depending on the search.  I am close, but cannot seem to create the markers needed.

<script type="text/javascript">
    //<![CDATA[
   
    if (GBrowserIsCompatible()) {

      // A function to create the marker and set up the event window
       
      function createMarker(point,html) {
        var marker = new GMarker(point);
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
        return marker;
      }

      // Display the map, with some controls and set the initial location
      var map = new GMap2(document.getElementById("map"));
      map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl());
      map.setCenter(new GLatLng(43.907787,-79.359741),12);
   
      // Set up markers with info windows
      <cfoutput query="searchtags">
      var point = new GLatLng('%#latitude#%', '%#longitude#%');
        
      var marker = createMarker(point, '%#description#%')
      map.addOverlay(marker);

      </cfoutput>
    }
   
    // display a warning if the browser was not compatible
    else {
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }

 
    //]]>
    </script>
LVL 1
ServalStudiosAsked:
Who is Participating?
 
Scott BennettConnect With a Mentor Manager TechnologyCommented:
to set thecenter to the first row in your query use:

 <cfoutput query="searchtags" startrow="1" maxrows="1">map.setCenter(new  GLatLng(#latitude#, #longitude#),12);</cfoutput>
0
 
danrosenthalCommented:
Are you getting any error messages?
What does the output look like?

I suggest getting non-DB version working and then comparing the source of that to the source of your DB version above.
0
 
ServalStudiosAuthor Commented:
Yes, I have already been able to get the non-database working, or at least I think it is. I sitll have one marker, but it could be from the first "create marker" instruction.

I get a map with one red marker in the left hand corner. It seems to be in the same place regardless of how I change the map.setCenter varialble.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Scott BennettManager TechnologyCommented:
Why do you have all those %'s in your code? your loop should probably be more like this:

<cfoutput query="searchtags">
      var point = new GLatLng(#latitude#, #longitude#);
      map.addOverlay(createMarker(point, 0, '#description#'));
    </cfoutput>

0
 
Scott BennettManager TechnologyCommented:
I have been working on a Google Maps implementation for my companies site as well, and the best example of a working implementation I have found is oakley. Do a dealer search on their site and then view the source of the resulting page for some good source code to follow:

http://oakley.com/dealer/
0
 
ServalStudiosAuthor Commented:
I had the % in my code cause I was getting a blank map.  Now I realize that it was because the fields were not populated.  Now if I can just figure out how to get it to center on the first record.
0
 
ServalStudiosAuthor Commented:
Thank you for all your help.  Works great!  
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.