f3n2x
January 30, 2018, 2:24pm
1
Hi
I encountered this error when tried Google Map Reserve Geocode. Any idea?
Unhandled Promise rejection: Cannot read property ‘Geocoder’ of null ; Zone: ; Task: Promise.then ; Value: TypeError: Cannot read property ‘Geocoder’ of null
See below my code:
import { GoogleMaps, GoogleMap, GoogleMapsEvent,
GoogleMapOptions, CameraPosition, MarkerOptions, Marker,
Geocoder,GeocoderRequest, LatLng, GeocoderResult
} from ‘@ionic-native /google-maps’;
…
export class GMapSearchPage {
@ViewChild (‘map’) mapElement: ElementRef;
map: any;
startP: string;
endP: string;
indicator: string;
dateTm : string;
constructor(private navCtrl: NavController, private navParams: NavParams
, private platform :Platform, private geolocation: Geolocation
, private geocoder: Geocoder) {
this.indicator=“start”;
}
…
let req : GeocoderRequest = { position: new LatLng( 1.3563415021796763, 103.98829936981201) } ;
Geocoder.geocode(req).then((results: GeocoderResult[])=>{
let address = [
(results[0].thoroughfare || "") + " " + (results[0].subThoroughfare || ""),
results[0].locality
].join(", ");
console.log("data_: ", address);
})
…
Thank you
Try like this:
$> cordova plugin rm cordova-plugin-googlemaps
$> cordova plugin add cordova-plugin-googlemaps@2.2.2 --variable API_KEY_FOR_ANDROID="..."
f3n2x
January 30, 2018, 11:35pm
3
Hi wf9a5m75
tried but still same error:
Unhandled Promise rejection: Cannot read property ‘Geocoder’ of null ; Zone: ; Task: Promise.then ; Value: TypeError: Cannot read property ‘Geocoder’ of null
Thanks and Regards
Ok, please share your project files on github. I will check it.
If you don’t want to share your project files with me, please create a demo project that reproduce your issue 100%.
Even you don’t want to create a demo, please debug this issue by yourself.
f3n2x
February 1, 2018, 3:14pm
5
hi wf9a5m75
please see my project under :
thanks
Your code is completely wrong. The ionic-native/google-maps does not work with google maps api v3. Stop either one
f3n2x
February 1, 2018, 11:44pm
7
Hi wf9a5m75
Noted with thanks. I use ionic-native/native-geocoder now. no more error but encounter below issue
Native: tried calling NativeGeocoder.reverseGeocode, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator
Kindly your advise
Thank you
ionic-native/native-geocoder is not my plugin. Please ask to someone.
The plugin does not support V3.x. Fair enough, what version of the google maps api does it support? I;m asking because I am seeing the exact same error (google maps api 3.32.13). From the google docs it appears that I can’t use a version of the API prior to V3.0.
So my conundrum is this: This plugin does not support the current (or at least a recent) google maps API, and I cannot use a google maps API prior to v3.0. Sorta leaves me in a bind.