Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript geocoder.getLocations会导致变量_Javascript_Jquery - Fatal编程技术网

Javascript geocoder.getLocations会导致变量

Javascript geocoder.getLocations会导致变量,javascript,jquery,Javascript,Jquery,我浪费了很多时间,但我做不到 谢谢你的帮助 如何在变量中得到逆地理定位的结果 以下是脚本: geocoder = new GClientGeocoder(); geocoder.getLocations('43.3372814,(-1.79548311)', showAddress); function showAddress(response) { place = response.Placemark[0]; point = new GLatLng(place.Point.

我浪费了很多时间,但我做不到

谢谢你的帮助

如何在变量中得到逆地理定位的结果

以下是脚本:

geocoder = new GClientGeocoder();
geocoder.getLocations('43.3372814,(-1.79548311)', showAddress);

function showAddress(response) {

    place = response.Placemark[0];
    point = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);
    marker = new GMarker(point);
    map.addOverlay(marker);
    return(place.address);
}
我试着做:

var address = geocoder.getLocations('43.3372814,(-1.79548311)', showAddress);
但是没有结果

如第二个参数
showAddress
中所述,真正需要您帮助的是回调函数。因此,您必须执行以下操作:

geocoder.getLocations('43.3372814,(-1.79548311)', showAddress);

function showAddress(response) {
  if (!response || response.Status.code != 200) {
    alert("Status Code:" + response.Status.code);
  } else {
    place = response.Placemark[0];
    point = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);
    marker = new GMarker(point);
    map.addOverlay(marker);
    marker.openInfoWindowHtml(
        '<b>orig latlng:</b>' + response.name + '<br/>' + 
        '<b>latlng:</b>' + place.Point.coordinates[1] + "," + place.Point.coordinates[0] + '<br>' +
        '<b>Status Code:</b>' + response.Status.code + '<br>' +
        '<b>Status Request:</b>' + response.Status.request + '<br>' +
        '<b>Address:</b>' + place.address + '<br>' +
        '<b>Accuracy:</b>' + place.AddressDetails.Accuracy + '<br>' +
        '<b>Country code:</b> ' + place.AddressDetails.Country.CountryNameCode);
  }
}
geocoder.getLocations('43.3372814,(-1.79548311),showAddress);
函数showAddress(响应){
如果(!response | | response.Status.code!=200){
警报(“状态代码:+响应.状态.代码”);
}否则{
地点=响应。地点标记[0];
点=新玻璃(地点点坐标[1],地点点坐标[0]);
标记器=新的GMarker(点);
添加覆盖图(标记);
marker.openInfoWindowHtml(
'orig latlng:'+response.name+'
'+ “latlng:”+place.Point.coordinates[1]+“,“+place.Point.coordinates[0]+”
”+ '状态代码:'+response.Status.Code+'
'+ '状态请求:'+response.Status.Request+'
'+ '地址:'+place.Address+'
'+ '准确度:'+place.AddressDetails.accurity+'
'+ “国家/地区代码:”+place.AddressDetails.Country.CountryNameCode); } }
运行此代码时会发生什么。有什么错误吗?显示任何错误输出,描述发生了什么和没有发生什么,甚至设置示例都有助于在此获得答案检查此项。希望这对您有所帮助: