geolocation

toRad() Javascript function throwing error

梦想的初衷 提交于 2019-11-26 18:47:57
I'm trying to find the distance between two points (for which I've latitudes & longitudes) using the technique described here at Calculate distance between two latitude-longitude points? (Haversine formula) The codes are as below Javascript: var R = 6371; // Radius of the earth in km var dLat = (lat2-lat1).toRad(); // Javascript functions in radians var dLon = (lon2-lon1).toRad(); var a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.cos(lat1.toRad()) * Math.cos(lat2.toRad()) * Math.sin(dLon/2) * Math.sin(dLon/2); var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); var d = R * c; // Distance in

Java, convert lat/lon to UTM [closed]

混江龙づ霸主 提交于 2019-11-26 18:42:20
Does anyone know of a way, in Java, to convert an earth surface position from lat, lon to UTM (say in WGS84)? I'm currently looking at Geotools but unfortunately the solution is not obvious. No Library, No Nothing. Copy This! Using These Two Classes , You can Convert Degree(latitude/longitude) to UTM and Vice Versa! private class Deg2UTM { double Easting; double Northing; int Zone; char Letter; private Deg2UTM(double Lat,double Lon) { Zone= (int) Math.floor(Lon/6+31); if (Lat<-72) Letter='C'; else if (Lat<-64) Letter='D'; else if (Lat<-56) Letter='E'; else if (Lat<-48) Letter='F'; else if (Lat

How to determine a zip code and city from an IP address? [closed]

血红的双手。 提交于 2019-11-26 18:27:13
I am looking for advice for open API or 3d party products which will help to convert an IP address to a zip code and city, to make geo-specific web site content. What I use is ip2nation: http://www.ip2nation.com It is a completely free MySQL database of IP to country mappings. They include a few sample PHP scripts at their site. I use it on my WordPress blog along with Ozh's free IP to Nation WordPress Plugin Even if you are not using WordPress, download the plugin as it will give you a good set of PHP code to access the database with. He even has a nice set of tiny country flags that you can

How to obtain longitude and latitude for a street address programmatically (and legally)

安稳与你 提交于 2019-11-26 18:19:46
Supposedly, it is possible to get this from Google Maps or some such service. (US addresses only is not good enough.) Sijin The term you're looking for is geocoding and yes Google does provide this service. New V3 API : http://code.google.com/apis/maps/documentation/geocoding/ Old V2 API: http://code.google.com/apis/maps/documentation/services.html#Geocoding Tim Farley In addition to the aforementioned Google geocoding web service , there is also a competing service provided by Yahoo . In a recent project where geocoding is done with user interaction, I included support for both. The reason is

Android Phonegap - How to Open Native Google Maps Application

北战南征 提交于 2019-11-26 18:09:57
问题 I'm working on an Android application using Phonegap and am having trouble figuring out how to open the native Google Maps application to display directions. I don't have any issue opening a map by inserting a URL but opening the application has me stumped. So far I have only been able to find Phonegap related suggestions for development on the iOS platform. I have added Google Maps to the whitelist permissions, am including the correct Cordova.js file and google maps link in my script tag,

how to convert between degrees, minutes, seconds to Decimal coordinates

一笑奈何 提交于 2019-11-26 17:45:23
问题 Looking for a java utility. It is even better if you can tell me how to do it using geotools library. 回答1: By "Decimal coordinates" do you mean latitude and longitude (also known as the decimal degree)? If so, what you're trying to do is pretty easy: Given a DMS (Degrees, Minutes, Seconds) coordinate such as W87°43′41″, it's trivial to convert it to a number of decimal degrees using the following method: Calculate the total number of seconds, 43′41″ = (43*60 + 41) = 2621 seconds. The

FusedLocationApi.getLastLocation always null

喜你入骨 提交于 2019-11-26 17:37:59
I'd like to simply retrieve device location in my Android project and in order to do so I use the play-services approach: protected synchronized void buildGoogleApiClient() { mGoogleApiClient = new GoogleApiClient.Builder( MainSearchActivity.this ) .addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() { @Override public void onConnected( Bundle bundle ){ Location location = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient); if( location == null ){ LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, new LocationListener() {

Convert UTC offset to timezone or date

浪尽此生 提交于 2019-11-26 17:35:15
A head scratcher for you. I am grabbing geo IP data from IPInfoDB 's API and it returns a timezone offset from UTC including DST (if currently reflected). For example, I live in EST (-5) and currently it's DST, so the geo IP API returns ( -04:00 ) as the offset. This is wonderful since DST is a freaking headache. But to my surprise, it caused another headache. I load this data in PHP to be passed via AJAX to the application. I would like to have the live local time of the IP address on the app. I have that all set perfectly, but I am going crazy trying to figure out how to set the PHP timezone

LocationListener of NETWORK_PROVIDER is enabled but , onLocationChanged is never called

旧时模样 提交于 2019-11-26 17:22:59
I am developing an application that gets position of the cell phone all day long in 6 and 6 minutes in a service, it works fine but sometimes the method OnLocationChanged of the Network provider listener stop to being called, and I don't know why. It for some reason stop being called, but the Provider is enable and the Lister is working, when I Enable or disable the Provider manually, onProviderEnabled and onProviderDisabled is called. It just happens with NETWORK_PROVIDER , the GPS_PROVIDER works well. Listener: LocationListener locationListenerGPS = new LocationListener() { // @Override

Mercator longitude and latitude calculations to x and y on a cropped map (of the UK)

断了今生、忘了曾经 提交于 2019-11-26 17:18:38
I have this image: http://imgur.com/99tSz.png . A map of the UK (not including Southern Ireland). I have successfully managed to get a latitude and longitude and plot it onto this map by taking the leftmost longitude and rightmost longitude of the UK and using them to work out where to put the point on the map. This is the code (for use in Processing.js but could be used as js or anything): // Size of the map int width = 538; int height = 811; // X and Y boundaries float westLong = -8.166667; float eastLong = 1.762833; float northLat = 58.666667; float southLat = 49.95; void drawPoint(float