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

Is there a way to get mapWrapper instance so that I can play with geocoding/reverseGeocoding #139

Closed
parmod-arora opened this issue Feb 19, 2016 · 10 comments

Comments

@parmod-arora
Copy link
Contributor

Thanks for this wonderful repo and Is there a way to get mapWrapper instance so that I can play with geocoding/reverseGeocoding in my own components.

@nachein
Copy link

nachein commented Feb 20, 2016

import {GoogleMapsAPIWrapper} from 'angular2-google-maps/services/google-maps-api-wrapper';

...

@component(...

providers: [GoogleMapsAPIWrapper]

...

constructor(private _mapsWrapper: GoogleMapsAPIWrapper){}

@parmod-arora
Copy link
Contributor Author

Simply injecting GoogleMapsAPIWrapper will not do the trick there, because _map is private (private _map: Promise<mapTypes.GoogleMap>) and not accessible in component

writing new google.maps.Geocoder() in component is also not working. due to google is undefined error.

So how can i get map instance from GoogleMapsAPIWrapper Service ??

@sebholstein
Copy link
Owner

@parmod-arora

I could introduce a new method getMap to get the google map instance from the wrapper. Then you could write a custom component like this (for quick workaround, that works with the current version, you could use the private _map Promise):

<sebm-google-map [latitude]="lat" [longitude]="lng">
  <my-comp></my-comp>
</sebm-google-map>
@Component({
  selector: 'my-comp'
})
export class MyComp {
  constructor(private _wrapper: GoogleMapsAPIWrapper) {
    this._wrapper.getMap().then((m) => {
      // implement your own logic
    }
  }
}

@alfredoperez
Copy link

sounds like a good idea =]

@parmod-arora
Copy link
Contributor Author

@SebastianM

I created a pull request. #155 (feat(SebmGoogleMap): exposing _map Instance from GoogleMapsAPIWrapper)

but build is failing and i am not able to figure out why ?

https://travis-ci.org/SebastianM/angular2-google-maps/builds/111165799

Can you look at the pull request and provide some kind of documentation for sending pull-requests.

@sebholstein
Copy link
Owner

@parmod-arora thanks for the PR. There was an issue in Travis CI. Can you do a rebase (shorten the commit message and add only on commit to the PR)? Then the build should be green.
Thanks!

@sebholstein
Copy link
Owner

Oh BTW: I will also add some contribution guidelines very soon.

@parmod-arora
Copy link
Contributor Author

Thanks for your suggestions,

Every things works as expected please merge below PR.

#161

@philipbrack
Copy link

Hi I put together a working example of accessing the native map, it seems to be a little confusing how to use it at first.

https://github.com/philipbrack/example-angular2-google-maps-getNativeMap

@brunofin
Copy link

brunofin commented May 9, 2018

@SebastianM @philipbrack is the code you provided still working? GoogleMapsAPIWrapper doesn't seem to have a getMap() method, and neither does the getNativeMap() method actually returns a native map.

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

No branches or pull requests

6 participants