如何在Google Maps API中以完全相同的坐标呈现多个标记? [英] How to render multiple markers at the exact same coordinates in Google Maps API?

查看:92
本文介绍了如何在Google Maps API中以完全相同的坐标呈现多个标记?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在同一条街道上有多个地址,房号相同,但公寓号码不同。 Google地图地理编码服务(v2)的许多地址的公寓级别准确性没有下降,只是给我返回了完全相同的地理编码坐标。

I have multiple addresses on the same street with the same house number, but with different apartment numbers. Google Maps Geocoding Service (v2) doesn't go down to apartment level accuracy for many addresses and just returned me the exact same geocode coordinates for them.

所以问题是,当我去显示它们时,无论放大多少,只有一个图钉出现。而我的问题是;在同一个家庭地址上呈现多个图钉的好方法是什么?我已经看到了craigslist.org如何在他们的新地图功能中创建螺旋图形,但想知道我的其他选项是什么,因为这看起来好像是一种解决方法。

So the problem is that when I go to display them, only one pushpin shows up no matter how much you zoom in. And my question is; what is a good way to render multiple pushpins at the exact same house address? I've seen how craigslist.org creates a spiral out of the pushpins on their new map feature, but was wondering what my other options are as that seems like a workaround at best.

创意? 使用

Ideas?

推荐答案

Google的动态图表图标可让您在该图标中添加一个数字,以确定在某个确切点上有多个标记。基本上,你用一些查询参数调用他们的图表网址,然后他们给你回号码图标,然后你可以在你现有的标记上放置/设置。

I solved this using Google's dynamic chart icons which allow you to put a number in the pin identifying that there are multiple markers on this exact some point. Basically, you call their "chart" url with some query params and they give you back your numbered icon which you can then place/set in the existing marker you have on that spot.

var markerImage = createMarkerImage(numDuplicates + 1);
existingMarker.setIcon(markerImage);

function createMarkerImage(text)
{
    var pinImage = new google.maps.MarkerImage("http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=" + text + "|FF8985|000000",
    new google.maps.Size(21, 34),
    new google.maps.Point(0,0),
    new google.maps.Point(10, 34));
    return pinImage;
}

注意:此解决方案使用弃用的Google API没有结束日期发布。 $ b

NOTE: This solution uses a deprecated google API with no end date posted.


重要提示:截至4月20日,Google Chart Tools的图表图表部分已正式弃用
,根据我们的弃用政策,它将继续工作

"Important: The Image Charts portion of Google Chart Tools has been officially deprecated as of April 20, 2012. It will continue to work as per our deprecation policy."



更新:

我已经从上面的解决方案中移除了,因为它在leiu中被弃用(并且对许多标记具有性能影响),但是使用路径的坐标定义标记形状的多边形,以及标记阴影的 .png 。只有我使用我自己的自定义标记的原因是因为我需要创建单个标记,每个标记都具有唯一的颜色(可能还有嵌入的数字),而这些标记不支持。


UPDATE:
I have moved away from the above solution since it's deprecated (and has performance impact for many markers) in leiu of the same end effect of a numbered marker, but using a path of coordinates defining polygon in the shape of a marker along with a .png for the marker shadow. Only reason I used my own custom marker is because I needed to create individual markers, each with a unique color (and possibly an embedded number), which the vanilla markers don't support.

这篇关于如何在Google Maps API中以完全相同的坐标呈现多个标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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