I want to make a simple search on Google Maps API v3 and get as a result the map with a colored polygon like the picture below:
Search: pinheiros, sao paulo
Google Maps has added a feature where it will highlight in a pink color the borders of a city, postal code or other borders based on your search. To see it yourself, go to Google Maps and search for a city name or even a zip code. You will see a pinkish highlight around the border.
In Google Earth, create the polygon that you wish to bring into RockWorks. Or, locate the polygon that currently exists in your Saved Places listing. Right-click on the item, and choose Copy from the pop-up menu. Or, right-click on the item, and choose Save Place As to save the locations in a KMZ file.
Draw a path or polygonTo make a path or polygon into a 3D object, click Altitude. A "New Path" or "New Polygon" dialog will pop up. You may need to move it out of the way before moving on to the next step. To draw the line or shape you want, click a start point on the map and drag.
I got it by using WikiMapia data.
The steps are:
F12
or Ctrl+Shift+I
.Edit Poly
.
Network
and filter by getPolygon
.
Copy server response that looks like:
And go to Console
tab to execute the function: Wikimapia.Parser.Itiles.prototype.decodePolygon("Copyed text here");
I use JSON.stringify
to transform the object in JSON.
Example:
JSON.stringify(Wikimapia.Parser.Itiles.prototype.decodePolygon("-619402099;-109032887;02fe8953fffe5a000ae5fe379a000fedffd250000e40ffd6050007f7ffeff2001925ffd59b001f6fffdc310012dcffed10003b82ffd9b9005514ffc4520053d2ffc807000c92fff82dfffde7000e670005070012ef0009390021bf000572001358fffc3a001a57fffa210013c1ffff940036530008610022fc000284004732fff5f0001fb1fff2960013c1fff80800594efffde7002c72000f16004b5000204600416f0013b2002292"))
The code above will return this JSON (indentation in JsonFormatter):
{
"points":[
{
"lat":-10.9032887,
"lng":-61.9402099
},
{
"lat":-10.9032466,
"lng":-61.9306183
},
{
"lat":-10.8915629,
"lng":-61.9308972
},
{
"lat":-10.8903934,
"lng":-61.9313049
},
{
"lat":-10.8893188,
"lng":-61.9316697
},
{
"lat":-10.8889079,
"lng":-61.9318736
},
{
"lat":-10.8878227,
"lng":-61.9325173
},
{
"lat":-10.8869061,
"lng":-61.933322
},
{
"lat":-10.8864214,
"lng":-61.9338048
},
{
"lat":-10.8854416,
"lng":-61.9353282
},
{
"lat":-10.8839139,
"lng":-61.9375062
},
{
"lat":-10.8824811,
"lng":-61.939652
},
{
"lat":-10.8822809,
"lng":-61.9399738
},
{
"lat":-10.8826496,
"lng":-61.9399202
},
{
"lat":-10.8831343,
"lng":-61.9400489
},
{
"lat":-10.8839982,
"lng":-61.940285
},
{
"lat":-10.8844934,
"lng":-61.9404244
},
{
"lat":-10.8851677,
"lng":-61.9403279
},
{
"lat":-10.8856734,
"lng":-61.9401777
},
{
"lat":-10.8870641,
"lng":-61.940167
},
{
"lat":-10.8879597,
"lng":-61.9403815
},
{
"lat":-10.8897823,
"lng":-61.9404459
},
{
"lat":-10.8905936,
"lng":-61.9401884
},
{
"lat":-10.8910993,
"lng":-61.9398451
},
{
"lat":-10.8933855,
"lng":-61.9396412
},
{
"lat":-10.8945233,
"lng":-61.9395876
},
{
"lat":-10.8964513,
"lng":-61.9399738
},
{
"lat":-10.8981264,
"lng":-61.9408
},
{
"lat":-10.8990114,
"lng":-61.9413042
}
],
"bounds":{
"left":-61.9413042,
"bottom":-10.9032887,
"right":-61.9306183,
"top":-10.8822809,
"centerLatLng":null
}
}
Finally I use regex like this regexr.com/3c5m2 to turn JSON into WKT. I don't copy entire JSON only the objects in "points"
array in Regex. On RegExr I copy the replaced text and paste in POLYGON((pastehere))
.
Important! After apply the regex you need to repeat the first point in last point.
-61.956523060798645 -10.877613428213532,-61.95640504360199 -10.877718788854143,-61.956791281700134 -10.878393096072424,-61.95735991001129 -10.87805594265392,-61.95682346820831 -10.877339490373695,-61.956523060798645 -10.877613428213532
Then you get something like this:
POLYGON((-61.956523060798645 -10.877613428213532,-61.95640504360199 -10.877718788854143,-61.956791281700134 -10.878393096072424,-61.95735991001129 -10.87805594265392,-61.95682346820831 -10.877339490373695,-61.956523060798645 -10.877613428213532))
That can be inserted in database that supports WKT (like MySQL).
WikiMapia has an API then all of this process can be automatic, but this works fine for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With