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

How to change map type

Open TrivediKomal opened this issue 7 years ago • 7 comments

I am using nativescript-google-maps-sdk plugin. import { MapView, Marker, Polyline, Position, Circle } from 'nativescript-google-maps-sdk';

I want to change type of google map.can anyone help me?

TrivediKomal avatar Jan 30 '18 06:01 TrivediKomal

When you say "map type" are you referring to projection (i.e. mercator) or rendering type (i.e. satellite)?

yoat avatar Jul 09 '18 16:07 yoat

you can use many methods of google map with gmap

export classComponent {
     private marker: Marker;
     
   public onMapReady(event) {
    this.mapView = event.object;
    this.mapView.gMap.setMapType(2);
    })
  }

}

fawadmukhtar avatar Jul 27 '18 06:07 fawadmukhtar

As far as I can tell, the function setMapType() doesnt exist in the nodejs code. Unless you can some how pass that to the native native sdk?

trevortos avatar Sep 19 '18 22:09 trevortos

@trevortos Yes, you can pass and it will work. With this.mapView.gMap, you can access all public properties and methods of google map API. https://developers.google.com/android/reference/com/google/android/gms/maps/GoogleMap using this link. In the plugin, gMap type declared is any and that's why you can't see the setMapType() in nodejs with autocompletion of editor tool.

fawadmukhtar avatar Sep 20 '18 01:09 fawadmukhtar

exports.onMapReady = (args) => { mapView = args.object; console.dir('map change'); mapView.gMap.setMapType(4); // 4 is hybrid };

mapView.gMap.setMapType is not a function. (In 'mapView.gMap.setMapType(4)', 'mapView.gMap.setMapType' is undefined)

The map loads fine, and I can set a marker, or a whole group of them. All the interactions work fine. When I create the maps:mapView I set a lat/long, which work. And im running the newest of all the nativescript and nodejs mods.

trevortos avatar Sep 20 '18 03:09 trevortos

The setMapType function is only available under the Android SDK. In iOS you assign mapType directly with

this.mapView.gMap.mapType = 4;

kuvelas avatar Oct 13 '18 15:10 kuvelas

onMapReady = (event) => {
    console.log("Map Ready");
    const mapView = event.object;

    if(isAndroid){
      event.object.gMap.setMapType(4);
    }else{
      mapView.gMap.mapType = 4;
    }

  };

kdmakwana43 avatar Feb 23 '20 05:02 kdmakwana43