早就听说google map的api已经公开了但一直没时间看,今天看了两篇这方面的文章,觉得不错,理解了一些 Code:
//correct the latitude to go from 0 (north) to 180 (south), // instead of 90(north) to -90(south) latitude=90-latitude; //correct the longitude to go from 0 to 360 longitude=180+longitude; //find tile size from zoom level double latTileSize=180/(pow(2,(17-zoom))); double longTileSize=360/(pow(2,(17-zoom))); //find the tile coordinates int tilex=(int)(longitude/longTileSize); int tiley=(int)(latitude/latTileSize);
Code:
//initialise the variables; double xmin=-180; double xmax=180; double ymin=-90; double ymax=90; double xmid=0; double ymid=0; string location="t"; //google use a latitude divided by 2; double halflat = latitude / 2; for (int i = 0; i < zoom; i++) { xmoy = (xmax + xmin) / 2; ymoy = (ymax + ymin) / 2; if (halflat > ymoy) //upper part (q or r) { ymin = ymoy; if (longitude < xmoy) { /*q*/ location+= "q"; xmax = xmoy; } else {/*r*/ location+= "r"; xmin = xmoy; } } else //lower part (t or s) { ymax = ymoy; if (longitude < xmoy) { /*t*/ location+= "t"; xmax = xmoy; } else {/*s*/ location+= "s"; xmin = xmoy; } } } //here, the location should contains the string corresponding to the tile...
Code:
/**<summary>Get the vertical tile number from a latitude using Mercator projection formula</summary>*/ private int getMercatorLatitude(double lati) { double maxlat = Math.PI; double lat = lati; if (lat > 90) lat = lat - 180; if (lat < -90) lat = lat + 180; // conversion degre=>radians double phi = Math.PI * lat / 180; double res; //double temp = Math.Tan(Math.PI / 4 - phi / 2); //res = Math.Log(temp); res = 0.5 * Math.Log((1 + Math.Sin(phi)) / (1 - Math.Sin(phi))); double maxTileY = Math.Pow(2, zoom); int result = (int)(((1 - res / maxlat) / 2) * (maxTileY)); return (result); }
Quote:
Google Error We're sorry... ... but your query looks similar to automated requests from a computer virus or spyware application. To protect our users, we can't process your request right now. We'll restore your access as quickly as possible, so try again soon. In the meantime, if you suspect that your computer or network has been infected, you might want to run a virus checker or spyware remover to make sure that your systems are free of viruses and other spurious software. We apologize for the inconvenience, and hope we'll see you again on Google. To avoid being blacklisted, developers should use a caching mechanism if possible...
附件:/Files/dotnetdoor/GoogleMapCs.rar Code:
http://maps.google.com/maps?output=kml&q=我的街道名称
Code:
<?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://earth.google.com/kml/2.0"> <Placemark> <name>New York, NY</name> <address>New York, NY</address> <styleUrl>root://styleMaps#default+nicon=0x304+hicon=0x314</styleUrl> <Point> <coordinates>-74.007130,40.714490,0</coordinates> </Point> <LookAt> <longitude>-74.007130</longitude> <latitude>40.714490</latitude> <range>64586.917969</range> </LookAt> </Placemark> </kml>
Code:
<?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://earth.google.com/kml/2.0"> <Folder> <name>Did you mean:</name> <open></open> <Placemark> <name>Paris, Lamar, Texas, United States</name> <address>Paris, Lamar, Texas, United States</address> <styleUrl>root://styleMaps#default+nicon=0x304+hicon=0x314</styleUrl> </Placemark> <Placemark> <name>Paris, Henry, Tennessee, United States</name> <address>Paris, Henry, Tennessee, United States</address> <styleUrl>root://styleMaps#default+nicon=0x304+hicon=0x314</styleUrl> </Placemark> <Placemark> <name>Paris, Edgar, Illinois, United States</name> <address>Paris, Edgar, Illinois, United States</address> <styleUrl>root://styleMaps#default+nicon=0x304+hicon=0x314</styleUrl> </Placemark> <Placemark> <name>Paris, Bourbon, Kentucky, United States</name> <address>Paris, Bourbon, Kentucky, United States</address> <styleUrl>root://styleMaps#default+nicon=0x304+hicon=0x314</styleUrl> </Placemark> <Placemark> <name>Paris, Logan, Arkansas, United States</name> <address>Paris, Logan, Arkansas, United States</address> <styleUrl>root://styleMaps#default+nicon=0x304+hicon=0x314</styleUrl> </Placemark> <Placemark> <name>Paris, Monroe, Missouri, United States</name> <address>Paris, Monroe, Missouri, United States</address> <styleUrl>root://styleMaps#default+nicon=0x304+hicon=0x314</styleUrl> </Placemark> <Placemark> <name>Paris, Mecosta, Michigan, United States</name> <address>Paris, Mecosta, Michigan, United States</address> <styleUrl>root://styleMaps#default+nicon=0x304+hicon=0x314</styleUrl> </Placemark> <Placemark> <name>Paris, Bear Lake, Idaho, United States</name> <address>Paris, Bear Lake, Idaho, United States</address> <styleUrl>root://styleMaps#default+nicon=0x304+hicon=0x314</styleUrl> </Placemark> <Placemark> <name>Paris, Stark, Ohio, United States</name> <address>Paris, Stark, Ohio, United States</address> <styleUrl>root://styleMaps#default+nicon=0x304+hicon=0x314</styleUrl> </Placemark> <Placemark> <name>Paris, Lafayette, Mississippi, United States</name> <address>Paris, Lafayette, Mississippi, United States</address> <styleUrl>root://styleMaps#default+nicon=0x304+hicon=0x314</styleUrl> </Placemark> </Folder> </kml>
分类: GoogleMap |
|
来自: 昵称QAb6ICvc > 《gis应用》