Reputation: 675
I would like to select county, or district like Google Maps do on http://maps.google.com/. I mean something like this:
Is it possible to do it by Google Maps API? Is it possible to select more districts?
Upvotes: 8
Views: 6001
Reputation: 850
I did it by using GEOJSON file.
My JS:
function initMap2() {
map = new google.maps.Map(document.getElementById("map"), {
zoom: 13,
mapId: "", // add map id here
center: {lat: 41.015137, lng: 28.979530},
//center: { lat: 20.773, lng: -156.01 },
});
map.data.loadGeoJson(
"https://raw.githubusercontent.com/ozanyerli/istanbul-districts-geojson/main/istanbul-districts.json"
);
map.data.setStyle({
fillColor: '#810FCB',
strokeWeight: 1,
fillOpacity: 0.5
});
}
and I get the JSON data for Istanbul by using the following JSON:
https://raw.githubusercontent.com/ozanyerli/istanbul-districts-geojson/main/istanbul-districts.json
Upvotes: 0
Reputation: 1552
Google has started highlighting search areas in pick color.
It's not available in the API.
(It may be available in the future. Features of Google Maps do migrate into the API, but Google don't make announcements in advance)
You would need to find the city boundaries and draw the line yourself, through overlays.
Upvotes: 0
Reputation: 18064
Refer to the Google Maps JavaScript API V3 and Google Maps Overview
You can try with statesobj.js for borders
Upvotes: 1