If one searches for a city on Google Maps, for example Berlin, the municipal boundaries of Berlin (gray dashed line with pink thick line inside) are shown.
Is it possible to make the same with Google Maps API?
I think you want to put an outline on the map that defines an area, in your case the municipal area of Berlin.
I know in the United States there is Census data that has the longitude and latitudes of all of the counties that are available for download for free. I am not sure if Germany has something similar however a Google search for "long lat coordinates outline Berlin municipal" reveals lots of results.
So what do you do with the coordinates after you find them - Google Maps API allows you put Polygons on the map based on geo-coordinates.
I use the Google Encoded Polylines part of the Geometry library to store my polygons and then redisplay them when a specific state is being displayed.
Example
var map = new google.maps.Map(document.getElementById("googlemap"), myOptions);
var encodedpoints = "<encoded points string>";
var polyOptions = {
"strokeColor": '#000000',
"strokeOpacity": 1,
"strokeWeight": 1,
"fillColor": "#000000",
"fillOpacity": 0.5
};
polyOptions.path = google.maps.geometry.encoding.decodePath(encodedpoints)
var mypolygon = new google.maps.Polygon(polyOptions);
mypolygon.setMap(map);
This example will put a polygon on the map that has a black line border and 50% opacity black fill. You can change the options to whatever you want.
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