On Aug 31, 9:05 am, Mark <[email protected]> wrote: > I'm trying to add data to the info windows in my map. As a non- > programmer, I'm relying on trial and error to modify things and it > isn't working out in this case. > > My map stores the marker data in an XML file. I see how the script > reads the XML data and I think I understand how to go about adding > more data to the XML file. Where I'm having problems is modifying the > script sequence so it doesn't break the map. > > Here's my test map:http://tiny.cc/63xpl > > Here's the existing XML marker structure and script from the test > map... > > <marker lat="55.60754" lng="-132.41340" name="XYZ Lodge" > address="Thorne Bay, Alaska" category="c1"/> > > // Read the data > downloadUrl("categories.xml", function(doc) { > var xml = xmlParse(doc); > var markers = > xml.documentElement.getElementsByTagName("marker"); > for (var i = 0; i < markers.length; i++) { > // obtain the attribues of each marker > var lat = parseFloat(markers[i].getAttribute("lat")); > var lng = parseFloat(markers[i].getAttribute("lng")); > var point = new google.maps.LatLng(lat,lng); > var address = markers[i].getAttribute("address"); > var name = markers[i].getAttribute("name"); > var html = "<b>"+name+"<\/b><p>"+address; > var category = markers[i].getAttribute("category"); > // create the marker > var marker = createMarker(point,name,html,category); > } > > Here's how I want to modify the XML (add website and description)... > > <marker lat="55.60754" lng="-132.41340" name="XYZ Lodge" > address="Thorne Bay, Alaska" website="" description="" category="c1"/> > > I believe the above XML modification would require adding these two > lines to the script... > > var website = markers[i].getAttribute("website"); > var description = markers[i].getAttribute("description"); > > How do you modify the following line to reflect adding website and > description? I tried a few things but they broke the map! > > var html = "<b>"+name+"<\/b><p>"+address;
one way would be: var html = ""<b>"+name+"<\/b><p>"+address+"<br>"+website +"<br>"+description; or you could add those fields conditionally if they have content... You should try some javascript tutorials. -- Larry > > Thanks, > Mark -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" 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-js-api-v3?hl=en.
