nativescript-google-maps-sdk使用本机调用来设置地图样式

时间:2016-10-20 11:29:22

标签: google-maps nativescript

我在我的angular2 + nativescript项目中成功整合了谷歌地图。打字稿定义文件中我需要的一切对我有用。

但是,我想玩地图的样式。 AFAIK,我必须使用对地图的本地调用,因为方法setMapStyle()不在typescript定义中。

我以为我可以使用gMap属性来访问本机对象并调用该方法。但我无法按照谷歌文档(https://developers.google.com/maps/documentation/android-api/styling)中的要求设置正确的参数,因为我不知道如何创建MapStyleOptions对象。类型未知。

有人尝试或成功完成此任务并希望分享一些提示吗?您将如何访问原生GoogleMap?

1 个答案:

答案 0 :(得分:1)

NativeScript允许您访问应用中使用的插件的所有公共API,因此您应该能够根据nativescript.org

上的文档对Map API进行本机调用

例如,如果要创建MapStyleOptions对象,则需要编写

var MapStyleOptions : any = com.google.android.gms.maps.model.MapStyleOptions;
var mapStyle : any = new MapStyleOptions({"..":".."});

或仅var mapStyle = new com.google.android.gms.maps.model.MapStyleOptions({"..":".."});

当TypeScript抱怨com.google...无法识别时,您可以将其定义为any或导入一些现成的打字输入。 祝你好运!