[英]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.