Reputation: 3
I currently have a Fusion Table Map that is synced to a Google Form through a script. It is for locations only in Oklahoma, so I am interested in adding a layer that will show the border of the state.
I made a KML Fusion Table with this information : https://www.google.com/fusiontables/embedviz?q=select+col2+from+1UUVOpuu7ymfkmuzyV9dO8PXwT2QoMFuRTCy8scvn&viz=MAP&h=false&lat=34.766328945783435&lng=-97.20538659179692&t=1&z=7&l=col2&y=2&tmplt=2&hml=KML
And I would like to add it to my map here: https://www.google.com/fusiontables/embedviz?q=select+col3%3E%3E0+from+1EPhndJHBm0ghi06Xq9d8P62hUwCisAcQxYxgH5ax&viz=MAP&h=false&lat=36.393799473451324&lng=-94.17718371249998&t=1&z=6&l=col3%3E%3E0&y=2&tmplt=2&hml=ONE_COL_LAT_LNG
I did some research and found the example of Chicago's map from google, and tried to adapt it to my current map
kmllayer = new google.maps.FusionTablesLayer({
query:{
select: "geometry",
from: "1UUVOpuu7ymfkmuzyV9dO8PXwT2QoMFuRTCy8scvn",
});
So I added that to the HTML from my Fusion Table map and then tried to add the code to my website. When I do this, I only get a blank screen. Also, I tried to add the code to my site without the KML code above, and it still only comes up blank. Am I missing a step? Any suggestions would be appreciated.
Upvotes: 0
Views: 308
Reputation: 117334
There is a syntax-error in your code, it has to be
kmllayer = new google.maps.FusionTablesLayer({
query:{
select: "geometry",
from: "1UUVOpuu7ymfkmuzyV9dO8PXwT2QoMFuRTCy8scvn",
}});
Working example with both layers:
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(35, -97),
zoom: 6
};
map = new google.maps.Map(document.getElementById("map-canvas"),
mapOptions);
new google.maps.FusionTablesLayer({
query: {
select: "geometry",
from: "1UUVOpuu7ymfkmuzyV9dO8PXwT2QoMFuRTCy8scvn",
},
map: map,
options: {
styleId: 2
}
});
new google.maps.FusionTablesLayer({
query: {
select: "geometry",
from: "1EPhndJHBm0ghi06Xq9d8P62hUwCisAcQxYxgH5ax",
},
map: map,
options: {
styleId: 2,
templateId: 2
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
html,
body,
#map-canvas {
height: 100%;
margin: 0;
padding: 0
}
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3"></script>
<div id="map-canvas"></div>
Upvotes: 1