View Full Version : Google Maps API XML Add Marker Description
spyderfx
February 17th, 2010, 03:04 PM
I'm trying to help my dad out with his real estate website. He wants to have a google map displaying his properties on there. So far I've been able to use the Google Map API to make a map and add markers downloaded from an XML source file. The XML file looks like this:
<markers>
<marker lat="38.679917" lng="-121.315895"/>
<marker lat="38.708823" lng="-121.389302"/>
<marker lat="38.663036" lng="-121.277524"/>
</markers>
What I can't find any info on is how to add a description when the click on the markers using XML. Does anyone know how to do this?
Thanks in advance
jwilliam
February 17th, 2010, 03:39 PM
I suppose the quick and dirty thing to do would be to add an additional attribute to each marker tag... ie,
<marker lat="foo" lng="bar" description="baz"/>
Once you have the descriptions loaded in your javascript, adding the "pop up balloons" is pretty straightforward:
var ll = new google.maps.LatLng(latitude, longitude);
var marker = new GMarker(ll);
var content = '<p>' + description + '</p>';
marker.popup_content = content;
GEvent.addListener(marker, "click", function()
{
this.openInfoWindowHtml(this.popup_content);
});
map.addOverlay(marker);
...at least that should be pretty close. Google has excellent API documentation for their maps online if you haven't checked them.
spyderfx
February 17th, 2010, 05:18 PM
Nevermind this post: That was actually really simple!
Thanks got it working :)
On a related note. In the info bubble I have a url. Is there a way to have it just say "Click Here" instead of show the whole url? The code looks like this:
if (url != "") markerhtml += "<a href=\"" + url + "\">" + url + "</a>";
jwilliam
February 17th, 2010, 05:38 PM
Yep:
if (url != "") markerhtml += "<a href=\"" + url + "\">Click Here</a>";
;)
Joël Séguin
June 23rd, 2011, 10:44 AM
Sorry to hijack this thread (the original question is actually answered, so it's not that bad...)
I'd like to put a webpage content inside the marker bubble. Think it's possible?
Thanks
Joel
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.