dapriett / nativescript-google-maps-sdk

Cross Platform Google Maps SDK for Nativescript
MIT License
244 stars 164 forks source link

Android: longitude, latitude, zoom, mapAnimationsEnabled,... are not set when defining them in XML #402

Open felixkrautschuk opened 4 years ago

felixkrautschuk commented 4 years ago

When defining those map-settings within XML, the App shows just the default map pointing to Africa (latitude 0, longitude zero, zoom 3).

My environment:

<maps:mapView
                latitude="51.04969202571914"
                longitude="13.738007694482803"
                minZoom="16"
                maxZoom="19"
                zoom="18"
                mapsAnimationsEnabled="false"
                mapReady="onMapReady"
                ...   >         
        <!--   ...   -->
</maps:mapView>

On iOS, this works as expected.

As a workaround for Android, one can set those settings in the onMapReady-event, but for the location (lat/long) and the zoom it is necessary to set these values within a setTimeout-call

export function onMapReady(args: EventData) {
    mapView = args.object;

    if(platformModule.isAndroid) {
        //not necessary for iOS, as these values can be set in XML there

        mapView.mapAnimationsEnabled = false;
        mapView.minZoom = 16;
        mapView.maxZoom = 19;

        setTimeout(function () {
            mapView.latitude = 51.04969202571914;
            mapView.longitude = 13.738007694482803;
            mapView.zoom = 18;
        }, 100);
    }
}

Would be nice if the plugin would behave more the same way on Android and iOS.