Google Map geocoder is not as accurate as Google maps

I have a database containing addresses that match the build level. When I put them manually in a search on Google Maps, Google Maps does not find their problems - markers appear directly above the correct building. However, when I pass these same addresses to the Google Maps API surveyor using the code below, the tokens are displayed only on the street, not in the building.

How to increase accuracy?

HTML / PHP:

<div id="addressline"><?php echo theaddress(); ?></div> 

JS:

  function myGeocodeFirst() { geocoder = new google.maps.Geocoder(); geocoder.geocode( {'address': document.getElementById("addressline").innerHTML}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { firstLoc = results[0].geometry.location; map = new google.maps.Map(document.getElementById("map_canvas"), { center: firstLoc, zoom: 15, mapTypeId: google.maps.MapTypeId.ROADMAP }); markers = new google.maps.Marker({ position: firstLoc, map: map, }); } else { document.getElementById("text_status").value = status; } } ); } window.onload=myGeocodeFirst; 
+1
source share
2 answers

Google Maps uses several different data sources to search for search results on a map.

The record you see is โ€œcorrectโ€, is the record of the โ€œPlacesโ€ database. See this page and enter the search bar (St Clements Church, Edge Lane, Chorlton, M21 9JF).

The geocoder gets designed to return the coordinates of postal addresses, your line does not have enough information to get accurate results:

http://www.geocodezip.com/v3_example_geo2.asp?addr1=St%20Clement%E2%80%99s%20Church,%20Edge%20Lane,%20Chorlton,%20M21%209JF&geocode=1

It looks like it just returns the geocode for the zip code:

 Manchester M21 9JF, UK (53.4414411, -2.285287100000005) 

It looks like the geocoder has this place in it. If I use "St Clements Church, Edge Lane", it seems to get the geocode on the roof (although it reports "APPROXIMATE")

http://www.geocodezip.com/v3_example_geo2.asp?addr1=St%20Clement%E2%80%99s%20Church,%20Edge%20Lane,%20Chorlton,%20M21%209JF&geocode=1&addr2=St%20Clement%E2%80 % 99s% 20Church,% 20Edge% 20Lane & geocode = 2

 St Clement Church, 6 Edge Ln, Manchester, Lancashire M21 9JF, UK (53.4406823, -2.283755499999984) 

proof of conceptual scripts

code snippet:

 var geocoder, map, service, infowindow, bounds; function initialize() { map = new google.maps.Map( document.getElementById("map_canvas"), { center: new google.maps.LatLng(37.4419, -122.1419), zoom: 13, mapTypeId: google.maps.MapTypeId.ROADMAP }); var request = { query: "St Clement's Church, Edge Lane, Chorlton, M21 9JF" } infowindow = new google.maps.InfoWindow(); service = new google.maps.places.PlacesService(map); bounds = new google.maps.LatLngBounds(); service.textSearch(request, callback); } google.maps.event.addDomListener(window, "load", initialize); function callback(results, status) { if (status == google.maps.places.PlacesServiceStatus.OK) { for (var i = 0; i < results.length; i++) { var place = results[i]; var marker = createMarker(results[i]); bounds.extend(marker.getPosition()) } map.fitBounds(bounds); google.maps.event.trigger(marker, 'click'); } } function createMarker(place) { var placeLoc = place.geometry.location; var marker = new google.maps.Marker({ map: map, position: place.geometry.location }); google.maps.event.addListener(marker, 'click', function() { infowindow.setContent(place.name); infowindow.open(map, this); }); return marker; } 
 html, body, #map_canvas { height: 100%; width: 100%; margin: 0px; padding: 0px } 
 <script src="https://maps.googleapis.com/maps/api/js?libraries=places"></script> <div id="map_canvas"></div> 
+3
source

Basically there is a name and address. The Google database may have a different name for the same location. You can read my answer here: http://www.stackoverflow.com/questions/12788664/google-maps-api-geocode-returns-different-co-ordinates-then-google-maps/12790012#12790012 . In google's answer, you need to go through the tags object to find the most similar location.

+1
source

All Articles