Hello,
I am trying to get the maps bounds thourgh the GoogleMapsAPIWrapper service.
I am using the Promise
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
@betfun where did you place this component inside your template? inside the
I did this myself and it doesn't work either, this was on Component.
Even calling "getNativeMap" and doing "then" on that isn't getting called at all.
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.
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
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?
I'm also seeing the same issue as well.
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());
}
@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.
@SebastianM
Im using Angular4, I can confirm GoogleMapsAPIWrapper's promises don't work.
@craftpip I'm getting the boundsChange event on map load too ...
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.
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.
Any fix for this? I'm having the same problem and using the event is not really a solution.
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 )
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
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.
still having the same issue.
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.
Even now, still having the same issue, did someone get it to work?
Why are you guys even using getBounds from GoogleAPIWrapper?
Most helpful comment
@SebastianM
Im using Angular4, I can confirm GoogleMapsAPIWrapper's promises don't work.