views:

55

answers:

2

Hi all,

I would like to use a map API that allows me manipulating countries subregions like England and Scotland for instance (that are "provinces" of the United Kingdom, ISO-3166-1 code: GB).

All the APIs I've found so far only allow you to work on a ISO country basis (in which England and Scotland aren't accessible).

The Google geomap API documentation (link) indicates that one can use "England" as a country name, however I've tested it and it doesn't work.

Does anybody know an API I could use to achieve this?

Thanks.

+2  A: 

You need to specify the ISO 3166-2 country subdivision code. For England this is GB-ENG or for Scotland GB-SCT. A complete lsit of codes can be found at http://docs.equest.com/eQuestCountryAndStateCodes.xls An example would be:

<html>
<head>
<script type='text/javascript' src='http://www.google.com/jsapi'&gt;&lt;/script&gt;
<script type='text/javascript'>
google.load('visualization', '1', {'packages': ['geomap']});
google.setOnLoadCallback(drawMap);

function drawMap() {
  var data = new google.visualization.DataTable();
  data.addRows(2);
  data.addColumn('string', 'Country');
  data.addColumn('number', 'Popularity');
  data.setValue(0, 0, 'GB-ENG');
  data.setValue(0, 1, 200);
  data.setValue(1, 0, 'GB-SCT');
  data.setValue(1, 1, 100);

  var options = {};
  options['dataMode'] = 'regions';
  options['region'] = 'GB';

  var container = document.getElementById('map_canvas');
  var geomap = new google.visualization.GeoMap(container);
  geomap.draw(data, options);
};
</script>
</head>

<body>
  <div id='map_canvas'></div>
</body>

ladi
thx for the sample code.
A: 

http://en.wikipedia.org/wiki/ISO_3166-2:GB

This link provides the ISO codes for GB and allows you to access the sub regions such as Scotland and England.

DeliveryNinja