Home > front end >  Google Maps - Data driven styling - Countries missing from feature layer
Google Maps - Data driven styling - Countries missing from feature layer

Time:09-07

I'm creating a custom map to have specific countries coloured in. I'm using the new data driven styling. Most countries are fine, but there appear to be five countries in the world that I can't get to colour in: Russia, Ukraine, Agentina, Chile, India.

Note: End result will NOT have all countries coloured, only select ones and that selection includes Ukraine and India. During testing I found 3 other countries I couldn't access.

I've created a sample that shows all the countries coloured in, except the five above. I've output the feature.displayName from the feature layer loop and the missing five are never accessed to try and style, so the fact they are in my list of countries doesn't ever matter. I have looked through all the output countries from the loop to see if there were some alternative names or spelling for these countries.

Example code pen: https://codepen.io/gobananas/pen/vYjOJEZ

 const countries_all = ["Chile", "Russia", "Argentina", "India", "Ukraine"];


function initMap() {
  let featureLayer;
  let map;
  
  map = new google.maps.Map(document.getElementById('mapbox'), {
      center: { lat: 16.6310, lng: 66.76005 },
      zoom: 2,
      mapId: 'a8540ac9b4094555',
  });

  // Add a feature layer for localities.
  featureLayer = map.getFeatureLayer(google.maps.FeatureType.COUNTRY);

  featureLayer.style = (placeFeature) => {
      if (countries_all.includes(placeFeature.feature.displayName)) {
          return {fillColor: '#007DB3', fillOpacity: 0.8}
      }
  }
}

CodePudding user response:

The documentation includes the Google boundaries coverage viewer which explicitly states that for some countries, the country boundaries are unavailable.

Today, unavailable countries are:

  • Argentina
  • Azerbaijan
  • Chile
  • India
  • Russia
  • Ukraine

Disputed territories, such as Western Sahara, Crimea, Gaza Strip, etc. also appear with a different styling.

Data Driven Styling is still in BETA. While it is not clear from the documentation as to why some countries are not available, it clearly appears that they are all related to a territorial dispute.

  • Related