Country shapes for google maps - javascript

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

Related

Is there a way to make a web map with custom areas that display custom info at addresses?

I am trying to make a map for work with our prices for different areas. Basically I would like to be able to add areas to a map so that if I search an address depending what area it is in will tell me the various prices. Is this possible?
I have tried using google map API tutorials but can only add a coloured area that doesn't really do much
This is very possible. Store your areas as an array containing sets of coordinate pairs. Each area with its pricing. You can use Google My Maps to draw the boundaries using real-world GPS coordinates. You can export the polygon shapes you create to JSON data.
Use Google Maps API to lookup a street address and retrieve the GPS coordinates.
Use Point In Polygon class to check which polygon the GPS coordinate belongs in (if any) and assess the price.

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!

Shading of city and country in Google Maps

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.

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.

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