2010-07-23 119 views
0

function showLocation(address){ geocoder.getLocations(address,addAddressToMap); }API谷歌地图和GPolyline的问题

function addAddressToMap(response) { 
    // map.clearOverlays(); 
    if (!response || response.Status.code != 200) { 
     alert("Sorry, we were unable to geocode your address"); 
    } else { 
     place = response.Placemark[0]; 
     point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]); 

     marker = new GMarker(point, icon); map.addOverlay(marker); 
     GEvent.addListener(marker, "click", function() { 
     marker.openInfoWindowHtml("<div>Your Location " + place.Point.coordinates[1] + "</div>"); });   

     var polyline = new GPolyline(point, '#ff0000', 5, 0.7); 

     map.addOverlay(polyline); 
    } 
} 

var xml = GXml.parse(data); 
var endpoints = xml.documentElement.getElementsByTagName("endpoint"); 
endpointSize = endpoints.length; 
if(endpointSize > 0) 
{ 
    for (var i = 0; i < endpointSize; i++) 
    { 
     var location = endpoints[i].getElementsByTagName("location")[0]; 

     address = location.getElementsByTagName("address")[0].childNodes[0].nodeValue + ' '+ location.getElementsByTagName("city")[0].childNodes[0].nodeValue + ' ' + location.getElementsByTagName("state")[0].childNodes[0].nodeValue; 

     name = location.getElementsByTagName("name")[0].childNodes[0].nodeValue; 

     showLocation(address); 
    } 
} 

为什么我只有一个openInfoWindowHtml吃了一点,为什么GPolyline不工作?

回答

0

现在GPolylinenow工作......但只有一个点有一个marker.openInfoWindowHtml

pontos.push(点);
var polyline = new GPolyline(pontos,“#0000dd”,6,0.8);
map.addOverlay(polyline);