我想要一张带有 2 个标记的地图。如果我使用 LatLng(请参阅 JS 代码 / WORKS JUST FINE /),那没问题......但是一旦我尝试使用地理编码(请参阅 JS 代码 / YU NOT WORKING? /)它就不起作用。我想这都是错误的:
var adresse3=geocoder.geocode({'address': 'Winkelriedstrasse 47, 6004 Luzern'})[0].geometry.location;
谁能帮我。提前谢谢你。
var myCenter=new google.maps.LatLng(47.050944,8.309441);
var geocoder;
var map;
function initialize(){
var mapProp = {
center :myCenter
};
var geocoder = new google.maps.Geocoder();
var map = new google.maps.Map(document.getElementById("googleMap"),mapProp);
/*WORKS JUST FINE*/
var marker1=new google.maps.Marker({
position: new google.maps.LatLng(47.050944,8.309441)
});
marker1.setMap(map);
var infowindow1 = new google.maps.InfoWindow({
content:"marker1"
});
google.maps.event.addListener(marker1, 'click', function() {
infowindow1.open(map,marker1);
});
/*Y U NOT WORKING?*/
var adresse3=geocoder.geocode({'address': 'Winkelriedstrasse 47, 6004 Luzern'})[0].geometry.location;
var marker3=new google.maps.Marker({
position: adresse3
});
marker3.setMap(map);
var infowindow3 = new google.maps.InfoWindow({
content:"marker3"
});
google.maps.event.addListener(marker3, 'click', function() {
infowindow3.open(map,marker3);
});
}
google.maps.event.addDomListener(window, 'load', initialize);