如何获得特定城市/国家/地区的经度/纬度? [关闭]

For example when I enter an address on the http://www.infoghidromania.com/harta_romania.html website and then press submit, it should extract the GPS coordinates.

That site uses the google maps api. You can use the same API to get the longtitude/lattitude for any location you can find on google maps itself.

Javascript code example:

var geocoder =  new google.maps.Geocoder();
geocoder.geocode( { 'address': '<YOUR_SEARCH_STRING_HERE>' }, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
        alert("Lang/Lat : " + results[0].geometry.location.lat() + " " +results[0].geometry.location.lng()); 
    } else {
        alert('Error: ' + status);
    }
});

Working examples:

Using jquery:

$(function(){
    $('idOfInputField').val("content");
    $('the id of the form').submit();
});

What you are looking for is called "geocoding". Google Maps has an API you can use - you can see the details here

A quick example of how to use it (assuming this is in a file called latLong.php):

<html encoding="utf-8">

<body>
    Please enter address to look up:
    <form method="get" action="latLong.php">
        <input name="address" />
        <input type="submit" />
    </form>
<?php
    $crlf = "<br>";

    if (isset($_GET["address"])) {
        $addressString = $_GET["address"];
        $address = urlencode($addressString);
        $googleApi = 'http://maps.googleapis.com/maps/api/geocode/json?address=%s&sensor=false';     

        $json = file_get_contents(sprintf($googleApi, $address));   
        $resultObject = json_decode($json);

        $location = $resultObject->results[0]->geometry->location;

        $lat = $location->lat;
        $lng = $location->lng;

        echo "Requested address: ".$addressString.$crlf; 
        echo "Latitude: ".$lat.$crlf;
        echo "Longitude: ".$lng.$crlf;
    }
?>
</body>
</html>