map marker not showing but apparently no problem in the code

32 views
Skip to first unread message

Moghomaya Arkel

unread,
Oct 26, 2017, 6:43:29 PM10/26/17
to Google Maps JavaScript API v3
hi guys please i have this code
var mapOptions = {
    zoom: 5,
    mapTypeId: 'roadmap'
};
var bounds = new google.maps.LatLngBounds();
var map = new google.maps.Map(document.getElementById('searsh-map'), mapOptions);
//map.setTilt(45);
var marker,i
    , infowindow = new google.maps.InfoWindow();

var image = new google.maps.MarkerImage('assets/img/map.png',
    new google.maps.Size(19, 29),
    new google.maps.Point(0, 0),
    new google.maps.Point(0, 32));
var result=[
    ['Bondi Beach', -33.890542, 151.274856, 4],
    ['Coogee Beach', -33.923036, 151.259052, 5],
    ['Cronulla Beach', -34.028249, 151.157507, 3],
    ['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
    ['Maroubra Beach', -33.950198, 151.259302, 1]
];
// for (i = 0; i < result.length; i++) {
// hotels += formatForHotelCarousel(result[i]);
var position = new google.maps.LatLng(result[1][1], result[1][2])

bounds.extend(position);
marker = new google.maps.Marker({
    postion: position,
    map: map,
    icon: image,
    animation: google.maps.Animation.DROP,
    title: result[1][0]
});
google.maps.event.addListener(marker, 'click', (function (marker) {
    return function () {
        var img = "assets/img/slide-01.jpg";
        infowindow.setContent(result[1][0]);
        infowindow.open(map, marker);
    }
})(marker));
map.fitBounds(bounds);
$('#mapModal').on('shown',function () {
    google.maps.event.trigger(map, 'resize');
});
$('#mapModal').modal();
google.maps.event.trigger(map, 'resize');

but i wonder why the marker does not show up i already looked for a solution in many forums but still don't have anything that works 

Alirio Arevalo

unread,
Oct 31, 2017, 7:18:42 PM10/31/17
to Google Maps JavaScript API v3

Hello Moghomaya Arkel,

Did you tried correcting the typo in the "postion" property of the marker?
Reply all
Reply to author
Forward
0 new messages