You appear to have left out a descent amount of the v3 code... From where you begin creating the marker etc.
Also a live page, even if it isn't working, would help immensely. On Wed, Sep 22, 2010 at 3:17 PM, Awilson430 <[email protected]>wrote: > I developed a page to read and parse a set of markers and polylines > with controls to show and hide them based on their categories. I've > been able to recreate the markers' functionality in V3 but have thus > far been unsuccessful converting the polyline code. Below is the V2 > code that works. > > I'm looking for an example of a similar functionality using V3. > > Thanks in advance for any light you can shed on the subject. > > I've tried referencing the V3 javascript, adding downloadxml.js since > V3 doesn't support XML parsing, and changed the V2 object names to > their corresponding V3 names GLatLng to google.maps.LatLng, etc. I'm > probably missing something simple or else V3 doesn't support arrays of > multiple polylines. > > > V2 code snippet: > GDownloadUrl("data.xml", function(doc) { > var xmlDoc = GXml.parse(doc); > var markers = > xmlDoc.documentElement.getElementsByTagName("marker"); > var lines = > xmlDoc.documentElement.getElementsByTagName("line"); > > 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 GLatLng(lat,lng); > var name = markers[i].getAttribute("name"); > var html = > GXml.value(markers[i].getElementsByTagName("infowindow")[0]); > var category = markers[i].getAttribute("category"); > // create the marker > var marker = createMarker(point,name,html,category); > map.addOverlay(marker); > map.addOverlay(geoXml); > map.addOverlay(geoXml2); > } > > // read each line > for (var a = 0; a < lines.length; a++) { > // get any line attributes > var colour = lines[a].getAttribute("colour"); > var width = parseFloat(lines[a].getAttribute("width")); > // read each point on that line > var points = lines[a].getElementsByTagName("point"); > var category = lines[a].getAttribute("category"); > var pts = []; > for (var i = 0; i < points.length; i++) { > pts[i] = new > GLatLng(parseFloat(points[i].getAttribute("lat")), > > parseFloat(points[i].getAttribute("lng"))); > } > > var poly = new > GPolyline(pts,colour,width[category]); > poly.mycategory = category; > map.addOverlay(poly); > poly.hide(); > gpolylines.push(poly); > > } > > V3 code snippet, works for markers, was unable to get polylines to > work: > > downloadUrl("data.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); > } > > -- > 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]<google-maps-js-api-v3%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-maps-js-api-v3?hl=en. > > -- 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.
