ionic-team / ionic-native-google-maps

Google maps plugin for Ionic Native
Other
221 stars 125 forks source link

Error when adding a simple KML overlay. #183

Closed reynirf closed 5 years ago

reynirf commented 5 years ago

I'm submitting a ... (check one with "x")

If you choose 'problem or bug report', please select OS: (check one with "x")

cordova information: (run $> cordova plugin list)

cordova-plugin-device 2.0.2 "Device"
cordova-plugin-geolocation 4.0.1 "Geolocation"
cordova-plugin-googlemaps 2.5.2 "cordova-plugin-googlemaps"
cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 3.1.2 "cordova-plugin-ionic-webview"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist

If you use @ionic-native/google-maps, please tell the package.json (only @ionic-native/core and @ionic-native/google-maps are fine mostly) "@ionic-native/core": "^5.2.0", (have also tried with 5.0.0) "@ionic-native/google-maps": "^5.0.0-beta.27",

Current behavior: I get an unhandle promise rejection when trying to create a simple KmlOverlay. Other functions work as expected, creating the map etc.

Expected behavior: A KML overlay should be added to the map and I should not get an error.

Related code, data or error log (please format your code or data):

Code:

let options: KmlOverlayOptions = {
  url: 'https://developers.google.com/kml/documentation/KML_Samples.kml'
};

this.map.addKmlOverlay(options).then((kmlOverlay: KmlOverlay) => {
  console.log('Kml Overlay added')
}).catch((error) => {
  console.log('Error when adding Kml Overlay', error)
});

Error: zone.js:682 Unhandled Promise rejection: Cannot read property 'forEach' of undefined ; Zone: ; Task: Promise.then ; Value: TypeError: Cannot read property 'forEach' of undefined at new KmlOverlay (KmlOverlay.js:249) at ... at ... .......

Basically, when "kmlData.forEach(seekOverlays);" gets executed on line 249 in your KmlOverlay.js, "kmlData" is undefined.

Testing using my own KML file and a sample KML file from Google (https://developers.google.com/kml/documentation/KML_Samples.kml)

reynirf commented 5 years ago

It also doesn't work on a freshly installed ionic 4 project with nothing but the functionality to add a KML overlay on a map. Has anyone managed to get this to work?

reynirf commented 5 years ago

Saw that you (@wf9a5m75) added a comment but then deleted it. Any update on this issue?

wf9a5m75 commented 5 years ago

ping

reynirf commented 5 years ago

There was some KML tag that didn't work with the plugin. I don't remember which tag it was.

wf9a5m75 commented 5 years ago

Ah, I see. KML is really complicated, but this plugin supports only limited tags. https://github.com/mapsplugin/cordova-plugin-googlemaps-doc/tree/master/v2.3.0/class/KmlOverlay#overview

Anyway, it seems you already solved this problem. Congrats.