How to offset the center of a Google maps (API v3) in pixels?

Viewed 27905

I was wondering if it is possible to offset the center of a map in Google maps api v3. I would like to control this offset in pixels, since by lat and lng seems wrong and very difficult to predict.

I just need to place a marker, and then offset the center by 250px so I can place some other content in the middle of the map.

Hope someone can help!

5 Answers

Example for latitude offset to pan a bit lower (on a negative lat, idk if positive lat will give the same result)

map.setZoom(15);
let latV = e.latLng.lat()+0.0135;
let lngV = e.latLng.lng();
map.panTo({lat: latV, lng: lngV});
Related