[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 251
  • Last Modified:

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>
0
ServalStudios
Asked:
ServalStudios
  • 3
  • 3
1 Solution
 
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
 
Scott BennettCommented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Scott BennettCommented:
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
 
Scott BennettCommented:
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
 
ServalStudiosAuthor Commented:
Thank you for all your help.  Works great!  
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now