Home  >  Article  >  Backend Development  >  如何调通过API调用51ditu中的地图_PHP

如何调通过API调用51ditu中的地图_PHP

WBOY
WBOYOriginal
2016-06-01 12:20:451061browse

今天研究下地图标注。实际上就是看看如何调用51ditu提供的api接口并结在PHP中应用。

其提供的api接口说明:http://api.51ditu.com/

帮助文档:http://api.51ditu.com/docs/index.html

以下简单的演示一个,用户从后台标注自己想用的东西,前台读出来。

从网站是复制,粘贴试了下,还是比较容易使用的。

第一。在http://api.51ditu.com/docs/ezmarkerapi.html

这里看了下,按上边说的引入JS,可以设这城市,上边说的是从下拉列表中选,实际应用时应该从数据库中读出

第二。他这里是把读出的经纬放到文本框里,实际用应是可以通过ajax提前并保存到数据库

function setMap(point,zoom)

{

document.getElementById("x").value=point.getLongitude();

document.getElementById("y").value=point.getLatitude();

document.getElementById("z").value=zoom;
//这里加代码通过ajax保存到数据库,如果是用jquery
$.get('map.php',{x:point.getLongitude(),y:point.getLatitude()},function(msg){
alert(msg);
});
//只需要在map.php中写插放到数据库中的代码即可

}

OK到这里已经能把位置保存到数据库里了,下边是读出

第三,读的话用http://api.51ditu.com/docs/mapsapi.html这里

如何依据经纬度或标记添加信息窗口

既然已经保存到数据库里了,这里再读出来就OK

更多的用法根据具体的需要求看下这网站的帮助文件。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn