Getting current geo Location of the user

edited December 2014 in How To...

Hey, I am using Unfolding Maps library to integrate the Open Street Maps Provider into my Java Application. What I want is that as the application starts the map directly zooms and points to the current geo Location of the user. So, the main problem I am encountering is to get the Geo Location of the user in processing. Any ideas anyone? Any help as soon as possible will be great.

Thanks!

Answers

  • edited December 2014 Answer ✓

    you can make GET requests to this api to get the long/lat from his ip

    http://www.telize.com/

    you actually need this endpoint http://www.telize.com/geoip

    the response is in json format

  • Thanks for the link. This works pretty well. But I think its accuracy is not that good. The actual location is varying by about 5 kms. What should I do?

  • maybe search for other geoip services and use the one that seems more accurate.. i do not think that you can get the exact location , i mean dont expect that it will be as accurate as a gps device

  • So, If I want to develop an android application how can I access the gps service of the phone from my processing application? Is it possible?

    Also, does any API exist on which I can query for the longitude and the latitude of a place? The query can be a string consisting of the name/location of the place.

  • edited December 2014

    i have not used processing in android a lot so i cannot answer for sure, i assume you can get pgs location by setting appropriate permissions..better wait for someone else answer this

    what you need is a geocoding service, like google`s or maybe you can find another provider..try to search in the programmableweb.com

    example with the address of Facebook headquarters that i found on line, using curl

    └──┤ curl https://maps.googleapis.com/maps/api/geocode/json?address=Menlo+Park
    {
       "results" : [
          {
             "address_components" : [
                {
                   "long_name" : "Menlo Park",
                   "short_name" : "Menlo Park",
                   "types" : [ "locality", "political" ]
                },
                {
                   "long_name" : "San Mateo County",
                   "short_name" : "San Mateo County",
                   "types" : [ "administrative_area_level_2", "political" ]
                },
                {
                   "long_name" : "California",
                   "short_name" : "CA",
                   "types" : [ "administrative_area_level_1", "political" ]
                },
                {
                   "long_name" : "United States",
                   "short_name" : "US",
                   "types" : [ "country", "political" ]
                }
             ],
             "formatted_address" : "Menlo Park, CA, USA",
             "geometry" : {
                "bounds" : {
                   "northeast" : {
                      "lat" : 37.5073225,
                      "lng" : -122.1210617
                   },
                   "southwest" : {
                      "lat" : 37.418539,
                      "lng" : -122.228677
                   }
                },
                "location" : {
                   "lat" : 37.4529598,
                   "lng" : -122.1817252
                },
                "location_type" : "APPROXIMATE",
                "viewport" : {
                   "northeast" : {
                      "lat" : 37.5073225,
                      "lng" : -122.1210617
                   },
                   "southwest" : {
                      "lat" : 37.418539,
                      "lng" : -122.228677
                   }
                }
             },
             "types" : [ "locality", "political" ]
          }
       ],
       "status" : "OK"
    }
    

    try your address and add your street number ex youAddress+10 and then check here just to be sure

Sign In or Register to comment.