Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Your html file had significant errors in the javascript portions. You really should study up on same basic javascript and in particular using JS with the GMap API. </p> <p>You created 2 global map objects. You did not encapsulate all your map and layer creations within you initialize function(). All map and layer creation must be done within the initialize (on body load) function. You must set globals outside your initialize function, e.g. the map, all the layers, etc. Finally you were failing to call <code>layer.setMap(map)</code> on 2 of your KML layers.</p> <p>Despite all this I fixed your file, really just re-arranging things. This is just the section I had to fix. Moved everything into the initialize()</p> <pre><code> function showbuildings(buildingcheck) { if (buildingcheck.checked == true) { campusmap.setMap(map); } else { campusmap.setMap(null); } } function showphilpotts(philpottscheck) { if (philpottscheck.checked == true) { philpotts.setMap(map); } else { philpotts.setMap(null); } } function showbeartrail(beartrailcheck) { if (beartrailcheck.checked == true) { beartrail.setMap(map); } else { beartrail.setMap(null); } } var infoWindow = new google.maps.InfoWindow(); function openIW(FTevent) { // infoWindow.setContent(FTevent.infoWindowHtml); // infoWindow.setPosition(FTevent.latLng); infoWindow.setOptions( { content: FTevent.infoWindowHtml, position: FTevent.latLng, pixelOffset: FTevent.pixelOffset }); infoWindow.open(map); } // Globals //Begin map parameters var map; var layer_2; var layer_1; var tableid_1 = 2920040; // polygons var tableid_2 = 3189980; // houses var zoom = 12; var center = new google.maps.LatLng(43.652417455515476, -79.37926607055226); var campusmap; var philpotts; var beartrail; function initialize() { map = new google.maps.Map(document.getElementById('map_canvas'), { center: center, zoom: zoom, mapTypeId: google.maps.MapTypeId.ROADMAP }); //End map parameters campusmap = new google.maps.KmlLayer('http://wendysmithtoronto.com/mapping/1851mapshoreline.kml', {preserveViewport:true, suppressInfoWindows:true}); campusmap.setMap(map); google.maps.event.addListener(campusmap, 'click', function(kmlEvent) { document.getElementById('sidebarinfo').innerHTML = kmlEvent.featureData.description; }); philpotts = new google.maps.KmlLayer('http://wendysmithtoronto.com/mapping/1818maplieutphilpottsd.kml', {preserveViewport:true, suppressInfoWindows:true}); google.maps.event.addListener(philpotts, 'click', function(kmlEvent) { document.getElementById('sidebarinfo').innerHTML = kmlEvent.featureData.description; }); philpotts.setMap(map); beartrail = new google.maps.KmlLayer('http://wendysmithtoronto.com/mapping/1842map-jamescaneb.kml', {preserveViewport:true, suppressInfoWindows:true}); google.maps.event.addListener(beartrail, 'click', function(kmlEvent) { document.getElementById('sidebarinfo').innerHTML = kmlEvent.featureData.description; }); beartrail.setMap(map); layer_2 = new google.maps.FusionTablesLayer({ suppressInfoWindows:true, query: { select: 'Location', from: '3189980' }, styles: [ {where: "'style' = 14", markerOptions:{ iconName:"star"}}, {where: "'style' = 13", markerOptions:{ iconName:"wht_pushpin"}}, {where: "'style' = 11", markerOptions:{iconName:"red_blank"}}, //town houses {where: "'style' = 12", markerOptions:{ iconName:"orange_blank"}}, //country homes {where: "'style' = 15", markerOptions:{ iconName:"target"}}, ]}); layer_1 = new google.maps.FusionTablesLayer({ suppressInfoWindows:true, query: { select: 'Location', from: '2920040' }}), google.maps.event.addListener(layer_1, "click", openIW); google.maps.event.addListener(layer_2, "click", openIW); google.maps.event.addListener(map, "click", function() { infoWindow.close();}); layer_1.setMap(map); layer_2.setMap(map); } // end initialize </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload