0
map.setCenter(new google.maps.LatLng(locationX,locationY); 

if I do this way, google puts a marker in the center of map canvas. I want that it will be not center, bot for example top right corner. Is it possible?

Sergey Kudryashov
  • 713
  • 2
  • 9
  • 30
  • 1
    possible duplicate of [How to center the Google Map NOT at the center of the screen?](http://stackoverflow.com/q/19206807/) – Dr.Molle Oct 10 '13 at 11:47
  • then you should not `setCenter`, you should use `panTo` – Praveen Oct 10 '13 at 11:47
  • Yes it's possible but there's no specific built-in method. You have to do some maths to calculate an appropriate lat/lng offset then `.setCentre()` thereon. – Beetroot-Beetroot Oct 10 '13 at 12:20

1 Answers1

0

Instead of setCenter, try the following

panTo(latLng:LatLng)

Changes the center of the map to the given LatLng. If the change is less than both the width and height of the map, the transition will be smoothly animated.

Community
  • 1
  • 1
Praveen
  • 55,303
  • 33
  • 133
  • 164
  • 1
    the only difference would be the possible animation, the result will be the same as if you use `setCenter()` – Dr.Molle Oct 10 '13 at 11:57