Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highlight sections of streets, based on address

I'm wondering if the Google Static Maps API can be used to do the following. Given a data set of ~100 addresses all located on 5 to 7 different blocks in the same neighborhood, I want to generate a map in which the span of each block that falls within the bounds of the lowest and highest address on that block is highlighted. So for example if on Street A, the lowest included address is 1100 and the highest is 1600, the map should highlight the stretch of Street A that stretches from 1100 to 1600.

like image 838
Ben Davidow Avatar asked Oct 02 '22 08:10

Ben Davidow


1 Answers

Using paths should help you with this, here's an example API call:

http://maps.googleapis.com/maps/api/staticmap?size=512x512&path=color:0x00000000|weight:5|fillcolor:0xFFFF0066|8th+Avenue+%26+34th+St,New+York,NY|8th+Avenue+%26+42nd+St,New+York,NY|Park+Ave+%26+42nd+St,New+York,NY,NY|Park+Ave+%26+34th+St,New+York,NY,NY&path=color:0x00000000|weight:5|fillcolor:0xFF003366|6th+Ave+%26+W+45th+St,NY|5th+Ave+%26+W+45th+St,NY|5th+Ave+%26+W+32nd+St,NY|6th+Ave+%26+W+45th+St,NY&sensor=false

So all you have to do is pass in a list of addresses (you would have to pass in those with matching street names yourself) and you can have a highlighted block.

To keep the shape more regular you may want to use Geocoding to get latitudes and longitudes, work out the lower left and right corner of the best-fit rectangle and plot a path around it's four corners instead.

API doc here: https://developers.google.com/maps/documentation/staticmaps/?csw=1#ImplicitPositioning

You can specify multiple paths to cover all of your blocks, as explained here : https://groups.google.com/forum/#!topic/google-maps-api/WAb556SoApw

like image 106
sturrockad Avatar answered Oct 05 '22 10:10

sturrockad