Подтвердить что ты не робот

Как преобразовать долготу и широту в адрес улицы

Учитывая широту и долготу, как мы преобразуем ее в адрес улицы с помощью Javascript или Python?

4b9b3361

Ответ 1

В 99% случаев большинство людей связывают вас с API Карт Google. Неплохой ответ. ОДНАКО - Остерегайтесь запрещенных видов использования, ограничений использования и Условия использования! В то время как распределенное приложение многие не работают с ограничениями использования, это довольно ограничивает веб-приложение. TOS не позволяет вам перегруппировать данные Google в приложение с вашим скином на нем. Вы не хотели бы, чтобы ваш бизнес-план был сорван из-за прекращения и отказа от письма от Google, нет?

Все не потеряно. Существует несколько открытых источников данных, включая источники в правительстве США. Вот несколько из лучших:

Перепись США База данных тигра, в частности, поддерживает обратное геокодирование и является бесплатной и открытой для американских адресов. Большинство других баз данных выходят из него в США.

Geonames и OpenStreetMap являются пользователями поддерживается в модели Википедии.

Ответ 3

Вы можете попробовать https://mapzen.com/pelias открыть исходный код и активно развиваться. например http://pelias.mapzen.com/reverse?lat=40.773656&lon=-73.9596353 возвращает (после форматирования): { "type":"FeatureCollection", "features":[ { "type":"Feature", "properties":{ "id":"address-node-2723963885", "type":"osmnode", "layer":"osmnode", "name":"151 East 77th Street", "alpha3":"USA", "admin0":"United States", "admin1":"New York", "admin1_abbr":"NY", "admin2":"New York", "local_admin":"Manhattan", "locality":"New York", "neighborhood":"Upper East Side", "text":"151 East 77th Street, Manhattan, NY" }, "geometry":{ "type":"Point", "coordinates":[-73.9596265, 40.7736566] } } ], "bbox":[-73.9596265, 40.7736566, -73.9596265, 40.7736566], "date":1420779851926 }

Ответ 4

Для этого есть библиотека google. Посещение этот сайт.

Ответ 5

Вы можете использовать Google Geo API. Пример кода для API V3 доступен на мой блог

<HEAD>
  <TITLE>Convert Latitude and Longitude (Coordinates) to an Address Using Google Geocoding API V3 (Javascript)</TITLE>

  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
  <script>

    var address = new Array();

    /*
    * Get the json file from Google Geo
    */
    function Convert_LatLng_To_Address(lat, lng, callback) {
            var url = "http://maps.googleapis.com/maps/api/geocode/json?latlng=" + lat + "," + lng + "&sensor=false";
            jQuery.getJSON(url, function (json) {
                Create_Address(json, callback);
            });     
    }

    /*
    * Create an address out of the json 
    */
    function Create_Address(json, callback) {
        if (!check_status(json)) // If the json file status is not ok, then return
            return 0;
        address['country'] = google_getCountry(json);
        address['province'] = google_getProvince(json);
        address['city'] = google_getCity(json);
        address['street'] = google_getStreet(json);
        address['postal_code'] = google_getPostalCode(json);
        address['country_code'] = google_getCountryCode(json);
        address['formatted_address'] = google_getAddress(json);
        callback();
    }

    /* 
    * Check if the json data from Google Geo is valid 
    */
    function check_status(json) {
        if (json["status"] == "OK") return true;
        return false;
    }   

    /*
    * Given Google Geocode json, return the value in the specified element of the array
    */

    function google_getCountry(json) {
        return Find_Long_Name_Given_Type("country", json["results"][0]["address_components"], false);
    }
    function google_getProvince(json) {
        return Find_Long_Name_Given_Type("administrative_area_level_1", json["results"][0]["address_components"], true);
    }
    function google_getCity(json) {
        return Find_Long_Name_Given_Type("locality", json["results"][0]["address_components"], false);
    }
    function google_getStreet(json) {
        return Find_Long_Name_Given_Type("street_number", json["results"][0]["address_components"], false) + ' ' + Find_Long_Name_Given_Type("route", json["results"][0]["address_components"], false);
    }
    function google_getPostalCode(json) {
        return Find_Long_Name_Given_Type("postal_code", json["results"][0]["address_components"], false);
    }
    function google_getCountryCode(json) {
        return Find_Long_Name_Given_Type("country", json["results"][0]["address_components"], true);
    }
    function google_getAddress(json) {
        return json["results"][0]["formatted_address"];
    }   

    /*
    * Searching in Google Geo json, return the long name given the type. 
    * (if short_name is true, return short name)
    */

    function Find_Long_Name_Given_Type(t, a, short_name) {
        var key;
        for (key in a ) {
            if ((a[key]["types"]).indexOf(t) != -1) {
                if (short_name) 
                    return a[key]["short_name"];
                return a[key]["long_name"];
            }
        }
    }   

  </SCRIPT>
</HEAD>

Ответ 6

var geocoder  = new google.maps.Geocoder();             // create a geocoder object
var location  = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);    // turn coordinates into an object          
geocoder.geocode({'latLng': location}, function (results, status) {
if(status == google.maps.GeocoderStatus.OK) {           // if geocode success
var add=results[0].formatted_address;         // if address found, pass to processing function
document.write(add);

источник из https://gist.github.com/marchawkins/9406213/download# он работает me