javascript 谷歌地图显示多个位置的标记
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20717791/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Google Map to show markers for multiple location
提问by Anand Jha
What I am trying to do is using Google map URL (https://maps.google.com/maps)
,I want to have markers for multiple location also I don't want to use Google Map API.
我想要做的是使用谷歌地图 URL (https://maps.google.com/maps)
,我想有多个位置的标记,我也不想使用谷歌地图 API。
I am only able to get a marker for single location using
我只能使用获得单个位置的标记
https://maps.google.com/maps?q=22.96783,88.74398
https://maps.google.com/maps?q=22.96783,88.74398
is there something like https://maps.google.com/maps?q=22.96783,88.74398&22.99783,88.78398
to get markers for multiple location (though it is not working in this format)
是否有类似https://maps.google.com/maps?q=22.96783,88.74398&22.99783,88.78398
为多个位置获取标记的东西(尽管它不适用于这种格式)
Any reference or help will be appreciated, Thanks
任何参考或帮助将不胜感激,谢谢
回答by tamak
Heres what you want -- basically the url string can hold more than one marker / location details. I've used the static version before on a project but heres the functional map version example I'd start with:
这就是你想要的——基本上 url 字符串可以包含多个标记/位置详细信息。我之前在一个项目中使用过静态版本,但这里是我开始使用的功能映射版本示例:
url syntax:
网址语法:
http://maps.google.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=14&size=512x512&maptype=roadmap&markers=color:blue|label:S|40.702147,-74.015794&markers=color:green|label:G|40.711614,-74.012318&markers=color:red|color:red|label:C|40.718217,-73.998284&sensor=false
(note: if will have heavy use you should obtain a key and add this to the end of the URL:
(注意:如果需要大量使用,您应该获取一个密钥并将其添加到 URL 的末尾:
&key=YOUR_MAPS_API_KEY
)
)
回答by Mike
You can setup a custom google map to show multiple locations (not multiple destinations), without API, but the capability is limited. The locations are input by either searching and selecting the locations individually or by inporting a csv or xlsx.
您可以设置自定义谷歌地图来显示多个位置(不是多个目的地),无需 API,但功能有限。通过单独搜索和选择位置或通过导入 csv 或 xlsx 来输入位置。
I did it from chrome (logged in) with the google maps app installed. Open the app and click the search bar, you should see something that states "my custom maps" click and from there it is pretty straight forward. One created send out the map link. You are limited to 3 layers in free version.
我在安装了谷歌地图应用程序的情况下通过 chrome(登录)完成了这项工作。打开应用程序并单击搜索栏,您应该会看到一些显示“我的自定义地图”的内容,然后点击它就很简单了。一创建就发出地图链接。免费版仅限 3 层。
回答by Ian
the csv file you upload can contain multiple locations; all it needs to be easily imported is the first row with column headers, and then subsequent rows can have label, lat, long.
您上传的 csv 文件可以包含多个位置;所有需要轻松导入的是带有列标题的第一行,然后后续行可以有标签、纬度、长度。