2010-07-23 117 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);