<?php
require_once 'curl.func.php';
$appkey = 'your_appkey_here';//你的appkey
$lat = '30,31';
$lng = '120,121';
$from=1;//1 WGS坐标系、2 火星坐标系(谷歌、高德、腾讯等)、3 百度坐标系、4 伪墨卡托坐标系
$to=2;//
$url = "https://api.binstd.com/coordconvert/coord2addr?appkey=$appkey&lat=$lat&lng=$lng&from=$from&to=$to";
$result = curlOpen($url, ['ssl'=>true]);
$jsonarr = json_decode($result, true);
//exit(var_dump($jsonarr));
if($jsonarr['status'] != 0)
{
echo $jsonarr['msg'];
exit();
}
$result = $jsonarr['result'];
echo $result['lat'].' '.$result['lng'].' '.$result['from'].' '.$result['to'].'
';
foreach($result['list'] as $val)
{
echo $val['lat'].','.$val['lng'].'
';
}
#!/usr/bin/python
# encoding:utf-8
import urllib2, json, urllib
# 1、坐标系转换
data = {}
data["appkey"] = "your_appkey_here"
data["lat"] = "30,31"
data["lng"] = "120,121"
data["from"] = 1
data["to"] = 2 #1 WGS坐标系、2 火星坐标系(谷歌、高德、腾讯等)、3 百度坐标系、4 伪墨卡托坐标系
url_values = urllib.urlencode(data)
url = "https://api.binstd.com/coordconvert/convert" + "?" + url_values
request = urllib2.Request(url)
result = urllib2.urlopen(request)
jsonarr = json.loads(result.read())
if jsonarr["status"] != u"0":
print jsonarr["msg"]
exit()
result = jsonarr["result"]
print result["lat"],result["lng"],result["from"],result["to"]
for val in result["list"]:
print val["lat"],val["lng"]
package api.binstd.coordconvert;
import api.util.HttpUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
public class Convert {
public static final String APPKEY = "your_appkey_here";// 你的appkey
public static final String URL = "https://api.binstd.com/coordconvert/convert";
public static final String lat = "30,31";
public static final String lng = "120,121";
public static final String from = "1";// 1 WGS坐标系、2 火星坐标系(谷歌、高德、腾讯等)、3
// 百度坐标系、4 伪墨卡托坐标系
public static final String to = "2";// 1 WGS坐标系、2 火星坐标系(谷歌、高德、腾讯等)、3 百度坐标系、4
// 伪墨卡托坐标系
public static void Get() {
String result = null;
String url = URL + "?lat=" + lat + "&lng=" + lng + "&from=" + from + "&to=" + to + "&appkey=" + APPKEY;
try {
result = HttpUtil.sendGet(url, "utf-8");
JSONObject json = JSONObject.fromObject(result);
if (json.getInt("status") != 0) {
System.out.println(json.getString("msg"));
} else {
JSONObject resultarr = json.optJSONObject("result");
String lat = resultarr.getString("lat");
String lng = resultarr.getString("lng");
String from = resultarr.getString("from");
String to = resultarr.getString("to");
System.out.println(lat + " " + lng + " " + from + " " + to);
if (resultarr.opt("list") != null) {
JSONArray list = resultarr.optJSONArray("list");
for (int i = 0; i < list.size(); i++) {
JSONObject obj = (JSONObject) list.opt(i);
String lat_ = obj.getString("lat");
String lng_ = obj.getString("lng");
System.out.println(lat_ + " " + lng_);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}