本文介绍了在单张地图上添加点并在记录点之前为其分配类别的概念。这不是我的想法,而是一个在民防部门工作的朋友的想法。
这个例子处理 “Tree Mapping” – 用户可以在地图上选择应该添加树的位置,还可以指定树的类型: 普拉塔诺(西班牙梧桐树) 要么 Faggio(山毛榉树)。 我的第一步是创建一个输入表单,该表单除了只记录地图上点击的坐标外,用户还可以提供更多信息,例如类别(即树类型),但我还需要更多信息:
学习有关GeoJSON文件的新知识
Even when I created these entry forms with WordPress, there was always the constraint of the point, since it is easy to create, because of theGeoJSON file structure. So I had to study how to successfully create a GeoJSON file with the help of 的PHP arrays. I stumbled upon the function array_push
and learned how to create a series of arrays and sub-array, which look like this: features > features, properties, geometry
.
更多: 我不想将新创建的点传递到数据库中,但是我想写入文件 直 into a GeoJSON file. 这是 done with a combinantion of the functions: file_get_contents
, json_decode
together with array_push
.
最后结果: A 地图 made with HTML5
and 的JavaScript
, for the geolocalization and 地图ping of trees –完全适合移动设备!
OnClick功能
提交
对地图代码的引用
json_decode ($data, true)
>> 堆栈溢出- 使用在线工具测试geojson>> geojson.io
- 将JSON直接传递到getJSON方法>> lyzidiamond.com
- 创建一个单选按钮>> w3schools
- using
array_push
for correct use of array >> 示例PHP指向GeoJSON - add icon after
getJSON
>> … 图标:L.icon (riga 331)… - 地图代码su>> 的GitHub
发表回复