简体   繁体   English

Google Maps API:如何使用户添加的标记成为永久标记?

[英]Google Maps API: how do I make user-added markers permanent?

I am currently trying to create a map application which allows users to add their own pins. 我目前正在尝试创建一个地图应用程序,该应用程序允许用户添加自己的图钉。 I want it to be an 'open' map where anyone with an account can add/edit pins on top of everyone else's. 我希望它是一个“开放”地图,任何有帐户的人都可以在其他人的顶部添加/编辑图钉。

With my limited knowledge of JavaScript, I have got to the point where anyone can add their pins, but they don't save (ie are removed once the application is reloaded). 以我对JavaScript的有限了解,我已经理解到任何人都可以添加自己的图钉,但是却无法保存(即,一旦重新加载应用程序,它们就会被删除)。 Only those I have put in manually (in the script) actually stick. 实际上,只有我手动(在脚本中)输入的内容会保留下来。

So, could anyone help me out? 那么,有人可以帮我吗?

How can I create some sort of 'database' (like in the custom map editor for google maps) which users can edit without having to actually put it in the code? 如何创建某种“数据库”(例如在Google地图的自定义地图编辑器中),用户可以编辑该数据库而无需将其实际放入代码中?

look at jStorage http://www.jstorage.info/ 看看jStorage http://www.jstorage.info/

<script src="//code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="jstorage.js"></script>
<script>
   // Check if "key" exists in the storage
   var value = $.jStorage.get("key");
   if(!value){
       // if not - load the data from the server
       value = load_data_from_server()
       // and save it
       $.jStorage.set("key",value);
   }
</script>

Have two arrays saved by jStorage, lat and lng arrays, and then set markers by using a for loop and let it work through the arrays. 由jStorage保存两个数组,即lat和lng数组,然后使用for循环设置标记,并使其遍历这些数组。

暂无
暂无

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

相关问题 如何使标记可拖动,标记和删除? 使用Google Maps JavaScript API - How do I make markers draggable, labeled, and deletable? with Google maps javascript API 如何在Google Maps API中添加多个叠加标记 - How do I add multiple overlay markers in google maps api 如何使用 Google Maps API 自定义不同的标记 CSS? - How do I customize different markers CSS with Google Maps API? 如何清除待办事项列表中的元素(带有用户添加的元素)? - How to clear element from to-do list (with user-added elements)? Google地图(JS-v3):如何让我的标记“从天而降” - Google Maps (JS-v3): How do I make my markers “fall from the sky” 如何向多个标记添加相同的事件侦听器,然后区分 Google Maps API v3 中侦听器中的标记? - How do I add same event listener to many markers and then differentiate between the markers in the listeners in Google Maps API v3? 如何在点击时显示标记并使用 google-maps-react API 获取坐标 - How do I display markers on click and get coordinates using google-maps-react API 如何为Google Maps V3中的所有标记创建一个事件处理程序? - How do I make a single event handler for all markers in Google Maps V3? 我们如何在Google Maps API中删除绑定到标记的标签 - How do we remove labels bound to markers in google maps api 如何将位智事件标记添加到带有流量的Google Maps javascript API生成的地图中? - How do I add waze incident markers to a google maps javascript API-generated map with traffic?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM