37

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
  • 15,582
  • 10
  • 47
  • 64
  • 1
    Someone had a similar question (http://stackoverflow.com/questions/2956355/highlight-polygon-and-tint-rest-of-map-using-google-maps/2958856#2958856) a while back. If you have the coordinates for the border, you can invert a polygon using the method in my answer to that question. If you don't have the coordinates for the border, you can probably find them somewhere on the web, or draw the border yourself using google maps "My Places" and get the coordinates out. – Mark Dec 29 '11 at 17:21
  • Does this answer your question? [Google Maps API v3 Highlight Country Border without using Polygons](https://stackoverflow.com/questions/28964573/google-maps-api-v3-highlight-country-border-without-using-polygons) – MrUpsidown Jun 24 '22 at 12:51

6 Answers6

51

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

davetapley
  • 17,000
  • 12
  • 60
  • 86
9

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

mgibson
  • 6,103
  • 4
  • 34
  • 49
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.

Asmo Soinio
  • 1,182
  • 12
  • 12
1

14 years (!) after the original feature request, Google has enabled Data-driven styling.

One of the most commonly requested features you have asked for is access to the same boundaries and polygons used in Google Maps to build informative and engaging maps for your customers. Today, we are excited to announce the preview release of Data-driven styling for the Maps JavaScript API, which enables you to display and style Google boundaries.

Here is a demo and the official documentation.

MrUpsidown
  • 21,592
  • 15
  • 77
  • 131
0

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

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

Germany is already available

martin jakubik
  • 4,168
  • 5
  • 29
  • 42
defau1t
  • 10,593
  • 2
  • 35
  • 47
  • I need all the details which are containing in Google Maps. – Armin Dec 30 '11 at 19:50
  • 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 – defau1t Dec 30 '11 at 20:18
  • 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 (http://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! – Armin Dec 30 '11 at 20:48
  • 1
    Then from the google maps prespective, the best approach for you is to use google chart tools http://code.google.com/apis/chart/interactive/docs/gallery/geomap.html, if you wanyt to leverage google maps then you need to overlays and highlight the germany map, like what is here for usa map http://econym.org.uk/gmap/example_egroundoverlay.htm – defau1t Dec 30 '11 at 21:24
  • Sad, that there seems to be no fancier solution :( But thanks for your efforts! – Armin Dec 30 '11 at 21:30
  • right, there is no fancier solution than this. you might still explore raphael js or the plugin I mentioned. – defau1t Dec 30 '11 at 21:32
  • 1
    @defau1t thanks for fixing it - yesterday jvectormap.owl-hollow.net did not exist at all. – Olli Apr 08 '14 at 07:28
  • @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? – defau1t Apr 08 '14 at 10:02
  • @defau1t can you fix the link in the post? ...owl-hollow... does not respond. – martin jakubik Aug 29 '17 at 16:26
  • @martinjakubik: Here you go http://jvectormap.com/maps/countries/germany/ if you find any post as useful make sure you vote up the answer :) – defau1t Aug 30 '17 at 18:51
  • @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 jakubik Aug 31 '17 at 09:13
0

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

Armin
  • 15,582
  • 10
  • 47
  • 64