Google Maps API NativeScript自定义标记图标

Fre*_*ris 0 javascript android google-maps nativescript

我尝试使用NativeScript和Google maps API包创建带有自定义图标的标记.我将我的图标添加到了android资源中,然后构建了我的项目几次.

   var marker = new mapsModule.Marker();
   marker.position = mapsModule.Position.positionFromLatLng(result.latitude, result.longitude);
   marker.title = "Home";
   var icon = new Image();
   icon.imageSource = imageSource.fromResource('bot_marker');
   marker.icon = icon;
   marker.snippet = "This is where I live";
   marker.userData = { index: 1 };
   mapView.addMarker(marker);
Run Code Online (Sandbox Code Playgroud)

即使我尝试iconlogo用于资源,它也不会出现.

Dan*_*nno 7

使用Angular2

import { Image } from "ui/image";
import { ImageSource } from "image-source";

    onMapReady(event) {
        console.log("Google map is ready!");

        var mapView = event.object;
        var marker = new Marker();
        marker.position = Position.positionFromLatLng(this.state.latitude, this.state.longitude);

        let imgSrc = new ImageSource();
        imgSrc.fromResource("pink_pin_dot");

        let image = new Image();
        image.imageSource = imgSrc;

        marker.icon = image;
        mapView.addMarker(marker);
    }
Run Code Online (Sandbox Code Playgroud)