Hi I have this weird problem with Google Maps V3 API. Showing multiple markers on a google map is fine, but when I only want to show a single marker on the map, I get no markers displaying?
The code below only shows a map with no markers.
var map = new google.maps.Map(document.getElementById('map_canvas'), options);
marker1 = new google.maps.Marker({
position: new google.maps.LatLng(1.288693,103.846733),
map: map
});
Adding a second marker shows 2 markers on the map.
var map = new google.maps.Map(document.getElementById('map_canvas'), options);
marker1 = new google.maps.Marker({
position: new google.maps.LatLng(1.288693,103.846733),
map: map
});
marker2 = new google.maps.Marker({
position: new google.maps.LatLng(1.288693,103.846733),
map: map
});
So my question is, how do I only display a single marker on the map? Currently my workaround is to have 2 markers of the same lat/lng, but its not very elegant lol
Your first code block totally works for me. Here’s the entire file I have where it’s working, if this helps: