Hm... Still struggling with this. I'm clearly on thin ice here...
Got the XML file sorted but still having problems displaying the infowindow.
Here's the code now:
function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.setCenter(new GLatLng(59.417138, 8.920898), 8);
var icon = new GIcon(G_DEFAULT_ICON);
icon.image = "
http://chart.apis.google.com/chart?cht=mm&chs=24x32&chco=FFFFFF,008CFF,000000&ext=.png
";
GDownloadUrl("genxml.php", function(data) {
var xml = GXml.parse(data);
var markers = [];
var markers2 = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers2.length; i++) {
var name = markers2[i].getAttribute("name");
var kommune = markers2[i].getAttribute("kommune");
var latlng = new GLatLng(markers2[i].getAttribute("lat"),
markers2[i].getAttribute("lng"));
var infowindow =
GXml.value(markers2[i].getElementsByTagName("infowindow")[0]);
var marker = new GMarker(latlng,
{title:markers2[i].getAttribute("vegnavn")});
var fn = markerClick(infowindow, latlng);
GEvent.addListener(marker, "click", fn);
markers.push(marker);
}
var markerCluster = new MarkerClusterer(map, markers);
});
}
}
// function to build a function to respond to the click on a marker
function markerClick(infowindow, latlng) {
return function() {
// download the event information
GDownloadUrl(infowindow, function(html) {
// open an info window with the information
map.openInfoWindowHtml(latlng, 'test', {maxWidth:450, maxHeight:400,
autoScroll:true});
});
}
}
2011/3/2 [email protected] <[email protected]>
> On Mar 2, 1:05 am, Tom <[email protected]> wrote:
> > There's obviously an error in the XML output. And it's quite easy
> > to spot the error aswell. Thanks for notifying!
>
> I would suggest using UTF-8 encoding for your xml (and declaring it in
> an xml header (<?xml version="1.0" encoding="UTF-8" ?>), it will save
> a lot of problems.
>
> -- Larry
>
> >
> > On 2 Mar, 02:12, "[email protected]" <[email protected]> wrote:
> >
> >
> >
> >
> >
> >
> >
> > > On Mar 1, 1:51 pm, Tom <[email protected]> wrote:
> >
> > > > Hi,
> >
> > > > I'm having a big issue combining infowindow and Markerercluster. Been
> > > > searching and testing extensively but haven't found a solution.
> >
> > > > The map works fine as of now but I need to add html content to every
> > > > marker. Any idea on how I can do this?
> >
> > > > Map:http://tinyurl.com/642c9b8
> >
> > > IE doesn't like your xml:
> > > An invalid character was found in text content. Error processing
> > > resource 'http://data.varden.no/kart/genxml.php'. Line 1,...
> >
> > > <markers><marker name="107124360" kommune="Nome" vegnavn="Eidsbygda."
> > > lat="59.2931887" lng="9.1933107" type="lskadd...
> >
> > > -- Larry
> >
> > > > Code:
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Maps API V2" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-maps-api?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Google Maps API V2" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-api?hl=en.