[ios] mapReady called with default map values rather than given properties
Description
On iOS the map is initialized within the constructor of MapView, which causes mapReady to be called with the default values defined in map-view.common.ts and not the properties provided in template.
For me it caused a problem with Google Maps iOS Utils, rendering clusters with zoom level 0, and then render the clusters with the provided zoom level of 9.
Reproduce
- Download this repo
- Get the demo app running on iOS (did not try in demo-vue)
- In demo/app/main-page.js add this:
console.log("What is zoom really? ", mapView.zoom);. just belowmapView = args.object;infunction onMapReady(args) {...} - Check the console on map initialization - the value is 0.
Example code in demo/app/main-page.js:
var mapView = null;
function onMapReady(args) {
mapView = args.object;
console.log("What is zoom really? ", mapView.zoom);
// ... Rest of impl.
}
Output: What is zoom really? 0
Solution
Change the initialization to use NativeScripts view lifecycle - like in the android implementation.
createNativeView() {...}
initNativeView() {...}
I have a PR ready in few minutes.
Hello, feel free to try this and give feedback on any bugs :
https://github.com/j20mc/Nativescript-Danem-Google-Maps-Utils#readme
IOS and Android support