Skip to content

Instantly share code, notes, and snippets.

@joshmoto
Created November 19, 2012 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshmoto/841acce7249aa5976c25 to your computer and use it in GitHub Desktop.
Save joshmoto/841acce7249aa5976c25 to your computer and use it in GitHub Desktop.
Zoom level event change icon size...
<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