Google Maps API NativeScript自定义标记图标 [英] Google Maps API NativeScript custom marker icon

查看:94
本文介绍了Google Maps API NativeScript自定义标记图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I try to create a marker with a custom icon with NativeScript and the Google maps API package. I added my icon to the android resources and then built my project a few times.

   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);

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

Even when I try icon or logo for the ressource it doesn't appear.

推荐答案

使用Angular2

Using 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);
    }

这篇关于Google Maps API NativeScript自定义标记图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