Tell me more ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have this JavaScript code. I want 2 buttons on the map. 1 to turn layer_2 'ON' and other to turn layer_1 'ON'. Once either button is clicked the other layer should turn off. Also layer_1 needs to be default and should show up when the map is opened. In no case the layers should overlap.

var map;
var layer_1;
var layer_2;
var tableid_1 = 3775630;
var tableid_2 = 4313734;
var queryUrlHead = 'http://www.google.com/fusiontables/api/query?sql=';
var queryUrlTail = '&jsonCallback=?';

function initialize(col_list, order_list) {
var latlng = new google.maps.LatLng(33.7071,-111.3024);

map = new google.maps.Map(document.getElementById('map_canvas'), {
    center: latlng,
    zoom: 7,
    mapTypeId: google.maps.MapTypeId.TERRAIN,
    mapTypeControl: true,
    mapTypeControlOptions: {
    style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR,
    position: google.maps.ControlPosition.TOP_LEFT
},
    scaleControl: true,
    scaleControlOptions: {
    position: google.maps.ControlPosition.BOTTOM_LEFT
},

});

var layer_2 = new google.maps.FusionTablesLayer(4313734);
layer_2.setMap(map);

var layer_1 = new google.maps.FusionTablesLayer(3775630);
layer_1.setMap(map);
layer_1.enableMapTips({
        select: "'Name'",
        from: tableid_1,
        geometryColumn: 'Location', 
        suppressMapTips: false, 
        delay: 50,
        tolerance: 5
});
    addListeners();

}

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.