Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps API v3 Highlight Country Border without using Polygons

I need to highlight the border of a country - let's say Switzerland. I achieved it with already with FusionTablesLayer like:

        var layer = new google.maps.FusionTablesLayer({
                    query: {
                        select: 'geometry',
                        from: '1N2LBk4JHwWpOY4d9fobIn27lfnZ5MDy-NoqqRpk',
                        where: "ISO_2DIGIT IN ('CH')"
                    },
                    styles: [
                        {
                            polygonOptions: {
                                strokeColor: "#FF0000",
                                fillOpacity: "0"
                            }
                        }
                    ]
                });

                layer.setMap(map);

The problem hereby is, that the drawn border is too straight

Screenshot

Is there any possibility to use some kind of search request, because if I go to Google Maps and search for Switzerland the country borders are highlighted in a light pink. This would already fullfil my requirements. See Maps

Thanks in advance

like image 862
Baby Jesus Avatar asked Mar 10 '15 13:03

Baby Jesus


People also ask

How do I highlight a country border on Google Maps?

To achieve this, you will basically need to look for the coordinates of the state or country on GADM. Once you have them, draw a shape on the Google Maps with the Polygon object providing an array with all the coordinates that play basically as borders of the place that you want to highlight.


1 Answers

As I said in my comment, this is not available through the API (at least at the time we speak).

You can do 2 things though:

  1. check out this answer where I give a complete solution on how to overlay polygons as country boundaries and provide a complete world data set.

  2. Subscribe to this feature request that is exactly what you are looking for.

Hope this helps!

Note: this answer is still valid in 06.2021

like image 158
MrUpsidown Avatar answered Oct 19 '22 23:10

MrUpsidown