nativescript-google-maps-sdk
nativescript-google-maps-sdk copied to clipboard
How to change map type
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?
When you say "map type" are you referring to projection (i.e. mercator) or rendering type (i.e. satellite)?
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);
})
}
}
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 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.
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.
The setMapType function is only available under the Android SDK. In iOS you assign mapType directly with
this.mapView.gMap.mapType = 4;
onMapReady = (event) => {
console.log("Map Ready");
const mapView = event.object;
if(isAndroid){
event.object.gMap.setMapType(4);
}else{
mapView.gMap.mapType = 4;
}
};