Angular-google-maps: How to recenter map based on marker position?

Created on 15 Dec 2016  ·  4Comments  ·  Source: SebastianM/angular-google-maps

* Question *

I have implemented a fullscreen option for the map but when I go to the fullscreen and back I call triggerResize() on the map to update the bounds for the map.

However, when going to fullscreen or returning to normal size, the marker is no longer centered on the screen.

How could I trigger the map control to recenter for the given marker position.

angular2 & angular2-google-maps version
Angular: 2.12
Angular2-google-maps: 0.16.0

important AgmMap feature-request

Most helpful comment

This is not supported right now. Current workaround could be to change the latitude/longitude for 1 millisecond and then change back to the original position. That should trigger the centering.

I think it's a good idea to add it to the triggerResize method.
```
triggerResize(recenter = true) { ... }
````

This would be a breaking change but most people probably want that behavior.

All 4 comments

This is not supported right now. Current workaround could be to change the latitude/longitude for 1 millisecond and then change back to the original position. That should trigger the centering.

I think it's a good idea to add it to the triggerResize method.
```
triggerResize(recenter = true) { ... }
````

This would be a breaking change but most people probably want that behavior.

@amiller29au can i know how you use full screen map. i was wondering how to dot it.

Hello. Any plans to do a new release where this issue's fix is included?

How can this be fixed?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stot3 picture stot3  ·  3Comments

Halynsky picture Halynsky  ·  3Comments

PeterSisovsky picture PeterSisovsky  ·  3Comments

n1t3w0lf picture n1t3w0lf  ·  3Comments

gnujeremie picture gnujeremie  ·  3Comments