Impossible to add a Geojson layer
See original GitHub issueHello
I’ve been using your library to try to display a map on a nativescript/angular app and i ran into an issue.
I created my map, no problem there, and then tried to add a Geojson layer on top of that. I used the addLayer method like described in the documentation and kept running into an error “No map has been loaded”.
After multiple checks on my code, i investigated the source code of the lib to find more info about what i did wrong and found that :
The addLayer method calls the addLineLayer because in my case i want to draw lines (https://github.com/Yermo/nativescript-mapbox/blob/master/src/mapbox.android.ts#L3121)
addLineLayers calls the addSource to add the layer source (https://github.com/Yermo/nativescript-mapbox/blob/master/src/mapbox.android.ts#L3262)
As you can see, it calls it with 2 parameters.
this.addSource( sourceId, style.source );
In addSource (https://github.com/Yermo/nativescript-mapbox/blob/master/src/mapbox.android.ts#L2958) we have a 3rd optional parameter called nativeMap.
the first thing the method does is check that parameter and return an error if it’s not set.
const theMap = nativeMap; if (!theMap) { reject("No map has been loaded"); return; }
So i have an error. It’s logical but unexpected.
Is this an error or am i using a deprecated method to add a layer ?
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (5 by maintainers)
I think I have this working now.
Please checkout branch issue_367_geojsonsource.
Rebuild the plugin and demo-angular app using:
I’ve added a test-source page to the demo angular app.
Let me know if it works for you.
Yes. I plan to do another major pass through the plugin in a few weeks.