简体   繁体   English

自定义谷歌地图图标

[英]custom google maps icons

Is there any way to create custom dynamic icons for the markers? 有什么方法可以为标记创建自定义动态图标吗?

What I want to create is a list of points and put a number "n" within markers specifying it's the n-th element. 我要创建的是一个点列表,并将数字“ n”放入指定第n个元素的标记中。

Yes. 是。 You can either use custom icons with Numeric Markers or the built-in numbering system on Google has for markers . 您既可以使用带有数字标记的 自定义图标 ,也可以使用Google上具有 标记的内置编号系统

Assuming the last option (not using custom markers), your marker definition code would look like: 假设最后一个选项(不使用自定义标记),则标记定义代码如下所示:

var NUMBER_SHOWN='34';
var ICON_COLOR = 'ff6600';
var ICON_TEXT_COLOR = '000000';
var marker = new google.maps.Marker({  
       position: [LatLong Obj],   
       map: [Map Obj],  
       icon: 'http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld='+NUMBER_SHOWN+'|'+ICON_COLOR+'|'+ICON_TEXT_COLOR  
        });

I believe this only works for two-digit number, though I'm not sure. 我不确定这仅适用于两位数的数字,尽管我不确定。

EDIT Geocodezip has correctly pointed out that the second approach has now been deprecated, so it looks like you're stuck using the first approach (using google's custom numbered-icons). EDIT Geocodezip已正确指出第二种方法现已被弃用,因此您似乎无法使用第一种方法(使用Google的自定义编号图标)。 Have a look at Daniel Vassallo's answer here on how to use it. 看看Daniel Vassallo在这里如何使用它的答案 If none of the markers fit your needs (colors, look, etc) you can create your own custom markers for each of the numbers (if you know how, you can write a server-side script that you can pass GET vars to and have it build the icon for you using GD etc, but you can also just build all the icons by hand) 如果所有标记都不符合您的需要(颜色,外观等),则可以为每个数字创建自己的自定义标记(如果您知道如何,则可以编写服务器端脚本,将GET变量传递给该脚本并具有它会使用GD等为您构建图标,但您也可以手动构建所有图标)

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

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