With the current version of GMDL its not possible to download maps of google maps. You only get a message: "Something not quite right with this page..."
I took a look in the source and found the problem. A FormatException is thrown in the Int32.Parse method. Google changed the format of their Urls.
Old:
http://mt1.google.com/mt?n=404&v=w2....m=12&s=Galileo
New:
http://mt2.google.com/mt?v=nq.83&hl=de&x=2&y=4&z=4&s=Ga
zoom= changed to z= and the n= parameter is missing.
In addition the source is horrible. Labels are used for string storage, names of UI elements and variables are often nonsense. But ok: It works. so far.
But there is a bug in the URL parse function of the Google Maps part. You are trying to get the URL Parameter values through an index-of algorithm. You search for an & after the x=, y=, zoom= strings. But its possible that there is no & after this parameters because of the ending url with an ".
There is a link in this format at the beginning:
http://maps.google.com/?ie=UTF8&ll=3...160156&z=4
I've written a new parser using regular expressions:
GMdl.cs -> GetNumbers() (Line: 402)
Code:
else // google
{
// Get all Links
StringCollection resultList = new StringCollection();
try
{
Regex regexObj = new Regex(@"((?#protocol)https?|ftp)://((?#domain)[-A-Z0-9.]+)((?#file)/[-A-Z0-9+&@#/%=~_|!:,.;]*)?((?#parameters)\?[-A-Z0-9+&@#/%=~_|!:,.;]*)?", RegexOptions.IgnoreCase);
Match matchResult = regexObj.Match(page);
while (matchResult.Success)
{
resultList.Add(matchResult.Value);
matchResult = matchResult.NextMatch();
}
}
catch (ArgumentException)
{
// Syntax error in the regular expression
}
// Iterate all images and search for minimum zoom
foreach (var s in resultList)
{
try
{
// Search for Minimum Zoom
string z = Regex.Match(s, "z=([0-9]+)", RegexOptions.IgnoreCase).Groups[1].Value;
int iz = Int32.Parse(z);
min_zoom = Math.Min(iz, min_zoom);
}
catch (ArgumentException)
{
// Syntax error in the regular expression
}
}
// Iterate all Images and search for min and max x and y for minimum zoom
foreach (var s in resultList)
{
try
{
// Get Zoom
string z = Regex.Match(s, "z=([0-9]+)", RegexOptions.IgnoreCase).Groups[1].Value;
int iz = Int32.Parse(z);
// Is Minimum Zoom?
if(min_zoom == iz)
{
// Get x and y
string x = Regex.Match(s, "x=([0-9]+)", RegexOptions.IgnoreCase).Groups[1].Value;
int ix = Int32.Parse(x);
string y = Regex.Match(s, "y=([0-9]+)", RegexOptions.IgnoreCase).Groups[1].Value;
int iy = Int32.Parse(y);
min_x = Math.Min(ix, min_x);
max_x = Math.Max(ix, max_x);
min_y = Math.Min(iy, min_y);
max_y = Math.Max(iy, max_y);
}
}
catch(ArgumentException)
{
// Syntax error in the regular expression
}
}
if (MapType() == "iFMnpe")
{
int cen_x = min_x + 1;
int cen_y = min_y + 1;
cen_x++;
cen_y++;
decimal[] Bcoord = LLXY.getLatLong(cen_x, cen_y, min_zoom); // center of map if compliant2x2
decimal minlat = Bcoord[1];
decimal maxlon = Bcoord[0];
mu.latC = System.Convert.ToDouble(minlat);
mu.lonC = System.Convert.ToDouble(maxlon);
}
}
Of course you need to change the method which creates the Map-URL for receiving the images.
mapUrl.cs -> GoogleMap() (Line:384)
Code:
public string GoogleMap(int zoom, int x, int y)
{
string s = "http://mt" + RandomGoogle() + ".google.com/mt?v=" + iMversion + "&x=" + x.ToString() + "&y=" + y.ToString() + "&z=" + zoom.ToString() + "&s=" + RandomGoogle2();
Debug.WriteLine(s);
return s;
}
But this does not solve the problem. Because their is a bug in the calculation of the x and y coordinates in addition with the zoom factor.
I would love to fix this problems and optimize the code. But I need the knowledge of the google maps backend (How the x and the y values are calculated) and how files are written, gps data is calculated,...
It would be great if you can fix this bug.
You should open a google code project where you offer this project. there is no official website where you get information about this project. You can contact me if you want help for this project.
Greets Daniel
Bookmarks