Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GoogleMapsAPIWrapper getBounds not returning #696

Closed
betfun opened this issue Oct 8, 2016 · 21 comments
Closed

GoogleMapsAPIWrapper getBounds not returning #696

betfun opened this issue Oct 8, 2016 · 21 comments

Comments

@betfun
Copy link

@betfun betfun commented Oct 8, 2016

Hello,
I am trying to get the maps bounds thourgh the GoogleMapsAPIWrapper service.
I am using the Promise function getBounds().

Nothing is returned.

Here's my code.

constructor(private searchService: SearchService, 
    private wrapper: GoogleMapsAPIWrapper, 
    private _loader: MapsAPILoader, 
    private zone: NgZone) {
  }

  ngOnInit() {
   this.wrapper.getBounds().then(x => console.log(x));  
  }

the console.log function is not called as the peomise never returns anything.

Thanks

@SebastianM
Copy link
Owner

@SebastianM SebastianM commented Nov 14, 2016

@betfun where did you place this component inside your template? inside the component?

@Uniphix
Copy link

@Uniphix Uniphix commented Nov 21, 2016

I did this myself and it doesn't work either, this was on Component.

@Uniphix
Copy link

@Uniphix Uniphix commented Nov 21, 2016

Even calling "getNativeMap" and doing "then" on that isn't getting called at all.

@ryan-morris
Copy link

@ryan-morris ryan-morris commented Jan 21, 2017

I experienced the same issue when trying to do it on a component that had <sebm-google-maps> in the template. My workaround was to create a custom component to drop inside <sebm-googe-maps><custom-component></custom-component></sebm-google-maps> to perform the needed functionality.

@hesyar
Copy link

@hesyar hesyar commented Mar 16, 2017

I have a similar issue. When I try to do the following:
this._wrapper.getNativeMap().then((map) => console.log("mappp", map));

mappp is not printed out. How can I make sure, that the instance is the same like sebm-google-map instance?

I would appreciate any help

@mrsauravsahu
Copy link

@mrsauravsahu mrsauravsahu commented Mar 22, 2017

I have a MapComponent which displays a map and I want to get its bounds from another component. How can I go about doing this?

@halben
Copy link

@halben halben commented Apr 10, 2017

I'm also seeing the same issue as well.

@josueadelima
Copy link

@josueadelima josueadelima commented May 29, 2017

Using sebm-google-map component inside a template you can use:

<sebm-google-map (boundsChange)="boundsChange($event)"></sebm-google-map>

and then inside your component:

boundsChange(event) {
    console.log(event.getNorthEast().lat());
    console.log(event.getNorthEast().lng());
    console.log(event.getSouthWest().lat());
    console.log(event.getSouthWest().lng());
  }
@craftpip
Copy link

@craftpip craftpip commented Jun 1, 2017

@josueadelima Thanks!
This only worked when the user pans over the map.
I also need to get the bounds when the map is loaded and the user hasn't touched it.

@craftpip
Copy link

@craftpip craftpip commented Jun 1, 2017

@SebastianM
Im using Angular4, I can confirm GoogleMapsAPIWrapper's promises don't work.

@josueadelima
Copy link

@josueadelima josueadelima commented Jun 1, 2017

@craftpip I'm getting the boundsChange event on map load too ...

@josueadelima
Copy link

@josueadelima josueadelima commented Jun 1, 2017

And as @craftpip mention promises are not working, also Angular4

Maybe (haven't test it) they work if you create the map using the GoogleMapsAPIWrapper and not the sebm-google-map template but then you loose a lot of the functionality that sebm-google-map gives you.

@pravinkumars
Copy link

@pravinkumars pravinkumars commented Jun 7, 2017

I am trying to getBounds from the directive <agm-circle> on load. I tried to access the native element but I couldn't get AgmCircle object from the native element.

this.circleManager.getBounds(this.searchCircle).then((bounds) => { console.log(bounds); }); 

http://plnkr.co/edit/nG6lUsm1KLbQRv3SRdgW?p=preview

Appreciate any help on this.

@cdarken
Copy link

@cdarken cdarken commented Sep 23, 2017

Any fix for this? I'm having the same problem and using the event is not really a solution.

@hesama110
Copy link

@hesama110 hesama110 commented Oct 16, 2017

thanks to @jplew
in this way can get Bounds ;)

latNorth: number
  @ViewChild(AgmMap) mapElement: any
  ...

  checkBounds(map) {

    const ln = this.mapElement._mapsWrapper.getBounds()
      .then( (latLngBounds) => {
        return latLngBounds.getNorthEast().lat()
      })
    ln.then( x => this.latNorth = x )
@fabio0296
Copy link

@fabio0296 fabio0296 commented Nov 15, 2017

Promises still not work in Angular 4, but this is not only getBounds function, also another functions like createMarker where the promise doesn't get excuted

@stale
Copy link

@stale stale bot commented Nov 13, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 13, 2018
@momentmuse
Copy link

@momentmuse momentmuse commented Nov 16, 2018

still having the same issue.

@stale stale bot removed the stale label Nov 16, 2018
@stale
Copy link

@stale stale bot commented Feb 14, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Feb 14, 2019
@stale stale bot closed this Feb 21, 2019
@Eraledm
Copy link

@Eraledm Eraledm commented Nov 29, 2019

Even now, still having the same issue, did someone get it to work?

@ghost
Copy link

@ghost ghost commented Nov 30, 2019

Why are you guys even using getBounds from GoogleAPIWrapper?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet