0

我已经看到了许多在标记图标上动态生成数字的示例。我发现其中之一是 google chart apis。部分解决了我的问题。编辑我的代码后,我能够生成数字,如下所示。
但是是否可以添加这样的自定义图标 ,然后在其上生成数字?

function addMarker(id,location,address,facility,name,ratings) 
    {


        marker = new google.maps.Marker(
        {
            position: location,
            map: map,
            animation:  google.maps.Animation.DROP,
            icon: 'https://chart.googleapis.com/chart?chst=d_map_pin_letter&chld='+id+'|FF776B|000000',
             shadow:'https://chart.googleapis.com/chart?chst=d_map_pin_shadow'
        });
4

1 回答 1

0

此图表 API 现在已弃用,谷歌将根据其修订后的“条款和条件”提供仅一年的支持。

我认为最好的方法是在服务器端创建标记。如果您的应用程序需要显示有限数量的标记(例如一次最多 25 个),那么您可以将它们放在服务器上。图像处理工具以 Java 或任何其他编程语言提供。

这是一个使用 java 的简短片段。

BufferedImage image = null;
try {
   image = ImageIO.read(new File("/path/to/base/icon"));
} catch (IOException e) {
   e.printStackTrace();
}

Graphics g = image.getGraphics();
g.setFont(g.getFont().deriveFont(30f));
g.drawString("1", x, y);  // x,y are points where you want to add the number
g.dispose();

try {
    ImageIO.write(image, "png", new File("test.png"));
} catch (IOException e) {
    e.printStackTrace();
}

您可以使用 for 循环创建任意数量的编号标记。

于 2013-06-27T08:33:06.823 回答