我正在创建一个webapp,我需要在地图上显示信息。但我需要将EPSG:3301转换为EPSG:4326。有一个网站,你可以做到http://spatialreference.org/projection/?json= {"几何":{"类型":"点","坐标" :[527742.81,6561591.74]}}& inref = EPSG:3301& outref = EPSG:4326。 所以我有我的代码:
$("#btn1").click(function(event){
var searchString = $('input[name=check_list1]:checked', '#myForm').val();
var data1 = 'search='+ searchString;
if(searchString) {
$.ajax({
type: "POST",
url: "do_search.php",
data: data1,
dataType: 'json',
success: function(data){
var otsing_data = (data);
var json_url = "http://spatialreference.org/projection/?json={'geometry':{'type':'Point', 'coordinates':["+otsing_data['x']+", "+otsing_data['x']+"]}}&inref=EPSG:3301&outref=EPSG:4326";
$.ajax({
type: 'GET',
url: json_url,
async: false,
contentType: "application/json",
dataType: 'jsonp',
}).done(function (data) {
var test = data;
console.log(test);
});
}
});
}
// return false;
})
但是console.log(test)给我回复
Object {error: "Expecting property name: line 1 column 1 (char 1)"}
答案 0 :(得分:0)
我需要改变
var json_url = "http://spatialreference.org/projection/?json={'geometry': {'type':'Point', 'coordinates':["+otsing_data['x']+", "+otsing_data['x']+"]}}&inref=EPSG:3301&outref=EPSG:4326";
到
var json_url = 'http://spatialreference.org/projection/?json={"geometry":{"type":"Point", "coordinates":['+point_x+', '+point_y+']}}&inref=EPSG:3301&outref=EPSG:4326';