geolocation

NETWORK_PROVIDER not providing updated locations

扶醉桌前 提交于 2019-11-27 03:11:16
LocationManager locationManager = (LocationManager)getApp().getSystemService(Context.LOCATION_SERVICE); //getApp() returns my Application object locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER , 1, 1, this); locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1, 1, this); That's the code I'm using to listen. With GPS enabled, everything works fine. However, if I disable GPS and rely on network location, it gives me stale results -- in this case, from two days ago. I cannot get it to update. Calling getLastKnownLocation returns the same stale results.

Get country from latitude longitude

你离开我真会死。 提交于 2019-11-27 03:01:01
I would like to know how I can get the country name from latitude & longitude using JavaScript. I am open to use of Google Maps’ JavaScript API. Can I also get city and zip? Edit: My aim is to fill up the address field automatically, not to display it on a map. Christian I don't know if it works with google maps, but there is a web service that returns a country code and takes as parameters the lat and long. Here is an example: http://api.geonames.org/countryCodeJSON?lat=49.03&lng=10.2&username=demo Returns a JSON data: {"languages":"de","distance":"0","countryCode":"DE","countryName":"Germany

Find a Location within a stored Circle

喜欢而已 提交于 2019-11-27 03:00:06
问题 I have data in MongoDB representing a Circle as follows: { "_id" : ObjectId("54c1dc6506a4344d697f7675"), "location" : [ 23.027573, 72.50675800000001 ], "radius" : 500 } I want to query with lat & long to determine whether the location is withing stored lat&long and radius. I tried following query but unable to execute: db.test.find({location:{ $geoWithin: { $center: [ [ -74, 40.74 ] , "$radius"] } }}) How can we used stored radius in geoWithin query? 回答1: Even more optimal than the original,

Wait until a condition is true?

烈酒焚心 提交于 2019-11-27 02:40:27
问题 I'm using navigator.geolocation.watchPosition in JavaScript, and I want a way to deal with the possibility that the user might submit a form relying on location before watchPosition has found its location. Ideally the user would see a 'Waiting for location' message periodically until the location was obtained, then the form would submit. However, I'm not sure how to implement this in JavaScript given its lack of a wait function. Current code: var current_latlng = null; function gpsSuccess(pos

How to convert longitude and latitude to street address

纵饮孤独 提交于 2019-11-27 02:39:22
问题 Given the latitude and longitude, how do we convert it to street address using Javascript or Python? 回答1: 99% of the time, most people link you to Google Maps's API. Not a bad answer. HOWEVER -- Beware of the prohibited uses, usage limits and Terms of Use! While a distributed app many not run afoul of the usage limit, it is quite limiting for a web app. The TOS does not allow you to repurpose Google's data into an app with your skin on it. You would hate to have your business plan derailed by

Cordova geolocation accuracy gets capped at 10 meters

你离开我真会死。 提交于 2019-11-27 02:37:28
问题 Update: it is a Google Play Service issue, reported internally here and it will be fixed from version 13.4.0 We use the cordova gelocation plugin and the method navigator.geolocation.watchPosition() with the option enableHighAccuracy: true to track the user location and get the most accurate results. Our app has been around for more than 1 year and we used to have no problems with any device getting a very good location accuracy, 4/6 meters when outside and the sky is clear. Lately, many of

How accurately should I store latitude and longitude?

谁都会走 提交于 2019-11-27 02:29:57
I was reading this question here: What datatype to use when storing latitude and longitude data in SQL databases? And it seems the general consensus is that using Decimal(9,6) is the way to go. The question for me is, how accurate do I really need this? For instance, Google's API returns a result like: "lat": 37.4219720, "lng": -122.0841430 Out of -122.0841430, how many digits do I need? I've read several guides but I can't make enough sense out of them to figure this out. To be more precise in my question: If I want to be accurate within 50 feet of the exact location, how many decimal points

Get the particular address using latitude and longitude

会有一股神秘感。 提交于 2019-11-27 02:24:50
问题 I need to know is there any API ,from where i can receive the Address of the current place.Using location Manager i have receive the latitude and longitude of the current place ,but i need the address. I have tried the below api. http://maps.googleapis.com/maps/api/geocode/json?latlng="+ lat + "," + lon + &sensor=true" But it is not showing the exact place .Can somebody help me.@Thanks 回答1: From a Geocoder object, you can call the getFromLocation(double, double, int) method. like :- private

How to highlight a user's current location in google maps?

南楼画角 提交于 2019-11-27 02:21:46
问题 I am using following code to get the location of user in phonegap (it works fine) function getLocation() { var win = function(position) { var lat = position.coords.latitude; var long = position.coords.longitude; var myLatlng = new google.maps.LatLng(lat, long); var myOptions = { center: myLatlng, zoom: 7, mapTypeId : google.maps.MapTypeId.ROADMAP }; var map_element = document.getElementById("displayMap"); var map = new google.maps.Map(map_element, myOptions); }; var fail = function(e) { alert

Switching between network and GPS provider

房东的猫 提交于 2019-11-27 02:18:39
问题 I want to implement a locationListener which will switch between network and GPS providers based on availability. For example if GPS is not enabled I want it to use network but as soon as GPS is on then I want it to stop listening for location updates from network and start listening from GPS. Similarly I want it to start listening for updates from network as soon as GPS is switched off. Is that possible? Subquestion Is GPS as fast as network in providing a location fix? 回答1: Sure, you just