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

Add Geocoding to Google Maps plugin #280

Closed
GuelorEmanuel opened this issue Jul 10, 2016 · 14 comments · Fixed by #292
Closed

Add Geocoding to Google Maps plugin #280

GuelorEmanuel opened this issue Jul 10, 2016 · 14 comments · Fixed by #292

Comments

@GuelorEmanuel
Copy link

GuelorEmanuel commented Jul 10, 2016

Is there any methods for cordova-plugin-googlemaps for performing Geocoding as shown here "https://github.com/mapsplugin/cordova-plugin-googlemaps/wiki/Geocoder"

@GuelorEmanuel GuelorEmanuel changed the title Is there any methods for cordova-plugin-googlemaps for performing Geocoding as shown here "https://github.com/mapsplugin/cordova-plugin-googlemaps/wiki/Geocode"r Is there any methods for cordova-plugin-googlemaps for performing Geocoding as shown here "https://github.com/mapsplugin/cordova-plugin-googlemaps/wiki/Geocoder" Jul 10, 2016
@ihadeed
Copy link
Collaborator

ihadeed commented Jul 11, 2016

No I missed that functionality. Will be added later.

@ihadeed ihadeed changed the title Is there any methods for cordova-plugin-googlemaps for performing Geocoding as shown here "https://github.com/mapsplugin/cordova-plugin-googlemaps/wiki/Geocoder" Add Geocoding to Google Maps plugin Jul 11, 2016
@GuelorEmanuel
Copy link
Author

@ihadeed
Thank you, how long will this take?

@ihadeed
Copy link
Collaborator

ihadeed commented Jul 13, 2016

See #292

Added it, just haven't tested it yet. Not sure how that class works.

ihadeed added a commit that referenced this issue Jul 17, 2016
@GuelorEmanuel
Copy link
Author

@ihadeed
Cool, thanks. Going to test the method and see how its goes.

@mgarciadash
Copy link

Hello,
Could you showme an example of Geocoding for IONIC 2, been trying without success.

Thanks in advance.

@mifkys
Copy link

mifkys commented Jan 11, 2017

import { Geocoder, Geolocation } from 'ionic-native';
export class HomePage {
...
	getUserLocation () {
		// Определяем текущие координаты
		this.platform.ready().then(() => {
			Geolocation.getCurrentPosition({timeout: 3000}).then(
				(resp) => {
					let req = {
						position: {
							lat: resp.coords.latitude,
							lng: resp.coords.longitude
						}
					}
					// Определяем название города
					Geocoder.geocode(req).then(
						(res) => {
							// do something
						}
					);
				}, 
				(err) => {
				}
			);
		});
	}
...
}

@mgarciadash
Copy link

Thank You for your quick answer.

I copied and paste your example but didnt work.

In getCurrentPosition() im getting empty error {} (then not enter to Geocoder section)

And isolate geocode() returns emty array []

this.platform.ready().then(() => {
let req = {
position: {
lat: 40.7127837,
lng: -74.00594130000002
}
}
Geocoder.geocode(req).then(
(res) => {
console.log(res);
}
);
});

Tensting on Device (Android 6.0.1)
Environment: Ionic 2.1.14, node v7.2.1, cordova 6.4.0

@mifkys
Copy link

mifkys commented Jan 11, 2017

I have the app in Play Market with this code and all works. Are you install cordova google maps plugin with api key?

@mgarciadash
Copy link

Yes, i've tried with:

cordova plugin add cordova-plugin-googlemaps --variable API_KEY_FOR_ANDROID="MY_API_KEY" --variable API_KEY_FOR_IOS="MY_API_KEY"

ionic plugin add cordova-plugin-googlemaps --variable API_KEY_FOR_ANDROID="MY_API_KEY" --variable API_KEY_FOR_IOS="MY_API_KEY"

Even with:

ionic plugin add https://github.com/phonegap-googlemaps-plugin/cordova-plugin-googlemaps --variable API_KEY_FOR_ANDROID="MY_API_KEY" --variable API_KEY_FOR_IOS="MY_API_KEY"

cordova plugin add https://github.com/mapsplugin/cordova-plugin-googlemaps --variable API_KEY_FOR_ANDROID="MY_API_KEY" --variable API_KEY_FOR_IOS="MY_API_KEY"

Before, every time I run:

cordova plugin rm cordova-plugin-googlemaps
cordova plugin rm com.googlemaps.ios

@sudharsanmit
Copy link

sudharsanmit commented Jan 11, 2017 via email

@mgarciadash
Copy link

Ok, began from zero...

I removed the plugin i had with:

cordova plugin rm cordova-plugin-googlemaps
cordova plugin rm com.googlemaps.ios

Then tried and nothing.

Also i checked Enabled APIs in console.developers.google and enable:

- Google Maps Android API
- Google Maps Geocoding API
- Google Maps Geolocation API
- Google Maps SDK for IOS

And i added the plugin again using:

cordova plugin add cordova-plugin-googlemaps --variable API_KEY_FOR_ANDROID="MY_API_KEY" --variable API_KEY_FOR_IOS="MY_API_KEY"

And everything works now !

@mgarciadash
Copy link

Also notice that not works on emulator nor device -livereload :O

@janand4
Copy link

janand4 commented May 16, 2017

@mgarciadash, I did the same steps as mentioned above and I still get an empty array for res : this.platform.ready().then(() => {
let req = {
position: {
lat: 40.7127837,
lng: -74.00594130000002
}
}
Geocoder.geocode(req).then(
(res) => {alert(res);
}
);
});

I am running this code on iOS emulator and ionic view. How did you test out the output?

@josepena0409
Copy link

Just as an FYI for people looking at this issue. When running on an emulator, it will not work. You need to run this on your mobile device. The Geocoder grpc fails in android studio emulator. bug has been identified.

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

Successfully merging a pull request may close this issue.

7 participants