Staffan Estberg
Staffan Estberg

Reputation: 7025

Google Charts: Show only a certain country

I'm digging into Google Charts on the account of a new client, and was wondering if it's possible to show only a certain country using the Map API. I've managed to set up selected regions but I can't seem to find a way to exclude neighboring countries. Would appreciate any help or direction on this subject.

Example of what I'm referring to - http://raphaeljs.com/australia.html (Don't want to use this library however.)

Upvotes: 1

Views: 5388

Answers (2)

sonal agrawal
sonal agrawal

Reputation: 11

I have tried the google chart code with my web application. but this is not working for me. Peckage ['Map'] is working Using ['Geomap'] package nothing is showing on my page.
and using package ['map'] , i cat display only 1 country chart. Is there anything which i am missing.

<script type='text/javascript'>
            google.charts.load('current', {'packages': ['geomap']});
            google.charts.setOnLoadCallback(drawMap);
            function drawMap()
                    var data = google.visualization.arrayToDataTable([
                            ['City', 'Popularity'],
                            ['New York', 200],
                            ['Boston', 300],
                            ['Miami', 400],
                            ['Chicago', 500],
                            ['Los Angeles', 600],
                            ['Houston', 700]
                    ]);
                    var options = {};
            options['region'] = 'US';
            options['colors'] = [0xFF8747, 0xFFB581, 0xc06000]; //orange colors
            options['dataMode'] = 'markers';
            var container = document.getElementById('map_canvas');
            var geomap = new google.visualization.GeoMap(container);
            geomap.draw(data, options);
    };
</script>    
<div id="map_canvas" style="width: 900px; height: 500px;"></div> 

Upvotes: 0

Steffen Stenersen
Steffen Stenersen

Reputation: 375

It is possible to display only a certain country using the Google Charts API. The way to do it is to set the region in the options variable and use the options variable when you draw the map.

var options = {};
options['region'] = 'AU';
...
geomap.draw(data, options);

Check out the example provided in the API documentation: http://code.google.com/apis/chart/interactive/docs/gallery/geomap.html#markersexample

Upvotes: 4

Related Questions