I have a map with an infobox overlay on the top of the marker. As the box is quote big it goes out the view so I need to offset the center of the map about 150px down. I can't figure out how to use the panBy method to offset the map center using gmap3 jQuery plugin.
This is my code:
var center = [<?php echo $coordinate ?>];
$('#sw-map')
.gmap3({
center: center,
zoom: 16,
mapTypeId : google.maps.MapTypeId.ROADMAP,
})
.marker({
position: center
})
.overlay({
position: center,
content: html,
x:-125,
y:-260
});
Thanks
I've found the solution myself. Forgot to mention i was using gmap3 v7.2, i had to switch back to v6 changing the code a little bit, here's the working solution:
var center = [<?php echo $coordinate ?>];
var default_zoom = <?php echo $sw_single_map_default_zoom_level ?>;
var max_zoom = <?php echo $sw_single_map_max_zoom_level ?>;
var min_zoom = <?php echo $sw_single_map_min_zoom_level ?>;
var offsetX = -125;
var offsetY = -268;
var panY = -100;
<?php if ($sw_single_map_infobox == 1) {
?>
var offsetX = -47;
var offsetY = -154;
var panY = -70;
<?php } ?>
$("#sw-map").gmap3({
map:{
options:{
center: center,
zoom: default_zoom,
maxZoom: max_zoom,
minZoom: min_zoom,
mapTypeId : google.maps.MapTypeId.ROADMAP
}
},
marker:{
latLng: center
},
overlay:{
latLng: center,
options:{
content: html,
offset:{
x: offsetX,
y: offsetY
}
}
}
});
var map = $("#sw-map").gmap3("get");
map.panBy(0,panY);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.