I am having problems with some code to display markers in a Google map. I have 8 markers defined in the code, but only 6 will ever show. This is the code I am using and it's the last two items in locations that do not show.
var locations = [
['', 45.382, -75.6704, 1, 'properties_detail.php?propertyID=16'],
['', 45.4009, -75.7009, 1, 'properties_detail.php?propertyID=17'],
['', 45.4041, -75.7017, 1, 'properties_detail.php?propertyID=18'],
['', 45.4135, -75.6977, 1, 'properties_detail.php?propertyID=19'],
['', 45.4176, -75.6928, 1, 'properties_detail.php?propertyID=20'],
['', 45.3268, -75.8217, 1, 'properties_detail.php?propertyID=22'],
['', 45.4179, -75.6928, 1, 'properties_detail.php?propertyID=23'],
['', 45.3908, 75.7236, 1, 'properties_detail.php?propertyID=25']
];
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(45.392769, -75.719140),
zoom: 11,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
var infowindow = new google.maps.InfoWindow();
var marker, i;
var iconBase = '';
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map
,icon: iconBase + 'tagg_map.png'
,url: locations[i][4]
});
google.maps.event.addListener(marker, 'click', function() {
window.location.href = this.url;
});
On your test case all 8 markers are there. You're missing the minus off the lng of the last point so it's plotting way off outside your scope and two of them are very close together (5 and 7 have the same lng) so appear in the same place until you zoom in.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With