(function(A) { if (!Array.prototype.forEach) A.forEach = A.forEach || function(action, that) { for (var i = 0, l = this.length; i < l; i++) if (i in this) action.call(that, this[i], i, this); }; })(Array.prototype); var mapObject, markers = [], markersData = { 'result-map': [ { id: '1', location_latitude: 26.484444, location_longitude: 74.543258, image_url: 'http://www.guidemegood.com/pic/cities/369/Pushkar-925043328s_260w_140h.jpg',name_point: 'Pushkar', location_point: 'Pushkar, India', tripadvisor_rating_point: '', review_count_point: '0', url_point: '#', tripadvisor_url_point: '#', currencySymbol: 'Rs', price: '2000', distance: '100', unit: 'km', } ] }; var mapOptions = { zoom: 10, center: new google.maps.LatLng(26.484444,74.543258), mapTypeId: google.maps.MapTypeId.ROADMAP, mapTypeControl: false, mapTypeControlOptions: { style: google.maps.MapTypeControlStyle.DROPDOWN_MENU, position: google.maps.ControlPosition.LEFT_CENTER }, panControl: false, panControlOptions: { position: google.maps.ControlPosition.TOP_RIGHT }, zoomControl: true, zoomControlOptions: { style: google.maps.ZoomControlStyle.LARGE, position: google.maps.ControlPosition.TOP_RIGHT }, scrollwheel: false, scaleControl: false, scaleControlOptions: { position: google.maps.ControlPosition.TOP_LEFT }, streetViewControl: true, streetViewControlOptions: { position: google.maps.ControlPosition.LEFT_TOP }, styles: [ { "featureType": "administrative", "elementType": "all", "stylers": [ { "visibility": "off" } ] }, { "featureType": "poi", "elementType": "all", "stylers": [ { "visibility": "simplified" } ] }, { "featureType": "road", "elementType": "labels", "stylers": [ { "visibility": "simplified" } ] }, { "featureType": "water", "elementType": "all", "stylers": [ { "visibility": "simplified" } ] }, { "featureType": "transit", "elementType": "all", "stylers": [ { "visibility": "simplified" } ] }, { "featureType": "landscape", "elementType": "all", "stylers": [ { "visibility": "simplified" } ] }, { "featureType": "road.highway", "elementType": "all", "stylers": [ { "visibility": "off" } ] }, { "featureType": "road.local", "elementType": "all", "stylers": [ { "visibility": "on" } ] }, { "featureType": "road.highway", "elementType": "geometry", "stylers": [ { "visibility": "on" } ] }, { "featureType": "water", "elementType": "all", "stylers": [ { "color": "#84afa3" }, { "lightness": 52 } ] }, { "featureType": "all", "elementType": "all", "stylers": [ { "saturation": -17 }, { "gamma": 0.36 } ] }, { "featureType": "transit.line", "elementType": "geometry", "stylers": [ { "color": "#3f518c" } ] } ] }; var marker; mapObject = new google.maps.Map(document.getElementById('bali-map'), mapOptions); for (var key in markersData) markersData[key].forEach(function (item) { marker = new google.maps.Marker({ position: new google.maps.LatLng(item.location_latitude, item.location_longitude), map: mapObject, icon: '/images/map-marker/' + key + '.png', }); if ('undefined' === typeof markers[key]) markers[key] = []; markers[key].push(marker); google.maps.event.addListener(marker, 'click', (function () { closeInfoBox(); getInfoBox(item).open(mapObject, this); mapObject.setCenter(new google.maps.LatLng(item.location_latitude, item.location_longitude)); })); }); function hideAllMarkers () { for (var key in markers) markers[key].forEach(function (marker) { marker.setMap(null); }); }; function closeInfoBox() { $('div.infoBox').remove(); }; function getInfoBox(item) { return new InfoBox({ content: '
' + '' + '
' + 'Image' + '
' + '
' + '

' + item.name_point + ', '+ item.distance+' ' + item.unit +'

' + '
' + '
' + '' + item.location_point + '' + '
' + '
' + '
' + '
' + item.star_point + '
' + '
' + '
', disableAutoPan: true, maxWidth: 0, pixelOffset: new google.maps.Size(-130, -255), closeBoxMargin: '5px -20px 2px 2px', closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif", isHidden: false, pane: 'floatPane', enableEventPropagation: true }); };