Search code examples
google-mapsgeolocationgeocoding

Google maps - how to get building's polygon coordinates from address?


How to implement the following:

  1. User defines an address
  2. User defines a color
  3. Service searches for a corresponding building on the google map
  4. Service fills the found building on the map with the color

I know how to:

1.find lat/long of the address

2.draw the polygon

So, to do the task I need to get polygon coordinates of building from address. How to?


Solution

  • (1) Acquire image tile

    original

    (2) Segment buildings based on pixel color (here, 0xF2EEE6).

    parsed

    (3) Image cleanup (e.g. erosion then dilation) + algorithm to acquire pixel coordinates of polygon corners.

    (4) Mercator projection to acquire lat/long of pixel