0
Я пытаюсь вынести полилинию динамически на моем page.Here мой Javascript функция, которая намеревается сделать так:Невозможно полилинии на Google Maps
function decodePath(){
var pathArray=[];
window.alert(("here!!!"));
pathArray=[
new google.maps.LatLng(25.774252, -80.190262),
new google.maps.LatLng(18.466465, -66.118292),
new google.maps.LatLng(32.321384, -64.75737)
];
var flightPath = new google.maps.Polyline({
path: pathArray,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2
});
poly = new google.maps.Polyline(flightPath);
poly.setMap(map);
}
Кнопка, с которой выше функция прилагается:
<input type="button" onclick="decodePath();" value="Decode Path"/>
И ДИВ, где визуализируется карта:
<div id="map"></div>
Вот как я инициализации ialize:
function initialize() {
var rendererOptions = {
draggable: true
};
var chicago = new google.maps.LatLng(41.850033, -87.6500523);
var mapOptions = {
zoom:7,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: chicago
}
map = new google.maps.Map(document.getElementById('map'), mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
Я изучал карту APIs https://developers.google.com/maps/documentation/javascript/examples/,https://developers.google.com/maps/documentation/javascript/reference Google и, в частности, что я пытаюсь основан на this примере. Только я хочу динамически добавлять полилинии. Итак, почему путь не отображается на карте?
[Ваш код работает] (http://www.geocodezip.com/v3_SO_simpleMap_Polyline_onClick.html) для меня. Что вы имеете в виду, когда говорите «путь не рендеринга»? – geocodezip
@geocodezip Ваш код не совпадает с моим. строка: