Extracting Google Map routes as shape - google-maps

We have very simple example of transition route in Web Google Map. Consider following example link. Or image, below.
.
My question is, how to get this shape of the route with some Map API(maybe not Google)? So I'm trying to make script, where I can insert a lot of points of the destination, and the output should be the shape of the transition routes. Even I can make shape with OpenCV, all what I need, it's just thumbnail of such route.
What I have tried so far? It's using Google Map Static API to create thumbnail. However, from the documentation, it's not possible to create such routes representation. By using path field in Static API with same destination points (provided in link above), we would have just connection lines. Example below and link to the Map Request.
What about if you put your points in the appropriate order? Let me explain, why order won't help in this case. Check the another example here. Or first image below. Now, lets take those points to the Static Map API. And you will have second image below. Or this link to API Request. So it's not about order, but behavior (which is obviously, is very different applications).

Your question is now a bit too broad and so will be my answer, but I'll summarize here what you could do.
Request your Directions with the JS API or the Directions API.
Use Waypoints in your request to specify each point. Warning: limitations apply (23 waypoints + origin & destination).
In your Directions response, you can use either the overview_path or the overview_polyline to draw that same route on the Maps Static API. Note that both are simplified paths (smoothed) that are less precise than the exact Polyline you get from the API. Maybe that is enough for your use case. Read more here.
Alternatively, if you need the exact Polyline coordinates, you will have to extract it from each DirectionsStep returned by the API.
Once you have your path points (or encoded Polyline), you can request your Maps Static API path (also see about encoded Polylines at the bottom of that page).
Hope this helps.

Related

how to get google maps route by sending the two latitudes and longitudes

Basically what I want is to use a webView to show google map but an URL wish I could send both the position of origin and destination so that when the page is loaded the route is displayed.
I have a list of positions of different branches and would like to do is to select a branch is displayed on the map the shortest route from the position where the device is located and the selected branch.
There is an option that is the Google Maps URL Scheme, but not how it works.
https://developers.google.com/maps/documentation/ios/urlscheme
You have to use Google Directions API to calculate the route. If you are showing the map using Google Maps JavaScript API you can use Direction Service that is included in the Map itself.
I found a solution that turned me perfect for what I needed and use a webView and link to google maps route with two positions as follows:
https://www.google.cl/maps/?saddr=origin_latitude,origin_longitude&daddr=destination_latitude,destination_longitude&directionsmode=transit

URL to dynamic Google Map with path

I want to build a URL to a dynamic map (i.e., to the normal Google Maps interface where you can pan and zoom, rather than an image of a static map) that has a path drawn on it from lat-long coordinates.
Similar questions have been asked with answers that won't solve my problem:
How to obtain a dynamic map from a static map URL? : This guy wanted to add some markers on the map (lines between them would make a path like I want), and was told it was not possible with URL parameters.
How to obtain a dynamic map from a static map URL? : Yes, this guy asked the same question. He was told to change the URL just slightly, but if you follow the URL to the dynamic map, you can see it does not draw what is seen in the static map (e.g., many of the parameters are ignored and stripped).
For KML output, how can I add waypoints between source and destination addresses in a Google Maps URL? : I understand I can ask for driving directions with saddr, daddr, and +to:, but I just want a poly-line path, not driving directions.
I've seen many links to http://mapki.com/wiki/Google_Map_Parameters documenting the URL parameters, but that site has since disappeared, and no other documentation (even the official one) seems to come close to this guy's tedious work.
So is it just not possible? Are driving directions the best I can do?
Thank you for your consideration.
The best you can do you've already found here: http://www.seomoz.org/ugc/everything-you-never-wanted-to-know-about-google-maps-parameters
Create a KML which contains the desired features(markers, polylines,markers etc.)and pass the URL of the KML-file as q-parameter to google-maps.
The KML-file may be created on the fly, so you may pass details for the features to your script that creates the KML.

Max url length with Google Maps static image

