I'm using the current code based off of Google's example, it works fine with one marker, but when I try and have multiple ones it fails.
I think it may have to do with my custom marker image, but not sure as I'm not great with this... Anyone have any ideas?
function initialize() {
var beaches = [
['Bondi Beach', -33.890542, 151.274856, 4],
['Coogee Beach', -33.923036, 151.259052, 5],
['Cronulla Beach', -34.028249, 151.157507, 3],
];
var myLatLng = new google.maps.LatLng(beach[1], beach[2], beach[3]);
var mapPKCanvas = document.getElementById('main-map');
var mapPKOptions = {
center: new google.maps.LatLng(-33.890542, 151.274856),
zoom: 15,
draggable: true,
scrollwheel: false,
mapTypeControl: false,
scaleControl: false,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var mainMapPK = new google.maps.Map(mapPKCanvas, mapPKOptions)
var url = 'https://www.customimage-map.png';
var size = new google.maps.Size(64, 78);
if (window.devicePixelRatio > 1.5) {
url = 'https://www.customimage-mapx2.png';
size = new google.maps.Size(64, 78);
}
var image = {
url: url,
size: size,
scaledSize: new google.maps.Size(64, 78),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(18, 20)
};
var marker = new google.maps.Marker({
position: myLatLng.getCenter(),
map: mainMapPK,
icon: image
});
marker.addListener('click', function() {
infowindow.open(mainMapPK, marker);
});
google.maps.event.trigger(mainMapPK, "resize");
}
google.maps.event.addDomListener(window, 'load', initialize);