简体   繁体   English

Google Maps JS API v3上带有字母的“现代”标记

[英]“Modern” marker with letter on the Google Maps JS API v3

I have been searching the web for a while looking for the option to create a marker on Google Maps with a letter (aka these: https://maps.gstatic.com/mapfiles/markers2/red_markers_A_J2.png ). 我一直在网上搜索一段时间,以寻找可以在Google Maps上用字母创建标记的选项(又名: https : //maps.gstatic.com/mapfiles/markers2/red_markers_A_J2.png )。 I know Google offers Dynamic Options (https://developers.google.com/chart/image/docs/gallery/dynamic_icons) but that is now deprecated, plus the icons look old school, not like the ones in the link above. 我知道Google提供了动态选项(https://developers.google.com/chart/image/docs/gallery/dynamic_icons),但现在已不推荐使用,而且图标看起来像是老派,不像上面链接中的图标。

So Google used to offer this option in the API but now looks like it's only available for themselves? 因此,Google曾经在API中提供此选项,但现在看起来仅适用于自己? Isn't that weird? 那不是很奇怪吗?

It's not part of their API, but I'm sure they wouldn't mind if you borrowed their image for your maps. 它不是他们的API的一部分,但是我敢肯定,如果您借用了他们的地图图像,他们不会介意。 Just upload the PNG to your own server and instantiate your marker like: 只需将PNG上传到您自己的服务器并实例化标记,例如:

var markerImages = {
  a: new google.maps.MarkerImage('red_markers_A_J2.png', new google.maps.Size(20,34), new google.maps.Point(0,0)),
  b: new google.maps.MarkerImage('red_markers_A_J2.png', new google.maps.Size(20,34), new google.maps.Point(0,34)),
  c: …
}

var marker = new google.maps.Marker({
  position: myPosition,
  map: myMap,
  icon: markerImages.a
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM