在Google地图中使用SVG作为标记? [英] Use an SVG for a marker in Google Maps?

查看:415
本文介绍了在Google地图中使用SVG作为标记?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道可以在Google地图上添加svg覆盖图。我想知道你是否可以使用svg文件作为标记。我试图设置它就像你会PNG或JPG文件,但没有出现。让我知道我是否应该发布我的代码,但我认为我可能以错误的方式接近它。



谢谢。



<$ p $ p> var marker = new google.maps.Marker({
position:new google.maps.LatLng(lat,lng),
icon:new google.maps。 MarkerImage('/ path / to / icon.svg',
null,null,null,new google.maps.Size(64,64)),
draggable:false,
map:地图
});


i know it's possible to add svg overlays to google maps. i'm wondering if you can use svg files as markers. i tried setting it just like you would a png or jpg file, but nothing shows up. let me know if i should post my code, but i think i am probably approaching it in the wrong way.

thanks.

解决方案

On Google Maps API v3 it's working just fine for me with this code (which also handles resizing):

var marker = new google.maps.Marker({
  position: new google.maps.LatLng(lat, lng),
  icon: new google.maps.MarkerImage('/path/to/icon.svg',
    null, null, null, new google.maps.Size(64,64)),
  draggable: false,
  map: map
});

这篇关于在Google地图中使用SVG作为标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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