nativescript-google-maps-sdk icon indicating copy to clipboard operation
nativescript-google-maps-sdk copied to clipboard

[ios] mapReady called with default map values rather than given properties

Open mikkelmoerch opened this issue 6 years ago • 1 comments

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 below mapView = args.object; in function 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.

mikkelmoerch avatar Jan 17 '20 11:01 mikkelmoerch

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

j20mc avatar Apr 14 '20 06:04 j20mc