Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var geocoder;
- var prevHover;
- var curCountry;
- var created = false;
- var worldGeometry;
- function highlightCountry(country) {
- var text = "ISO_2DIGIT IN ('" + String(curCountry) + "')";
- worldGeometry.setOptions({
- query: {
- select: 'geometry',
- from: '1N2LBk4JHwWpOY4d9fobIn27lfnZ5MDy-NoqqRpk',
- where: text
- }
- })
- }
- function getCountry(latLng) {
- geocoder.geocode({ 'latLng': latLng },
- function (results, status) {
- if (status == google.maps.GeocoderStatus.OK) {
- if (results[0]) {
- for (var i = 0; i < results[0].address_components.length; i++) {
- if (results[0].address_components[i].types[0] == "country") {
- curCountry = results[0].address_components[i].short_name;
- }
- }
- }
- else {
- //didn't find anything
- }
- }
- }
- );
- }
- google.maps.event.addListener(map, 'click', function (event) {
- getCountry(event.latLng);
- });
- google.maps.event.addListener(map, 'mousemove', function (event) {
- getCountry(event.latLng);
- highlightCountry(curCountry);
- });
- google.maps.event.addListenerOnce(map, 'idle', function () {
- getCountry(map.getCenter());
- var center = "ISO_2DIGIT IN ('" + curCountry + "')";
- worldGeometry = new google.maps.FusionTablesLayer({
- query: {
- select: 'geometry',
- from: '1N2LBk4JHwWpOY4d9fobIn27lfnZ5MDy-NoqqRpk',
- where: center
- },
- map: map,
- suppressInfoWindows: true
- });
- google.maps.event.addListener(worldGeometry, 'click', function (event) {
- getCountry(event.latLng);
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement