Google maps 如何使用谷歌地图将地址地理编码为lat/long

Google maps 如何使用谷歌地图将地址地理编码为lat/long,google-maps,google-maps-api-3,google-maps-markers,Google Maps,Google Maps Api 3,Google Maps Markers,我希望能够在谷歌地图上标出几家公司,并理解我需要对这些公司进行地理编码 我在地图上的多个标记下面也有代码 如何对多个公司地址进行地理编码(使用以下地址作为第一个示例)并将其合并到当前的代码中 我真的需要有人的帮助,因为我无法理解谷歌文档,也无法将其与我已有的文档结合起来。你可以用它来获取你的邮政编码坐标 编辑:我真的不喜欢你这样改变问题的意义,但没关系。请尝试这样的东西(未经测试): 尽管可能存在一些小错误,但这可能会起作用 编辑2:我刚刚发现: 谢谢,我不知道从哪里开始使用它,更不用说将它与我

我希望能够在谷歌地图上标出几家公司,并理解我需要对这些公司进行地理编码

我在地图上的多个标记下面也有代码

如何对多个公司地址进行地理编码(使用以下地址作为第一个示例)并将其合并到当前的代码中

我真的需要有人的帮助,因为我无法理解谷歌文档,也无法将其与我已有的文档结合起来。

你可以用它来获取你的邮政编码坐标

编辑:我真的不喜欢你这样改变问题的意义,但没关系。请尝试这样的东西(未经测试):

尽管可能存在一些小错误,但这可能会起作用

编辑2:我刚刚发现:


谢谢,我不知道从哪里开始使用它,更不用说将它与我现有的代码合并。请查看我提供的网站链接,并:,只需构建您的请求,如:eval json response from google,您很高兴gooops在geocode请求中忘记了传感器:maps.googleapis.com/maps/api/geocode/json?address=SW1A+0AA&sensor=false谢谢您的编辑。在我当前的代码中应该放在哪里?你应该把这些结果,而不是硬编码的带有latLng对象(位置)的数组,我会再次编辑答案以更清楚地显示出来
// Creating an array that will contain the coordinates 
// for New York, San Francisco, and Seattle
var places = [];

// Adding a LatLng object for each city
//places.push(new google.maps.LatLng(40.756, -73.986));
//places.push(new google.maps.LatLng(37.775, -122.419));
//places.push(new google.maps.LatLng(47.620, -122.347));
//places.push(new google.maps.LatLng(-22.933, -43.184));
var result;
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "http://maps.googleapis.com/maps/api/geocode/json?address=your+code&sensor=false",true);
 xmlhttp.onreadystatechange=function() {
  if (xmlhttp.readyState==4) {
       result = eval('(' + xmlhttp.responseText + ')');
if (result.status == "OK") {
var location = new google.maps.LatLng(result.results[0].geometry.location.lat, result.results[0].geometry.location.lng);
places.push(location);
// Creating an array that will contain the coordinates 
// for New York, San Francisco, and Seattle
var places = [];

// Adding a LatLng object for each city
//places.push(new google.maps.LatLng(40.756, -73.986));
//places.push(new google.maps.LatLng(37.775, -122.419));
//places.push(new google.maps.LatLng(47.620, -122.347));
//places.push(new google.maps.LatLng(-22.933, -43.184));
var geocoder = new google.maps.Geocoder();
geocoder.geocode( { 'address': "your+code"}, function(results, status) {
  if (status == google.maps.GeocoderStatus.OK) {
    map.setCenter(results[0].geometry.location);
    //var marker = new google.maps.Marker({
        //map: map,
        //position: results[0].geometry.location
    //});
    places.push(results[0].geometry.location);
  } else {
    alert("Geocode was not successful for the following reason: " + status);
  }
});