Google Maps - get the border of polygons of zones / neighborhood

I want to do a simple search in the Google Maps API v3 and get a map with a colored polygon, as shown in the image below:

Search: pinheiros, sao paulo

enter image description here

+7
source share
3 answers

I got it using WikiMapia .

Steps:

enter image description here

  • Find the desired location.
  • Right-click on the neighborhood and select Edit Poly . enter image description here
  • In the developer tools, click Network and filter getPolygon . enter image description here
  • Copy the server response that looks like this: enter image description here

  • And go to the Console tab to execute the function: Wikimapia.Parser.Itiles.prototype.decodePolygon("Copyed text here");

  • Press enter to execute after that the console will return an object with dots (the path to Poly).

I am using JSON.stringify to convert an object to JSON.

Example:

 JSON.stringify(Wikimapia.Parser.Itiles.prototype.decodePolygon("-619402099;-109032887;02fe8953fffe5a000ae5fe379a000fedffd250000e40ffd6050007f7ffeff2001925ffd59b001f6fffdc310012dcffed10003b82ffd9b9005514ffc4520053d2ffc807000c92fff82dfffde7000e670005070012ef0009390021bf000572001358fffc3a001a57fffa210013c1ffff940036530008610022fc000284004732fff5f0001fb1fff2960013c1fff80800594efffde7002c72000f16004b5000204600416f0013b2002292")) 

The above code will return this JSON (indent 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 regexr.com/3c5m2 regex to enable JSON in WKT. I do not copy all JSON only objects in the "points" array in Regex. In RegExr, copy the replaced text and paste into POLYGON((pastehere)) .

Important! After applying the regular expression, you need to repeat the first point at the last point.

-61.956523060798645 -10.877613428213532 , - +61.95640504360199 -10.877718788854143, -61.956791281700134 -10.878393096072424, -61.95735991001129 -10.87805594265392, -6.638938938938938938938938938938938938838938938938938968690738690738.

Then you will 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)) 

This can be inserted into a database that supports WKT (e.g. MySQL).

WikiMapia has an API , then this whole process can be automatic, but it works fine for me.

+7
source

Short answer: no, the Google Maps API does not provide this functionality.

One way to implement this is to find the spatial data (polygons) that you are involved in, load it into a database (which ideally supports spatial queries), and then query the database via AJAX to add the geometry of the object as KMLLayer to the map along with corresponding click.

+1
source

You can check this out at funda.nl . When you select an individual property, it also shows a Google map in which a polygon is drawn around the vicinity of the selected property.

0
source

All Articles