西/东|来自Google API的GPS坐标的北/南

时间:2013-07-02 07:18:35

标签: ajax gps maps latitude-longitude

我有Lat&长。我怎样才能获得西/东| GPS的北/南?

附加截图:ScreenShot

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>

<script type="text/javascript" src="/design/js/jquery-autocomplete/jquery.autocomplete_geomod.js"></script>

<script type="text/javascript" src="/design/js/jquery-autocomplete/geo_autocomplete.js"></script>
<link rel="stylesheet" type="text/css" href="/design/js/jquery-autocomplete/jquery.autocomplete.css" />

<script type="text/javascript">
$().ready(function() {

    var latlng = new google.maps.LatLng(-34.397, 150.644);
    var myOptions = {
      zoom: 8,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

    // use all the autocomplete options as documented at http://docs.jquery.com/Plugins/Autocomplete
    /* additional geo_autocomplete options:
        mapkey : 'ABQ...' (required for Static Maps thumbnails, obtain a key for your site from http://code.google.com/apis/maps/signup.html)
        mapwidth : 100
        mapheight : 100
        maptype : 'terrain' (see http://code.google.com/apis/maps/documentation/staticmaps/#MapTypes)
        mapsensor : true or false
    */
    $('#location').geo_autocomplete(new google.maps.Geocoder, {
        mapkey: 'ABQIAAAAbnvDoAoYOSW2iqoXiGTpYBTIx7cuHpcaq3fYV4NM0BaZl8OxDxS9pQpgJkMv0RxjVl6cDGhDNERjaQ', 
        selectFirst: false,
        minChars: 3,
        cacheLength: 50,
        width: 300,
        scroll: true,
        scrollHeight: 330
    }).result(function(_event, _data) {

    var coords = new google.maps.LatLng(
                        _data.geometry.location.lat(),
                        _data.geometry.location.lng()
                    );

        $('#lat').val (_data.geometry.location.lat())
        $('#lng').val (_data.geometry.location.lng())


        console.log (coords.lat () + '/' + coords.lng ());

        if (_data) map.fitBounds(_data.geometry.viewport);
    });

});
</script>
<style>
.ac_results li img {
    float: left;
    margin-right: 5px;
}
</style>

<h3><a href="http://code.google.com/p/geo-autocomplete">jQuery geo-autocomplete Plugin</a> Demo</h3>

<div>Location: <input type="text" id="location" /> (autocomplete)</div>
<br/>
<div id="coords">Lat: 
    <input id="lat" name="lat" />
    Lng: 
    <input id="lng" name="lng" />
</div>
<br/>

1 个答案:

答案 0 :(得分:3)

东/西:如果经度&lt; 0然后西,否则东 北/南:如果纬度< 0然后南方其他北方

说明:
0-Meridian(通过伦敦/格林威治)是西方和东方之间的界限 Aequator是南北之间的限制。

在Google中,坐标以十进制度表示,其中负号定义为E / W或N / S