Reputation: 2033
I'm using geoxml3 and markerclusterer to parse a kml file to a google maps api v3 map. this works so far.
the kml file stores several information.
<Placemark>
<name>Manfred Mustermann</name>
<description>Manfred Mustermann</description>
<Point>
<coordinates>7.0964850607874,51.781641735074,0</coordinates>
</Point>
<address>Musterstr. 29 Aachen, 52070 Nordrhein-Westfalen</address>
<styleUrl>#0</styleUrl>
</Placemark>
It´s working to output the Nodes "name" or "description" but not the "address". If I try to output this with place mark.address, undefined is written in the info window.
My Question is, how can I parse also this address info?
here is my code:
$(document).ready(function(){
var myOptions = {
zoom: 3,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var mcOptions = {gridSize: 80, maxZoom: 15};
markers = [];
var map = new google.maps.Map(document.getElementById("map-canvas"), myOptions);
markerclusterer = new MarkerClusterer(map, [], mcOptions);
var infoWindow = new google.maps.InfoWindow({maxWidth:800});
var myParser = new geoXML3.parser({
map: map,
singleInfoWindow:true,
createMarker:function(placemark){
var point = new google.maps.LatLng(placemark.point.lat, placemark.point.lng);
var con = "<pre>" + placemark.description + "<br /><br />" + placemark.address + "</pre>";
var marker = new google.maps.Marker({position:point});
markers.push(marker);
google.maps.event.addListener(marker, "click", function(){
infoWindow.content = con;
infoWindow.open(map, marker);
});
markerclusterer.addMarker(marker);
}
});
myParser.parse('dat.kml');
});
function clickMarker(i){
google.maps.event.trigger(markers[i], "click");
}
Thanks a lot!
Toni
Upvotes: 1
Views: 2918
Reputation: 26
Modify the 'geoxml3.js' file. In the 'var render = function (responseXML, doc)', placemark is defined as:
placemark = {
name: geoXML3.nodeValue(node.getElementsByTagName('name')[0]),
description: geoXML3.nodeValue(node.getElementsByTagName('description')[0]),
styleUrl: geoXML3.nodeValue(node.getElementsByTagName('styleUrl')[0])
};
Change it to add:
address: geoXML3.nodeValue(node.getElementsByTagName('address')[0])
Keep in mind that adding an address tag to KML is not in the standards of KML. Better to use a tag such as ExtendedData https://developers.google.com/kml/documentation/extendeddata#entityreplacement .
Upvotes: 1