var _markers = []; var _bounds = false; var _infowindow = false; var _icon_image = false; function gmapInitializeMap(map_element_id, is_results, latitude, longitude) { if(!latitude){ latitude = 51.2696291; } if(!longitude){ longitude = -1.0867946; } var latlng = new google.maps.LatLng(latitude, longitude); var myOptions = { scrollwheel: false, draggable: true, zoom: 8, maxZoom: 12, center: latlng, zoomControl: true, mapTypeControl: false, scaleControl: false, streetViewControl: false, rotateControl: false, fullscreenControl: false, mapTypeId: google.maps.MapTypeId.ROADMAP, styles: [{"featureType":"administrative","elementType":"labels","stylers":[{"visibility":"on"}]},{"featureType":"landscape","elementType":"all","stylers":[{"visibility":"on"}]},{"featureType":"poi.attraction","elementType":"labels","stylers":[{"visibility":"on"}]},{"featureType":"poi.business","elementType":"all","stylers":[{"visibility":"on"}]},{"featureType":"poi.business","elementType":"labels","stylers":[{"visibility":"on"}]},{"featureType":"poi.business","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"poi.government","elementType":"labels","stylers":[{"visibility":"on"}]},{"featureType":"poi.school","elementType":"all","stylers":[{"visibility":"on"}]},{"featureType":"poi.school","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"road","elementType":"all","stylers":[{"visibility":"on"}]},{"featureType":"road","elementType":"labels","stylers":[{"visibility":"off"}]}] }; var map = new google.maps.Map(document.getElementById(map_element_id), myOptions); _icon_image = { url: '/build/site/images/pin.svg', // This marker is 20 pixels wide by 32 pixels tall. size: new google.maps.Size(29, 51), // The origin for this image is 0,0. origin: new google.maps.Point(0,0), // The anchor for this image is the base of the flagpole at 0,32. anchor: new google.maps.Point(15, 51) }; _infowindow = new google.maps.InfoWindow({ content: "", pixelOffset: new google.maps.Size(-1, -5), infoBoxClearance: new google.maps.Size(1, 1), }); // and a click event map.addListener('click', function(e) { // console.log(e.latLng.toJSON()); }); _bounds = new google.maps.LatLngBounds(); return map; } function gmapAddMarker(map, latlng, identifier, icon_image, is_results){ var nextMarkerId = _markers.length; // add the icon _markers.push(new google.maps.Marker({ position: latlng, map: map, icon: icon_image })); // and a click event _markers[nextMarkerId].addListener('click', function() { _infowindow.setContent($('#marker'+identifier+'infobox').html()); _infowindow.open(map, _markers[nextMarkerId]); }); if(is_results){ // and mouse-over/out _markers[nextMarkerId].addListener('mouseover', function() { $('.venue-result-'+identifier).addClass('over'); alert(identifier); }); _markers[nextMarkerId].addListener('mouseout', function() { $('.venue-result-'+identifier).removeClass('over'); alert(identifier); }); } _bounds.extend(latlng); map.fitBounds(_bounds, {'left':0, 'right':0, 'top':160, 'bottom':20}); }