Retrieve latitude and longitude of a draggable pin via Google Maps API V3

Either of these work google.maps.event.addListener(marker, ‘click’, function (event) { document.getElementById(“latbox”).value = event.latLng.lat(); document.getElementById(“lngbox”).value = event.latLng.lng(); }); google.maps.event.addListener(marker, ‘click’, function (event) { document.getElementById(“latbox”).value = this.getPosition().lat(); document.getElementById(“lngbox”).value = this.getPosition().lng(); }); You might also consider using the dragend event also google.maps.event.addListener(marker, ‘dragend’, function (event) { document.getElementById(“latbox”).value = this.getPosition().lat(); document.getElementById(“lngbox”).value = this.getPosition().lng(); });

get Lat Lang from a place_id returned by autocomplete place api

The following code snippet which uses Google Places API for android worked for me Places.GeoDataApi.getPlaceById(mGoogleApiClient, placeId) .setResultCallback(new ResultCallback<PlaceBuffer>() { @Override public void onResult(PlaceBuffer places) { if (places.getStatus().isSuccess()) { final Place myPlace = places.get(0); LatLng queriedLocation = myPlace.getLatLng(); Log.v(“Latitude is”, “” + queriedLocation.latitude); Log.v(“Longitude is”, “” + queriedLocation.longitude); } places.release(); } }); Visit Google Places API … Read more

Using Address Instead Of Longitude And Latitude With Google Maps API

See this example, initializes the map to “San Diego, CA”. Uses the Google Maps Javascript API v3 Geocoder to translate the address into coordinates that can be displayed on the map. <html> <head> <meta name=”viewport” content=”initial-scale=1.0, user-scalable=no”/> <meta http-equiv=”content-type” content=”text/html; charset=UTF-8″/> <title>Google Maps JavaScript API v3 Example: Geocoding Simple</title> <script type=”text/javascript” src=”http://maps.google.com/maps/api/js?sensor=false”></script> <script type=”text/javascript”> var … Read more

Google Maps API – how to get latitude and longitude from Autocomplete without showing the map?

You can use the code below. <script src=”http://maps.googleapis.com/maps/api/js?libraries=places” type=”text/javascript”></script> <script type=”text/javascript”> function initialize() { var input = document.getElementById(‘searchTextField’); var autocomplete = new google.maps.places.Autocomplete(input); google.maps.event.addListener(autocomplete, ‘place_changed’, function () { var place = autocomplete.getPlace(); document.getElementById(‘city2’).value = place.name; document.getElementById(‘cityLat’).value = place.geometry.location.lat(); document.getElementById(‘cityLng’).value = place.geometry.location.lng(); //alert(“This function is working!”); //alert(place.name); // alert(place.address_components[0].long_name); }); } google.maps.event.addDomListener(window, ‘load’, initialize); </script> and … Read more

How can I quickly estimate the distance between two (latitude, longitude) points?

The answers to Haversine Formula in Python (Bearing and Distance between two GPS points) provide Python implementations that answer your question. Using the implementation below I performed 100,000 iterations in less than 1 second on an older laptop. I think for your purposes this should be sufficient. However, you should profile anything before you optimize … Read more

How to convert an address to a latitude/longitude?

Google has a geocoding API which seems to work pretty well for most of the locations that they have Google Maps data for. http://googlemapsapi.blogspot.com/2006/06/geocoding-at-last.html They provide online geocoding (via JavaScript): http://code.google.com/apis/maps/documentation/services.html#Geocoding Or backend geocoding (via an HTTP request): http://code.google.com/apis/maps/documentation/services.html#Geocoding_Direct The data is usually the same used by Google Maps itself. (note that there are some … Read more

How can I measure distance and create a bounding box based on two latitude+longitude points in Java?

Here is a Java implementation of Haversine formula. I use this in a project to calculate distance in miles between lat/longs. public static double distFrom(double lat1, double lng1, double lat2, double lng2) { double earthRadius = 3958.75; // miles (or 6371.0 kilometers) double dLat = Math.toRadians(lat2-lat1); double dLng = Math.toRadians(lng2-lng1); double sindLat = Math.sin(dLat / … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)