_From @EddyVerbruggen on April 18, 2016 21:8_
Hi folks,
I was updating the Mapbox plugin for Android from Mapbox GL 3.2.0 to 4.0.0 and may have found an issue in the metadata generator or Android runtime.
Mapbox has changed a lot of implementation details and I'm able to refactor the plugin accordingly except for one important item: addMarkers is broken because (I think) the NativeScript Android metadata generator chokes on the Java structure Mapbox now uses. Runtime error:
Error in mapbox.addMarkers: TypeError: markerOptions.title is not a function
In the 3.2.0 release the MapboxOptions class didn't extend anything and had a method called title, but since 4.0.0 it extends BaseMarkerOptions and title has moved over there.
So in a regular Android app you should still be able to access the title method through the child class MarkerOptions but in a NativeScript app it seems to no longer be possible.
Not having Markers would be killing for this plugin so if we can't fix it here I'll contact Mapbox and ask them for a different class inheritance or method structure.. I would need to know what the exact cause is though, hence this issue.
git clone https://github.com/EddyVerbruggen/nativescript-mapbox-demogit clone -b mapbox-4.0.0 https://github.com/EddyVerbruggen/nativescript-mapbox (to try the working old version just remove the -b mapbox-4.0.0 stuff)cd nativescript-mapbox-demo/Mapboxtns install"nativescript-mapbox": "1.1.2", by "nativescript-mapbox": "file:../../nativescript-mapbox", so it refers to your locally cloned pluginapp/App_Resources/Android/AndroidManifest.xml regarding TelemetryServicesDo a tns run android, browse to the second tab and press "show". That should draw a map.. if you now press "add markers" you'll see the error in the console.
_Copied from original issue: NativeScript/NativeScript#1990_
Thank you @EddyVerbruggen,
We managed to reproduce the problem and will look into it.
@EddyVerbruggen thank you for reporting this problem.
The problem originates in the android-runtime and it's caused by the fact the Base class(BaseMarkerOptions) there is a field and a method with the same name : title. If the filed and the method had a different name, you wouldn't have any problems.
Following the Java convention, for every field there should be, in our case: getTitle and setTitle, which will fix your problem.
Yes I was a bit surprised about the setter named as well. Do you think the runtime will ever be able to cooe with this kind of situation?
I think for the short term I'm best off sending them a PR or opening a ticket to fix the Mapbox SDK.
Thanks for investigating this so quickly and thoroughly!
@EddyVerbruggen We can think of a way to support it, yes. Should we ... I don't know. For now this is an isolated case, and we will keep it mind. If the need comes, we will have a discussion, including the community and we will come to solution.
I'm closing this issue for now, but we will reopen it if it's necessary.