-
Notifications
You must be signed in to change notification settings - Fork 815
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
Using Geocoder with GoogleMapsAPIWrapper #689
Comments
If you just need Geocoder(), you don't need to use getNativeMap(). I'm importing
But if you want to get the native map, you TestComponent must be loaded inside the google map component :
and you have to be sure that your instance of GoogleMapsAPIWrapper inside |
@gnujeremie thx for the tip to use MapsAPILoader. How do I go about importing it? Did you import it along with AgmCoreModule? |
No, AgmCoreModule is imported only in my module using google map. |
How about this -
|
In addition to the solution presented by @vintesh I had to update the lat and lng inside the NgZone to update the map.
|
I still run into problems when trying to use the geocoder. Here's my code.
I get two errors:
|
@slooker you need to add |
@gnujeremie That solves the google undefined problem, but it still tells me that MapsAPILoader isn't exported by angular2-google-maps. |
@slooker I too faced the same issue and MapsAPILoader error is coming because "node_modules/angular2-google-maps/core/index.js" do not export MapsAPILoader .I have solved this issue. Insert following code in "node_modules/angular2-google-maps/core/index.js" file as follows :
This works for me. Hope this will work for you also. |
Do you guys have a working version? I get my addresses from a database and I need their coordinates in order to build a marker cluster. GeoCoder is defined in the constructor but is not accessible via the nginit method. |
VinTesh, why does the service you listed say that google is undefined? What is the proper way tos et this up? Thanks |
I'm facing the same google undefined problem. Any suggestions? I'm using "@agm/core": "^1.0.0-beta.0" Thanks |
is my code and it works fine, but I am trying to write a unit test
but it fails with
Help please? |
Hello "google undefined" friends. Did you try the tip of our colleague @gnujeremie?
|
Fabio, can you provide a sample of how this is called and used? |
@DoubleExposure assuming you have a constructor like this constructor(private ms: MapsService) { you can call this in your code this.ms.getGeocoding( '10 10th Street NE, Atlanta, GA 30309' ).subscribe(function (x) { |
@FabioBentoLuiz @gnujeremie Hi 've tried your code and it's working great. Except the first call which allways fail. I've tried to make a first call in an ngOnInit but it does not seems to work. Here my usage attempt
|
Hi @Canadadry , |
My map is supposed to center on the address. I have tried waiting before starting to click to be sure google map script are loaded but it still require two clics. The MapsService used is the one you provide. |
Try it using NgZone as described here
Add to your constructor
Then set lat and lng like this:
Here is another thread that explain the reason of it. Let me know if it works. |
It seems to work, but I don't see why. |
I got it working with agm combining answers of @vintesh, @FabioBentoLuiz and @neilpennell. google-maps.service.ts:
shops.component.ts:
shops.component.html:
shops.component.css:
Thanks guys! |
@taneljoeaar do you know why I'm getting google is not defined I mostly copy and paste your code. Thanks a lot. |
@beachjf use the @FabioBentoLuiz solution instead, to get the lat and long because variable " google" may be still undefined as google maps scripts still loading. it works for me. |
Try |
@taneljoeaar or try |
Well I know that is an old question, but I'd like to comment on this topic a code about get the location objects with name and type of the city, state and country. But, in my case, I was needing to get these names from the coordinates of the users. So, to do it I wrote this based on last comments:
To get the coordinates values, I used the ionic native geolocation. |
I have implemented the code as you show it but I am getting the following error: ERROR Error: StaticInjectorError [MapsAPILoader]: NOTE: I am using Angular 5 Can you please give me a hand. |
@ronaldrenteria Did you placed
on your "imports" in app.modules.ts? |
Well I want to tell you, I already show the map and a marker, but what I want to do is convert some directions to latitude and longitude, but this has not been possible. I do not have the import in the app.modules.ts, because each component is using its own module and if I'm using LazyLoading. In this case I have a component called home.component.ts and this in turn has its own module called home.module.ts Before using MapsAPILoader it already showed the map and the markers (example by placing the longitude and latitude manually), but now I want to read the addresses from the DB and get the longitude latitude. Thank you. maps.service.ts
home.module.ts
home.component.ts
|
Hi everybody Maybe someone is facing a similar problem. I need to customize the AGM library, i downloaded the code and included this code like a part of my project, therefore i add the agmCoreModule from local src folder in apps.module, like this.
AgmCoreModule.forRoot({ i have a page with markers generated in a ngFor loop. But i am having the next error.
<agm-marker *ngFor="let ubicacion of ubicaciones"
|
For all those who are getting 'google is undefined' error: use this event 'mapReady' of agm-map element. |
Could someone come up with a working example? |
Working example of geocoding service https://stackblitz.com/edit/angular-google-maps-demo-geocoding based on examples listed here. |
Can I call mapsAPILoader.load() multiple times? |
hi every body i had a little problem , am new to AGM and angular too , but the thing is i got the place_id , i wanted to change this to latlng object thats was it , any help is appriciated |
@henoktsegaye basic principle here https://developers.google.com/maps/documentation/javascript/examples/geocoding-place-id |
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. |
@supruniuk thz GOD there is any way to have typed Observable result ? |
@xanscale Why not, just implement interface and use it for type checking |
@supruniuk i mean to typing google objects like results and status |
As @sainisk comment
Sample: |
I saw in issue #139 you are providing the ability to access google.maps object via the getMap() function, which I assume is now the getNativeMap() function in GoogleMapsAPIWrapper. I've also read that other people have gotten it to work, but I can't find any documentation or examples on how to use the GoogleMapsAPIWrapper and Geocoder.
Right now I can't even get the console.log to print out "test". I'm not sure why. Also would the m variable be the equivalent of google.maps? So that I can then use m.Geocoder()?
I'm also not sure if I'm importing the GoogleMapsAPIWrapper correctly. Currently I'm importing it in the core.module, since the Angular 2 guidelines say to have services be in the core.module. "sebm-google-map" works for me without any issues, so I think the AgmCoreModule is imported correctly, I'm just not sure about how to use GoogleMapsAPIWrapper.
I've been able to get google.maps.Geocoder() to work via GMap from PrimeNG, but sometimes I get google is not defined errors. So I'm trying to use Sebastian's google map instead.
The text was updated successfully, but these errors were encountered: