- Static Map Images (covering the track at zoomed & top level))
- Direction steps and description.
Static map images can be downloaded from Google using there static map API. Direction steps and descriptions can only be downloaded via a AJAX API. Since I had only AJAX way of getting this data, I created a webpage which can do all necessary DOM operation using JavaScript. Once the DOM is populated I can easily grab the data from C# API (Web browser control + GetElementByID APIs).
Downloading the static Images from Google is not enough, you need to map Latitude and Longitude on the static map. Which is done like this
Downloading the static Images from Google is not enough, you need to map Latitude and Longitude on the static map. Which is done like this
public PixelPoint GetCordinateOnStaticImage(double latitude, double longitude,
double centerLat,
double centerLang,
int zoom,
double width,
double height)
{
long val = 1 << ((21 - zoom));
double target_y = LatToY(latitude);
double target_x = LongToX(longitude);
double delta_x = (((target_x - LongToX(centerLang))) / (val));
double delta_y =(((target_y - LatToY(centerLat)) )/ (val));
double marker_x = (width/2) + delta_x;
double marker_y = (height/2) + delta_y;
PixelPoint p = new PixelPoint(marker_x,marker_y);
return p;
}
Direction
Google returns the poly-line of the direction path. Some of the points on this polyline will be identified as step, step has direction description, e.g "at blah blah circle take left".
This project solve another problem of pulling the right direction description from the given location.
SourceCode
Complete source-code of this project is available on Google code here.
Demo
Here is a demo video.
No comments:
Post a Comment