Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.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/7/google-maps/4.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
Jquery 使用地址而不是lat&;长的_Jquery_Google Maps_Reverse Geocoding - Fatal编程技术网

Jquery 使用地址而不是lat&;长的

Jquery 使用地址而不是lat&;长的,jquery,google-maps,reverse-geocoding,Jquery,Google Maps,Reverse Geocoding,我正在构建一个地图,根据每个列表更改的页面地址填充其位置。我没有反向地理编码器,但想知道是否有办法只添加地址?如果没有,我如何反向地理编码我的地址?我不太了解谷歌的API页面,不了解这类事情 这是我的代码: <script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyBEbIFpr3iySjmSuJz4mwEomIaXnsA8OdQ&sensor=false"> </script>

我正在构建一个地图,根据每个列表更改的页面地址填充其位置。我没有反向地理编码器,但想知道是否有办法只添加地址?如果没有,我如何反向地理编码我的地址?我不太了解谷歌的API页面,不了解这类事情

这是我的代码:

      <script
src="http://maps.googleapis.com/maps/api/js?key=AIzaSyBEbIFpr3iySjmSuJz4mwEomIaXnsA8OdQ&sensor=false">
</script>

            <script>
function initialize()
{
  var mapProp = {
    center: new google.maps.LatLng(51.508742,-0.120850),
    zoom:7,
    disableDefaultUI:true,    
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };
  var map = new google.maps.Map(document.getElementById("googleMap"),mapProp);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
        <div id="googleMap" style="width:100%;height:100px;"></div> 

函数初始化()
{
var mapProp={
中心:新google.maps.LatLng(51.508742,-0.120850),
缩放:7,
disableDefaultUI:true,
mapTypeId:google.maps.mapTypeId.ROADMAP
};
var map=new google.maps.map(document.getElementById(“googleMap”),mapProp);
}
google.maps.event.addDomListener(窗口“加载”,初始化);

您必须使用地理编码器获取一个地方的纬度和经度

你可以这样做:

var geocoder;
var map;

function initialize()
{
    geocoder = new google.maps.Geocoder();

    var mapProp = {
        center: new google.maps.LatLng(51.508742,-0.120850),
        zoom:7,
        disableDefaultUI:true,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };

    map = new google.maps.Map(document.getElementById("googleMap"), mapProp);

    geocoder.geocode({ 'address': 'London' }, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            map.setCenter(results[0].geometry.location);

            // To add a marker:
            var marker = new google.maps.Marker({
                map: map,
                position: results[0].geometry.location
            });
        } else {
            alert("Geocode was not successful for the following reason: " + status);
        }
    });
}

google.maps.event.addDomListener(window, 'load', initialize);

所有信息均可在

上找到。您是否搜索过地理编码器的文档?您只需添加一个地址,它就会返回一个latLng。因此,它可以不是:center:new google.maps.latLng(51.508742,-0.120850),而是:center:new google.maps.latLng(伦敦),