yaronyogev
yaronyogev

Reputation: 428

Points for rows from fusion table not shown in map gadget

I have a Google Sites page with a Google map showing locations of speed traps in Israel. It is showing the locations from a Google Fusion Tables table, displaying locations on the map by dividing values of the 'type' column into buckets. See the map gadget XML below.

Lately, I added several new rows with a new type (7). I see that the points for these new locations are not shown in the map gadget on my Google Sites page. However, in the fusion table page, I can see these locations just fine.

Any idea why this can happen?

Thanks, Yaron

The map gadget XML: (removed unused function for clarity)

<Module>
<ModulePrefs 
description="Israel Speed Traps"
width="500"
height="600">
</ModulePrefs>
<Content type="html"><![CDATA[
<!DOCTYPE html>
<html>
<head>
<style>
  #map_canvas { width: 100%; height: 100%; }
</style>

<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false&language=iw"></script>
<script type="text/javascript">
var map;

var layer;
var tableid = 2943387;

function initialize() {
  map = new google.maps.Map(document.getElementById('map_canvas'), {
    center: new google.maps.LatLng(32.407792,35.502319),
    zoom: 8,
    mapTypeId: google.maps.MapTypeId.HYBRID
  });

  layer = new google.maps.FusionTablesLayer(tableid);
  layer.setQuery("SELECT 'Location' FROM " + tableid);
  layer.setMap(map);
}

</script>

</head>
<body onload="initialize();">

<div id="map_canvas"></div>

</body>
</html>
]]></Content>
</Module>

Upvotes: 0

Views: 91

Answers (1)

Dr.Molle
Dr.Molle

Reputation: 117334

Your code uses a wrong tableId.

The ID of the table you are talking about is 1uMTPGcFuJsNxKcCLkSxAOIMJCrlzNIV46MUTlD4,

but your code points to a different table with the ID 1OZ8ty7BP3di6WVEwtM-CTJhoQaNlIpZowsSHkHPR which doesn't contain the rows with type:7

Furthermore, when you want to apply the same appereance in the gadget you also must define templateId(for infowindows) and styleId(for feature-styles)

fixed script:

<script type="text/javascript">
var map,
    layer,
    tableid = '1uMTPGcFuJsNxKcCLkSxAOIMJCrlzNIV46MUTlD4';
function initialize() {
  map = new google.maps.Map(document.getElementById('map_canvas'), {
    center: new google.maps.LatLng(32.407792,35.502319),
    zoom: 8,
    mapTypeId: google.maps.MapTypeId.HYBRID
  });

  layer = new google.maps.FusionTablesLayer(tableid,{
      options: {
        styleId: 3,
        templateId:3
      }});
  layer.setQuery("SELECT 'Location' FROM " + tableid);
  layer.setMap(map);
}

</script>

Upvotes: 1

Related Questions