将用户标记的位置保存在Google地图JavaScript API中? [英] Save location of user markers in google maps javascript API?

查看:93
本文介绍了将用户标记的位置保存在Google地图JavaScript API中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作地图,希望用户能够添加标记。具体来说,我想要一种方法来保存它们添加的标记,以便在地图重新加载时,您可以看到其他人放置标记的位置。这可能吗?我觉得我已经清理了一下互联网,似乎找不到办法做到这一点。我对开发很陌生,以前从未使用过Google的API,因此我可能会要求一些不可能的事情。

I'm working on a map that I'd like users to be able to add markers to. Specifically, I'd like a way to save the markers they add so that any time the map is reloaded you can see where others have placed their markers. Is this possible? I feel like I've scavenged the internet quite a bit and can't seem to find a way to do it. I'm very new to development and have never used google's API before, so I may be asking for something that's impossible.

http://test-bd8a1b.webflow。 io /

我正在处理的地图就在这里。

the map I'm working on is here.

推荐答案

您可以添加事件侦听器来映射每个标记创建并将经度和纬度保存到数组中,或者您可以将它们保存到数据库。稍后,您可以在地图上显示它们。

you can add event listener to map on every marker creation and save the latitude and longitude into array or you can save them to database. Later you can show them on map.

      marker.addListener('click', function() {
           -- write code to save markers details into an array
         });

这篇关于将用户标记的位置保存在Google地图JavaScript API中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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