I need to create a static image of google map with several markers, and each marker has a custom icon.
In the Api DOC there is the note: Static Map URLs are restricted to 2048 characters in size. In practice, you will probably not have need for URLs longer than this, unless you produce complicated maps with a high number of markers and paths.
The url is very long.... There is the position for each marker and the URL for the custom icon for each one.
I've already tried with POST request ma it is not supported.
There is another way to create a static map image without max length limitation?
A possible way might be this, but i don't know if is it possible: I've create my custom map using the function in GMaps, and i have added all the markers i need.
There is a way to access in static way to this particular map? so in the url i have to give only the center of the map and other parameters (zoom, ...), but all the markers are already positioned.
Or... another idea... Can i submit the URL of a KML with all markers positioned instead each single marker position+icon url?
FYI, Google recently updated the limit to 8192.
Have you tried using a URL shortener for the icon urls? I believe the static map API will respect services that make URLs shorter... might save you a few characters.
You might wanna check out toopola´s API to help working with Google Static Maps, I am about to make my own attempt.
Another idea
find map area that contains all the markers
divide the map area into rectangular pieces (4 pieces for example)
create image url for each part, but include in url only markers and icons visible on map
show images
Мethod of division depends on the markers position.
Yes, you can definitely do this with the Javascript API.
I have built a few applications using that API. It can be a little tricky to get your head around, but it is pretty good. For what you want to do, it would not be too difficult. If the user has to be able to interact with the map and add pins and such, it starts to get a little more complicated because you have to capture clicks and such.
Does the map its self need to be available as a URL, or does it just need to be embedded on some page and that URL can be used?
The Javascript API will work best if you can embed the map into an existing webpage.

What is a good API to use to determine the address of a place based on its name?

I need to get the specific address (or lat/long coordinates) of a place based on that place's name.
Specifically, I need to determine the location of supermarkets in a given area so that I can use those locations as 'markers' in my implementation of google maps static maps api.
Using the following, I can if you input a specific location in the area that currently says "INSERT_LOCATION_HERE", then you will get a google map of the specified area with markers at the locations.:
http://maps.google.com/maps/api/staticmap?center=Ithaca,%20NY&size=512x512&maptype=roadmap&markers=color:blue|label:S|INSERT_LOCATION_HERE&sensor=false
For example (the marker indicates the local Wegmans store based on its address:
http://maps.google.com/maps/api/staticmap?center=Ithaca,%20NY&size=512x512&maptype=roadmap&markers=color:blue|label:S|500%20So.%20Meadow%20Street&sensor=false
If anyone knows how to do this without using google maps places api, that would be extremely helpful!
If you want to get the name as a string intead of an image, you can do it with a little help for Google. That'll match nicely with the static map that you're using.
Let's say you want to search for "Den Haag"...
Construct a URL like this, and parse the result:
http://maps.google.com/maps/geo?q=den%20haag
You can also specify the output format:
http://maps.google.com/maps/geo?q=den%20haag&output=xml
http://maps.google.com/maps/geo?q=den%20haag&output=csv
http://maps.google.com/maps/geo?q=den%20haag&output=json
You can also provide coordinates instead of a name, and get a full name+coordinates in return:
http://maps.google.com/maps/geo?q=52.0467315,4.3796239&output=json
For some reason the links don't work when you click them from this page. I guess google doesn't accept a referrer in the request, so just copy and paste the links... That works.

google maps: find out coordinates

i'm parsing some html data which has google maps embedded (displaying just one certain point) and i was wondering:
how can i find out the exact geographic coordinates of that point?
thx
I will look into this further but if you are able to see the Google Maps representation, you can type this into your browser and it will pinpoint the exact center location:
javascript:void(prompt('',gApplication.getMap().getCenter()));
Very useful if you want to get quick lat/long values. Is this the kind of info you need?
Parsing HTML files and want to find what point map is displaying?
This is likely not be possible (correct me if I am wrong). The map is a JavaScript object that only exists inside a browser - it is only text code in the html file. Map variables and data only exist inside the JavaScript engine running inside the browser, their dynamic variable state cannot be stored in a file ahead of time.
If the site is displaying a static map image then we have a different story. Just parse the URL to google static maps requesting the map image.
i found out that the actual coordinates were stored in the html :)
Have you tried the LatLng Marker lab in google map?