Geocoding with PHP and ajax

PHP로 geocoding 사용하기

<?php
file_get_contents("https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=YOUR_API_KEY")
?>

Ajax로 geocoding 사용하기

$.ajax({
    url : "https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=YOUR_API_KEY",
    type: "GET",
    success: function (data) {

        $.each(data["results"][0]["address_components"], function(key, value) {
            if (value["types"][0] == "country") {
                alert(value["short_name"]);
            }
        })
    }
})

© 2018. All rights reserved.

Powered by Hydejack v8.5.2