I am using Google Maps API Geocoder to geocode an address.
Problem: When the server does the geocoding, I often (not always) get results that have the exact same lat/lng, and this is the lat/lng of the city center.
However when I call the exact same URL on my browser, I always get the correct lat/lng returned!
Any idea why its returning the wrong and different results when the same URL is called from server and from my browser?
Query URL
http://maps.googleapis.com/maps/api/geocode/json?address=6954 N Greenview, Chicago, IL&sensor=false®ion=us
Results on Server (Using curl)
"lat": 41.8781136
"lng": -87.6297982
Results on Browser
"lat" : 42.0082060,
"lng" : -87.66836499999999
I also believe it's region bias but did you tried comparing name and address of the result? It's happen to me sometimes I get the address and not the name lat lng pairs. I suggest you also to try this url from google http://maps.google.com/maps/geo?q= see my answer: Google Maps API: Geocode returns different co-ordinates then Google maps.
Related
Iam Using this library https://github.com/wimagguc/jquery-latitude-longitude-picker-gmaps
to make map with marker
and use in the backend laravel
i want to get the name of place where the marker located on it
how can i do it ?!
in the database i am saved the lat and lng
any way to get the name of place ???
enter image description here
Reverse Geocoding in Geocoding API would be able to help you convert latlng coordinates into addresses. You may refer to this documentation: https://developers.google.com/maps/documentation/geocoding/intro#ReverseGeocoding
Here is a sample HTTP request: https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&key=YOUR_API_KEY
However, kindly note that, and as mentioned in the doc, Reverse geocoding is an estimate. The geocoder will attempt to find the closest addressable location within a certain tolerance. If no match is found, the geocoder will return zero results.
I hope this helps!
Whenever a user enters my site, i want to get his longitude, latitude to further use in my google maps. I have tried using HTML5 geolocation script and geocoder gem.
Using Geocoder gem, my hash is empty when trying below code, why is this happening ? Is this because i am running it in localhost ? Please suggest how to get it done if any other way.
I just need latitude and longitude of my user, thats it.
location = request.location
longitude = location.data['longitude']
If you had carefully read documentation of geocoder gem you would notice that:
Note that these methods will usually return nil in your test and
development environments because things like "localhost" and "0.0.0.0"
are not an Internet IP addresses.
I plot locations of real estate on a map. The address listed below is mapped incorrectly because it is a new build and I assume the street and everything is a new build, which is the reason Google can't find it in it's database.
What I want to happen is Google return "GeocoderStatus.ZERO_RESULTS" and not just pick a location with a related name and give me those coords.
The address I'm plotting is:
14018 Lonecreek Ave
Orlando, Florida 32828
If you submit the request via http, you get the same results i get through the API, see this link: http://maps.googleapis.com/maps/api/geocode/json?address=140
You'll see it comes back with "Lone Hill Drive" which is incorrect location. How can I tell Google return ZERO_RESULTS status in this instance?
Google's geocoding process isn't perfect (none are.)
What you can check for is the result's geometry.location_type property and test if it's value is "APPROXIMATE" to see if you can trust the returned lat/lng. Read more in the Documentation.
If it's way off you can report it directly to google.
You can use the API's Component Filtering to filter the results by a specific postcode. In such cases a non-exact match will have location_type of "APPROXIMATE" rather than the "GEOMETRIC_CENTER" you were seeing before.
http://maps.googleapis.com/maps/api/geocode/json?address=[address]&components=postal_code:[postcode]&sensor=false
Here's your geocoding request WITH component filtering
and WITHOUT component filtering
I need to calculate the distance between two addresses and I don't need a map view or anything graphical.
I simply want the user to type in the address (end location is defined by myself) and let the javascript calculate the distance between the two points.
However I don't find a way to send an address string and get the GPS-coordinates from it using the Google Maps API.
(I really only need the two GPS points, the distance calculation is trivial.)
What you are trying to do is called geocoding. It is possible with the Maps API. See the Geocoding section for more details. This is the basic idea:
var geocoder = new google.maps.Geocoder();
geocoder.geocode({
"address": inputAddress
}, function(results) {
console.log(results[0].geometry.location); //LatLng
});
However, you are limited to 2500 geocoding requests a day, and what you are trying to do is against the terms of use:
Note: the Geocoding API may only be used in conjunction with a Google
map; geocoding results without displaying them on a map is prohibited.
This page describes a Google JSON service that you can extract gps coordinates from. I think this would also be under the "No Use of Content without a Google Map" in the TOS.
This is possible. See below link
http://briancray.com/posts/how-to-calculate-the-distance-between-two-addresses-with-javascript-and-google-maps-api
Loving Google Maps API V3, but having difficulty in getting accurate driving directions and manipulating the destination address displayed when using DirectionsRenderer.
Regardless if I pass an address string or a latLng instance as the destination to DirectionsService, when I use the DirectionsRenderer to output step-by-step directions, the destination text is always the geocoded result of my original destination (i.e. the address, rather than COMPANY NAME).
Ideally, I want to pass a precise latLng destination to DirectionsService, but control the text displayed as the 'destination'.
I guess I could manually output the HTML, but part lazy, part not wanting to re-invent the wheel, would prefer to use DirectionsRenderer.
Any ideas?
You may use:
response.routes[0].legs[0].end_address="Company";
before calling
directionsDisplay.setDirections(response);