locked
How to get the client city,state,country,lattitude,longitude in asp.net??? RRS feed

  • Question

  • User-2136585936 posted

    Hi,

    How to get the client city,state,country,lattitude,longitude in asp.net???

    Thanks,

    Lakshman.

    Thursday, October 20, 2011 12:31 AM

Answers

  • User-2136585936 posted

    Hi,

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

    $.getJSON("http://www.geoplugin.net/json.gp?jsoncallback=?", function(data) {
    // for (var i in data) {
    // $('#divGeoDetails').append('data["i"] = ' + data.geoplugin_city + '<br/>');
    // }
    geoplugin_city = data.geoplugin_city;
    geoplugin_region = data.geoplugin_region;
    geoplugin_areaCode = data.geoplugin_areaCode;
    geoplugin_dmaCode = data.geoplugin_dmaCode;
    geoplugin_countryCode = data.geoplugin_countryCode;
    geoplugin_countryName = data.geoplugin_countryName;
    geoplugin_continentCode = data.geoplugin_continentCode;
    geoplugin_latitude = data.geoplugin_latitude;
    geoplugin_longitude = data.geoplugin_longitude;
    geoplugin_regionCode = data.geoplugin_regionCode;
    geoplugin_regionName = data.geoplugin_regionName;
    geoplugin_currencyCode = data.geoplugin_currencyCode;
    geoplugin_currencySymbol = data.geoplugin_currencySymbol;
    geoplugin_currencyConverter = data.geoplugin_currencyConverter;
    var url = 'http://www.geoplugin.net/extras/postalcode.gp?jsoncallback=?&lat=' + geoplugin_latitude + '&long=' + geoplugin_longitude + '&format=json';
    // alert("geoplugin_latitude" + geoplugin_latitude + " --- geoplugin_longitude" + geoplugin_longitude + " -- geoplugin_city " + geoplugin_city + " -- geoplugin_currencySymbol " + geoplugin_currencySymbol);
    $.getJSON(url, function(data1) {
    geoplugin_postCode = data1.geoplugin_postCode;

    if (geoplugin_postCode != '' && $('#TextBox2').val() == '' && geoplugin_countryCode == 'IN')
    $('#TextBox2').val(geoplugin_postCode);
    });
    });

    });
    </script>
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 20, 2011 3:11 AM

All replies

  • User674443648 posted

    what do you mean

    Thursday, October 20, 2011 12:40 AM
  • User-155225845 posted

    Hi,

    Use HTMl 5.0 GEO Location  feature to get the above details.

    but it is browser dependent. all browser not support this feature. only latest browsers can support.  it asks the client to enable this feature or not?

    based on client willing it will work.

    chekt the below links.

    http://html5demos.com/geo#view-source

    http://merged.ca/iphone/html5-geolocation

    hope this helps

    Thursday, October 20, 2011 12:47 AM
  • User-2136585936 posted

    Hi,

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

    $.getJSON("http://www.geoplugin.net/json.gp?jsoncallback=?", function(data) {
    // for (var i in data) {
    // $('#divGeoDetails').append('data["i"] = ' + data.geoplugin_city + '<br/>');
    // }
    geoplugin_city = data.geoplugin_city;
    geoplugin_region = data.geoplugin_region;
    geoplugin_areaCode = data.geoplugin_areaCode;
    geoplugin_dmaCode = data.geoplugin_dmaCode;
    geoplugin_countryCode = data.geoplugin_countryCode;
    geoplugin_countryName = data.geoplugin_countryName;
    geoplugin_continentCode = data.geoplugin_continentCode;
    geoplugin_latitude = data.geoplugin_latitude;
    geoplugin_longitude = data.geoplugin_longitude;
    geoplugin_regionCode = data.geoplugin_regionCode;
    geoplugin_regionName = data.geoplugin_regionName;
    geoplugin_currencyCode = data.geoplugin_currencyCode;
    geoplugin_currencySymbol = data.geoplugin_currencySymbol;
    geoplugin_currencyConverter = data.geoplugin_currencyConverter;
    var url = 'http://www.geoplugin.net/extras/postalcode.gp?jsoncallback=?&lat=' + geoplugin_latitude + '&long=' + geoplugin_longitude + '&format=json';
    // alert("geoplugin_latitude" + geoplugin_latitude + " --- geoplugin_longitude" + geoplugin_longitude + " -- geoplugin_city " + geoplugin_city + " -- geoplugin_currencySymbol " + geoplugin_currencySymbol);
    $.getJSON(url, function(data1) {
    geoplugin_postCode = data1.geoplugin_postCode;

    if (geoplugin_postCode != '' && $('#TextBox2').val() == '' && geoplugin_countryCode == 'IN')
    $('#TextBox2').val(geoplugin_postCode);
    });
    });

    });
    </script>
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 20, 2011 3:11 AM