2

对于熟悉 Google Fusion Tables 的人,我有一个简单的问题。基本上,我希望用户能够通过间接更改与标记样式类型对应的数字列来更改地图上的标记样式。

具体来说,我目前有一个包含大约 7000 个地址和相应地图的 Fusion Table。我想知道是否有任何方式从地图更改标记类型。这是我目前的配置方式:我在融合表中有一个列,它将标记类型划分为绘制不同标记类型的“桶”。现在它们都是红色圆圈,当我访问每个位置时,我想单独更改标记类型(所以在表格中我会将 1(对应于红色)更改为 3(对应于绿色)),这样我知道我去过哪些房子。但是我向下滚动 7000 点的融合表并将 1 更改为 3 是不可行的,所以我想知道是否无论如何我可以直接在地图上更改它,无论是从网页上的地图还是在里面的融合表地图上谷歌。

提前谢谢你,大卫

4

1 回答 1

1

如果您在页面上有一个融合表派生图,您可以在信息窗口中添加一个按钮来更新融合表中的值 - 这样您就可以将值从 1 更改为 3。再进一步,您可以添加单击地图标记本身并更改值的侦听器。

更新值(特别是如果您是表的所有者)很简单(https://developers.google.com/fusiontables/docs/v1/using#updateRowhttps://developers.google.com/fusiontables/docs /v1/sql-reference#updateRow)并且基本上是使用 HTTP 调用请求的相当标准的 sql 操作形式。

UPDATE <table_id>
SET <column_name> = <value> {, <column_name> = <value> }*
WHERE ROWID = <row_id>

将侦听器添加到标记以使用更新按钮弹出信息窗口也很简单:

https://developers.google.com/maps/documentation/javascript/examples/infowindow-simple

// This example displays a marker at the center of Australia.
// When the user clicks the marker, an info window opens.

function initialize() {
  var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
  var mapOptions = {
    zoom: 4,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };

  var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);

  var contentString = '<div id="content">'+
      '<div id="siteNotice">'+
      'button that call some ajax to fire off a column update' +
      '</div>';

  var infowindow = new google.maps.InfoWindow({
      content: contentString
  });

  var marker = new google.maps.Marker({
      position: myLatlng,
      map: map,
      title: 'Uluru (Ayers Rock)'
  });
  google.maps.event.addListener(marker, 'click', function() {
    infowindow.open(map,marker);
  });
}

google.maps.event.addDomListener(window, 'load', initialize);
于 2013-11-04T09:51:37.523 回答