I try this code :
function codeAddress() {
// var marker = new google.maps.Marker();
var address = document.getElementById("address").value;
if (geocoder) {
geocoder.geocode( { 'address': address}, function(results,
status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
placeMarker();
// marker.setPosition(results[0].geometry.location);
// marker.setMap(map);
infoWindow.setPosition(results[0].geometry.location);
infoWindow.open(map);
google.maps.event.addListener(map, 'click', function(Event) {
marker.setPosition(Event.latLng);
marker.setMap(map);
infoWindow.setPosition(Event.latLng);
infoWindow.setContent(html);
infoWindow.open(map)
});
} else {
alert("Impossible de trouver votre adresse pour la raison
suivante: " + status);
}
});
}
}
But I have this error -> placeMarker is not defined
Do you know why ?
On Nov 21, 12:48 pm, Rossko <[email protected]> wrote:
> > Hum, I undesterstand my problem now but how fix this ?
>
> Let's put it simply
>
> > But your codeAddress() function defines a new local marker
> > var marker = new google.maps.Marker();
> > that you don't need at all.
>
> So, it's not needed. Take that line away in codeAddress().
>
> > codeAddress() places that new marker
> > marker.setPosition(results[0].geometry.location);
> > marker.setMap(map);
> > instead of using placeMarker() to control the global one.
>
> So, take those lines away. Replace with a call to placeMarker(). See
> if you can work out what argument to pass to placeMarker() when you
> call it.
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.