-
-
Save joshmoto/841acce7249aa5976c25 to your computer and use it in GitHub Desktop.
Zoom level event change icon size...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
jQuery(function($){ | |
var image1 = new google.maps.MarkerImage( | |
'<?php bloginfo('template_url'); ?>/images/marker-images/map-marker-12px.png', | |
new google.maps.Size(12,12), | |
new google.maps.Point(0,0), | |
new google.maps.Point(6,6) | |
); | |
var image2 = new google.maps.MarkerImage( | |
'<?php bloginfo('template_url'); ?>/images/marker-images/map-marker-24px.png', | |
new google.maps.Size(24,24), | |
new google.maps.Point(0,0), | |
new google.maps.Point(12,12) | |
); | |
var image3 = new google.maps.MarkerImage( | |
'<?php bloginfo('template_url'); ?>/images/marker-images/map-marker-48px.png', | |
new google.maps.Size(48,48), | |
new google.maps.Point(0,0), | |
new google.maps.Point(24,24) | |
); | |
$('#map_div').gmap3({ | |
action:'init', | |
options: { | |
center:[<?php echo $lt;?>,<?php echo $lo;?>], | |
zoom: 6, | |
scrollwheel: false | |
}, | |
events:{ | |
zoom_changed: function(map){ | |
var zoomLevel = map.getZoom(); | |
if (zoomLevel < 6) | |
UseMarkerIcon(image1); | |
else if (zoomLevel >= 6 && zoomLevel <=8) | |
UseMarkerIcon(image2); | |
else | |
UseMarkerIcon(image3); | |
} | |
} | |
}, | |
{ | |
action: 'addMarkers', | |
markers: [ <?php echo $lat_long;?> ], | |
marker: { | |
options: { | |
draggable: false, | |
icon: image1 | |
}, | |
events:{ | |
mouseover: function(marker, event, data){ | |
var map = $(this).gmap3('get'), | |
infowindow = $(this).gmap3({ action:'get', name:'infowindow' }); | |
if (infowindow) { | |
infowindow.open(map, marker); | |
infowindow.setContent(data); | |
} else { | |
$(this).gmap3({action:'addinfowindow', anchor:marker, options:{content: data}}); | |
} | |
}, | |
mouseout: function(){ | |
var infowindow = $(this).gmap3({ action:'get', name:'infowindow' }); | |
if (infowindow){ | |
infowindow.close(); | |
} | |
} | |
} | |
} | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment