Highlight whole countries in Google Maps

66,668

Solution 1

I was able to do this using the public World Country Boundaries.kml Fusion Table.

You'll need to add it as a Fusion Table Layer to your map.


Firstly initialize a map zoomed out right out, centered so we can see most countries:

var map = new google.maps.Map(document.getElementById('map-canvas'), {
  center: new google.maps.LatLng(30,0),
  zoom: 2,
  mapTypeId: google.maps.MapTypeId.ROADMAP
});

Next add the FusionTablesLayer:

var world_geometry = new google.maps.FusionTablesLayer({
  query: {
    select: 'geometry',
    from: '1N2LBk4JHwWpOY4d9fobIn27lfnZ5MDy-NoqqRpk'
  },
  map: map,
  suppressInfoWindows: true
});

That looks like this:

all countries


With regard to:

Is there a possibility to fade out the other, not used countries?

If you look at the Fusion Table you'll see there are columns for Name and ISO_2DIGIT. We can filter on these by passing a where condition to the FusionTablesLayer, e.g:

  query: {
    select: 'geometry',
    from: '1N2LBk4JHwWpOY4d9fobIn27lfnZ5MDy-NoqqRpk',
    where: "ISO_2DIGIT IN ('US', 'GB', 'DE')"
  },

To give:

filter countries with where

Solution 2

For any one who ends up here in the future, this seems to now be handled very well by Google Charts, the latest implementation of the deprecated link above

https://developers.google.com/chart/interactive/docs/gallery/geochart

Solution 3

Old question, but: Google's deprecated Map Charts API looks like a better solution, if you do not need the map to be draggable:

https://developers.google.com/chart/image/docs/gallery/new_map_charts

Example: https://chart.googleapis.com/chart?cht=map:fixed=-60,0,80,-35&chs=600x350&chld=CA-BC|CN|IT|GR|US-UT&chdl=Vancouver|Beijing|Torino|Athens|Salt+Lake+City&chco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274&chtt=Last+Five+Olympic+Hosts&chm=f2010+Winter,000000,0,0,10|f2008+Summer,000000,0,1,10|f2008+Winter,000000,0,2,10,1,:-5:10|f2004+Summer,000000,0,3,10|f2004+Summer,000000,0,4,10

enter image description here

This api will continue to work at lest until April 2015: https://developers.google.com/chart/terms

Important: The Image Charts portion of Google Chart Tools has been officially deprecated as of April 20, 2012. It will continue to work as per our deprecation policy.

Solution 4

Currently (API version 3) there seems to exist no possibility to increase border-thickness for single countries.

Solution 5

If you just want a map of Germany why not use this:

http://jvectormap.com/maps/countries/germany/

Germany is already available

Share:
66,668
Armin
Author by

Armin

Freelancer from Cologne, Germany

Updated on November 24, 2020

Comments

  • Armin
    Armin over 3 years

    I have a general question about Google Maps. I want to use Google Maps just for germany, but of course the neighbor countries are shown as well. The border of germany is rarely visible.

    Is there a possibility to fade out the other, not used countries?

  • Armin
    Armin over 12 years
    I need all the details which are containing in Google Maps.
  • defau1t
    defau1t over 12 years
    can you please elaborate what is your exact requirement. No doubt google maps is always the answer, I am just wondering if your problem can be solved with other map type solution
  • Armin
    Armin over 12 years
    Okay, I have coded a vector based map solution for a customer, which calculates the position of dots by long and lat and creates clusters (goo.gl/LvfFN - the map on the left side) . The customer wants additionally a gmaps implentation. Do you want to ask him why? I suppose this is not part of my initial question!
  • defau1t
    defau1t over 12 years
    Then from the google maps prespective, the best approach for you is to use google chart tools code.google.com/apis/chart/interactive/docs/gallery/geomap.h‌​tml, if you wanyt to leverage google maps then you need to overlays and highlight the germany map, like what is here for usa map econym.org.uk/gmap/example_egroundoverlay.htm
  • Armin
    Armin over 12 years
    Sad, that there seems to be no fancier solution :( But thanks for your efforts!
  • defau1t
    defau1t over 12 years
    right, there is no fancier solution than this. you might still explore raphael js or the plugin I mentioned.
  • Jeroen K
    Jeroen K almost 11 years
    Even if you change the color, this is pretty ugly. Especially as the layer goes over the country names.
  • davetapley
    davetapley almost 11 years
    You make a valid point, I've created an issue here.
  • Olli
    Olli about 10 years
    @defau1t thanks for fixing it - yesterday jvectormap.owl-hollow.net did not exist at all.
  • defau1t
    defau1t about 10 years
    @Olli: that's true, the link was down but not 404. I saw someone down voted the post today so I was curious what could be the reason?
  • Haya Raed
    Haya Raed about 10 years
    Is it possible to choose the highlight colour?
  • davetapley
    davetapley about 10 years
    @HayaRaed yes, see Fusion Table Styles in the docs.
  • martin jakubik
    martin jakubik almost 7 years
    @defau1t can you fix the link in the post? ...owl-hollow... does not respond.
  • defau1t
    defau1t almost 7 years
    @martinjakubik: Here you go jvectormap.com/maps/countries/germany if you find any post as useful make sure you vote up the answer :)
  • martin jakubik
    martin jakubik almost 7 years
    @defau1t I meant why don't you Edit your post and fix it... but I did it myself. Otherwise your post is wrong and people have to read down the comments to find the right link.
  • Martin Zvarík
    Martin Zvarík over 5 years
    FYI: Fusion Tables are now deprecated and will be removed next month.
  • Cristian
    Cristian over 4 years
    is there a way to achieve this now since fusion tables are deprecated?
  • Cristian
    Cristian over 4 years
    is there a way to costumize the map and apply zooming and paning?