i would like to get a map with 2 markers. if i use the LatLng (see JS Code /WORKS JUST FINE/) it is no problem... but as soon i try to use geocoding (see JS Code /Y U NOT WORKING?/) it doesn't work. I guess this is all wrong:
var adresse3=geocoder.geocode({'address': 'Winkelriedstrasse 47, 6004 Luzern'})[0].geometry.location;
Can anyone help me. Thanks you in advance.
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);