Plotting a Google defined "route" - google-maps

When using the Google Places Autocomplete to return a "route" type, such as a street, I want to take that route and plot several markers along it on the map.
Example: Take the entire route of "Yonge Street, Toronto, ON, Canada" and place markers all along that street from the beginning to end.
Currently searching for "Yonge Street, Toronto, ON, Canada" returns a single Lat/Long point for the entire route.
This needs to be done in a way that doesn't involve me manually selecting each point as I need this to function for any Google "route" on the globe.
I am stumped as to way to do this using Google Maps API v3.. perhaps there is another service that can help me get the Lat/Long points I need which I can then feed to the Google Maps API?

What you are looking for is currently not possible with the Google Maps API v3. You could add an enhancement request to the issues list, but doesn't seem likely to happen.
The geocoder actually returns 3 points along the road for your query ("Yonge Street, Toronto, ON, Canada"). You can get the coordinates of the street using the directions service, but you have to manually find the start and end, and possibly walking directions, maybe even add waypoints. But you said you didn't want to do that...

Related

Geolocation: How to get a uniqueID for a street/block?

Background I'm a bit new to google maps/mapping sdks in general. I want to create a street by street "heat" map of an area on iOS. As an easy to understand example, let's say it will be for the purpose of mapping daily puppy sightings in a city. The data changes regularly, we need to show that certain streets have more puppy traffic than others.
Similar to the ones pictured here
https://blog.mapbox.com/spotangels-mobile-parking-maps-30db4b10aee7
And here
https://www.trulia.com/local/san-francisco-ca/type:traffic_volume_live
To do this, I would like to get a unique ID for each street block.
Something like this:
Question: How can I tell when a user entered a unique street? How can I get a unique street ID?
Related side question: If it's not possible in google maps, links to doing it in OpenStreetMap or Mapbox would be appreciated.
Places I've looked
How to get an use an unique identifier for each street in google maps api
Issue: No answer
Highlighting whole street with some maps API
Issue: Info from 2010
Google Maps: Get coordinates of a street block
Issue: No answer
Get street graph for a game using Google Maps API
Issue: Info from 2012
Map Highlight Odd/Even Side of Street
Issue: Unanswered
Display traffic data with maps
Issue: Unanswered
How to get only street/road coordinates via reverse geocoding (Google Maps API)
Streets in a radius
How to get all roads around a given location in OpenStreetMap?
Partial solution OSM
This should be doable with OSM data.
Retrieve the streets around you (e.g. using Overpass API and the around query). Determine the way you are currently driving on, then split it at each intersection node. Now you have street segments similar to your second image. The start and end node ID of each segment could be used as (temporary¹) identifier.
¹ temporary, because IDs in OSM can change eventually.

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.
You could possibly use the Google Maps API StreetViewService to get the street location you need.
Google Maps API - Directly Accessing Street View Data
Get the latLng location using the Geocoder
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);
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.
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.
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.
If you geocode the addresses off line, if you don't like the values that are returned by the geocoder, you can fix them.
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

Highlight street on any of type of maps

The problem I have is that I would like to highlight the whole street from beginning to the end. For example if I enter Av. Montaigne, Paris, France in Google Maps, I want the whole street to be highlighted.
It seems that Google Maps does not support this option and I would have to implement algorithm to mark the street by using polylines. However, I am not sure if there is a somewhat easy way to get information about how the street looks like, because the street could be curved so it is a problem.
Is it possible to get information that would be simple to use to highlight the street from beginning to end by just passing street name to API? The maps that I would use do not have to be Google maps, they can be Yahoo, Bing on OpenStreetMap.
The goal is actually something like this:
As far as I know, none of the common web map APIs offer this facility. Two possible approaches come to mind, although neither one is straightforward or reliable:
a.) Download from OpenStreetMap a local set of all the road data that you want to be able to highlight in your application. Then, when your user enters the street name they are searching for, search the OSM data and construct a polyline from the relevant coordinate points and plot it on the map. The problem with this approach is that it requires you to host and maintain a complete set of road data, and also implement the appropriate parsing algorithm to deal with misspellings of street names etc. You may often find that road names as they appear on Google Maps will be spelled differently than they are in OSM, for example.
b.) Use a routing service to calculate a route from one end of the street to the other, and then plot a polyline that follows the points of the route. e.g. Using the Bing Maps Routes API (http://msdn.microsoft.com/en-us/library/ff701717.aspx), you could plot a route between the two intersections at either end of the road in question - e.g. "Av. Montaigne & Rond-point des Champs-Élysées" to "Av. Montaigne & Place de L'Alma". You could then plot a polyline from the route points as follows:
There are two problems with this approach: first, you need to know the names of the roads with which the street intersects at either end (or some other way of identifying the ends of the street in question), and secondly, the route chosen between those two intersections may not actually follow the street itself (for example, if the street is one-way and you try to calculate a route in the other direction).

Find neighbors delimitations with google maps or google api

I need to find points that define delimitations of neighbors from Chicago.
My question is: How can I find a list with latitudes/longitudes of all the points that delimit neighbors. For example:
Gold Coast from Chicago is a polygon with 6 points as seen on google map: http://maps.google.com/maps/ms?ie=UTF8&t=m&vpsrc=6&source=embed&oe=UTF8&msa=0&msid=206241844247425110008.0004b43f0262868b8037f
What is the best way to extract this points so I can draw poly-lines over google map with google API for specific neighbors?
Edited:
So with addresses, which you already have, you can create a Maps API site:
http://code.google.com/apis/maps/
and use the Geocoding API to get the latitude and longitude of each of the addresses.
Added: Seems based on your comment that you're looking for neighborhood boundary data. Google Maps doesn't provide that data. There are different venders that do, one I have heard of is the Zillow Neighborhood API. I have never used it so I don't know much about it.

Google Maps API Driving Directions

I use Google Maps API and I have a map with 20 points on it.
Can I find an API call to give me driving directions and draw lines between them?
Yes, it can be done. The Google Maps API Documentation describes how to this very accurately:
"You can add the ability to calculate directions (using a variety of methods of transportation) by using the GDirections object. The GDirections object requests and receives direction results using either query strings (e.g. "New York, NY to Chicago, IL") or textual lat/lons.
The GDirections object also supports multi-part directions using a series of waypoints. Directions may be displayed as either a polyline drawing the route on a map, as a series of textual description within a <div> element (e.g. "Turn right onto the Williamsburg Bridge ramp") or both."
Unfortunately driving directions are not yet available for all countries. You may want to check the following spreadsheet to see if driving directions are available for a particular location:
Google Code - Map Coverage Filtered