Shading of city and country in Google Maps - javascript

when I am searching any city or state or country in google map then I want the shading of that place as shown in figure.
can any one tell me how to do it ?

You can achieve this through KML layer for google maps. You can use the JS Bin link to achieve what you want. Currently I have implemented it only for the state level but you can also do it for country. The KML I used dont provide the data for the city level.

Related

Drawing region on google maps

If I search a query in google maps for example "carlton victoria australia" then it will give me a map of the region with the border around that area.
My questions are:
Is there a way to get list of all regions from the google map api for
certain province or country?
Can I combine the region information for example, change the color and also add some infowindow on top of the region?
What kind of level of the region that I can get from the api (district, subdistrict, village)?
Currently Google Maps JavaScript API doesn't expose any boundaries of geographic features. There is very old feature request in the public issue tracker to add this functionality, however it looks like Google didn't set high priority on this:
https://issuetracker.google.com/issues/35816953
Feel free to star the public feature request to express your interest and subscribe to further updates from Google.
You can get polygons from other sources and add them to Google maps as additional layers.
The nice workaround to get polygons in GeoJSON format from OpenStreetMap is described in the following answer:
https://stackoverflow.com/a/40172098/5140781
So, if you download the GeoJSON you will be able to add it to map using the data layer and its loadGeoJson() method:
https://developers.google.com/maps/documentation/javascript/datalayer#load_geojson
You can style colors of GeoJSON objects and create info windows. Just read the aforementioned documentation.
I hope this helps!

how to highlight a state in google maps on click any area in the state of a country

I am willing to highlight a state in the Google maps when user click on any area in the particular state. Supprose if I click on any area in the Washington sate. Then the Washington should be highlighted. Can you help me if any api or js is available to do like that.
There is no automatic API for this. You are going to have to draw a polygon either dynamically when the user clicks, or pre-draw all the U.S. State polygons in advance and hidden, then dynamically make the proper one visible when the user clicks.
As for making polygons in the shape of at least U.S. states, several persons have posted pre-defined polygon lists. One is here in StackOverflow: Geographical boundaries of states/provinces -> Google Maps Polygon
However, if you are looking at world-wide regions, states, and provinces, I doubt you will find pre-defined lists of them all. You may well have to create your own polygons by manually drawing on a Google Map or Google Earth, then export the polygon's lat/lng waypoints.
recently I am creating some relative, the tests I made was based on OpenStreetMap Nominatim (https://wiki.openstreetmap.org/wiki/Nominatim), is something like:
Click on map get Lat, Lng
Search by reverse Geocode, get state (or city)
Use Nominatim API to get a polygon_text (I use the geo WKT format), parse it
Draw the polygon or polygons (if multiplygon) with Google Maps API
Hope it could make some ideas come.

Country shapes for google maps

I'm doing few experiments using Google Maps and now I was taking a look to the circles.
My idea is to create a circle for each country in Europe and load the markers inside only when someone click on the circle.
I did it and works fine.
Now what I'd like to do is to create a shape of the countries and replace each circle.
I was looking at the polygons and it seems to be what I'm looking for but creating a good shape for each country takes a planty of time...
There is a Google Maps service that highlight the countries that you need? (Not Google Charts, I already took a look on it)
Or Exist something already builded to import easily with Javascript?
The boundaries of the world countries are available in the Natural Earth data set and in a public FusionTable.
Here is an example using that data to display French provinces

Which one to use - Kml or Google Map Api

I want to show locations on google map based on the user search criteria i.e; if a user selects London, then all records from London should be displayed and if user enters his postcode then it should show the result within 25 miles of his postcode on the google map(All data will be coming from database php/mysql).
Now the question is What should I use? KML or google map api V3, As i want to give option to user to see brief info about the location, when he will mousehover that marker, and onClick of that marker I want to show the image of location and review count, and distance(calculated dynamically based on his postcode.), I also want to ceate custom markers. I have done some work on api V3 previously but wanted to know about KML. Does it supports my need? As according to my understanding KML is just a static file and can't give such dynamics.If so, can you please provide any sample and how to do that.
Thanks
Your understanding is correct, KML are just static files. You should be able to complete your requirements using combination of google maps api v3 methods like geocode, computeDistance etc.

How to highlight a region on Google Maps

How can I highlight/cover a region or multiple regions with different colors (for example 3 US states), using google maps polygon arrays?
I found a tuto on google code about how to draw a polygon but it's not giving detailed information.
Thank you for your help.
This documentation on Google is about as straight forward as you can get.
http://code.google.com/apis/maps/documentation/javascript/overlays.html
View the source of this page. Copy and paste the code into your own page and start from there.
http://code.google.com/apis/maps/documentation/javascript/examples/polygon-simple.html
In the example above you simply need to make more than one instance of bermudaTriangle and name it something else and add it to the map.

Categories