user1604256
user1604256

Reputation: 21

How do I move marker to the street in front of address

I am using the google geocodeing and for a lot of the rural addresses the marker gets placed in the middle of the lot. What I need to have is the marker placed on the street in front of the address that was geocoded.

Here is a link to what I currently have for testing. http://www.commsoft.net/maps/index.html

Any suggestions would be greatly appreciated.

Upvotes: 2

Views: 686

Answers (2)

geocodezip
geocodezip

Reputation: 161374

  1. The best way to display multiple addresses on a Google Maps API map is to geocode them off-line and store the coordinates in your database (or where ever you are getting the addresses from). If you are going to display more than 10-15 markers using the geocoder or the directions service, you will run into the quota/rate limits.
  2. If you geocode the addresses off line, if you don't like the values that are returned by the geocoder, you can fix them.
  3. An option for programmatically getting coordinates on the street nearest an address is to use the directions service (get directions from the address of interest to itself, should result in a zero length route with the same start and end point on the road at the point closest to the address).

example using your addresses

Upvotes: 0

xcer
xcer

Reputation: 1707

You could possibly use the Google Maps API StreetViewService to get the street location you need.

Google Maps API - Directly Accessing Street View Data

  1. Get the latLng location using the Geocoder
  2. Send that location, a search radius, and a callback function to the streetview service:

    var streetViewService = new google.maps.StreetViewService(); streetViewService.getPanoramaByLocation(location, searchRadius, callbackFunction);

  3. The streetViewService will respond with the closest streetView photo it has to your location. In your callback function, callbackFunction(data, status), data.location.latLng will contain the location on the street where that streetview photo was taken.

  4. Use that location for your marker.

It isn't a perfect solution, but it might be the best you can do, short of storing your own street locations in a database. The main drawback is that, in order for it to work, the address must have a streetview image. So if you are mostly concerned with rural addresses, it might not work for you.

Upvotes: 1

Related Questions