Google maps api 3 在fusion tables映射中标记附近图标

Google maps api 3 在fusion tables映射中标记附近图标,google-maps-api-3,google-fusion-tables,Google Maps Api 3,Google Fusion Tables,我画了一张地图,上面显示了某个特定地区的一些餐馆。我使用融合表作为数据输入,并生成代码来显示此地图: 我尝试在placemark图标附近添加一个带有餐厅名称的文本标签,但没有成功。 有什么办法吗? 我在论坛上搜索了很多,但没有找到解决方案 多谢各位 JT 这是密码 <!DOCTYPE html> <html> <head> <meta name="viewport"></meta> <title

我画了一张地图,上面显示了某个特定地区的一些餐馆。我使用融合表作为数据输入,并生成代码来显示此地图:

我尝试在placemark图标附近添加一个带有餐厅名称的文本标签,但没有成功。 有什么办法吗? 我在论坛上搜索了很多,但没有找到解决方案

多谢各位

JT

这是密码

  <!DOCTYPE html>
    <html>
    <head>
    <meta name="viewport"></meta>
    <title>Locali in zona Fiume e Quarnero - Google Fusion Tables</title>
    <style type="text/css">
    html, body, #googft-mapCanvas { height:100%; margin: 0; padding: 0;}
    </style>

    <script type="text/javascript" src="https://maps.google.com/maps/api/js?     sensor=false&amp;v=3"></script>

    <script type="text/javascript">
      function initialize() {
        google.maps.visualRefresh = true;
        var isMobile = (navigator.userAgent.toLowerCase().indexOf('android') > -1) ||
          (navigator.userAgent.match(/(iPod|iPhone|iPad|BlackBerry|Windows Phone|iemobile)/));
        if (isMobile) {
          var viewport = document.querySelector("meta[name=viewport]");
          viewport.setAttribute('content', 'initial-scale=1.0, user-scalable=no');
    }
    var mapDiv = document.getElementById('googft-mapCanvas');
    mapDiv.style.width = isMobile ?  '500px':'100%' ;
    mapDiv.style.height = isMobile ? '300px':'100%' ;
    var map = new google.maps.Map(mapDiv, {
      center: new google.maps.LatLng(45.19975321105807, 14.824613028515614),
      zoom: 10,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });
        map.controls[google.maps.ControlPosition.RIGHT_BOTTOM].push(document.getElementById('googft-legend-open'));
       map.controls[google.maps.ControlPosition.RIGHT_BOTTOM].push(document.getElementById('googft-legend'));

    layer = new google.maps.FusionTablesLayer({
      map: map,
      heatmap: { enabled: false },
      query: {
        select: "col6",
        from: "1e8PEAUCopFkL9XqgVp1gJAv6Hh6ttGkMViOGhSZx",
        where: ""
      },
      options: {
        styleId: 2,
        templateId: 2
      }

    });

    if (isMobile) {
      var legend = document.getElementById('googft-legend');
      var legendOpenButton = document.getElementById('googft-legend-open');
      var legendCloseButton = document.getElementById('googft-legend-close');
      legend.style.display = 'none';
      legendOpenButton.style.display = 'block';
      legendCloseButton.style.display = 'block';
      legendOpenButton.onclick = function() {
        legend.style.display = 'block';
        legendOpenButton.style.display = 'none';
      }
      legendCloseButton.onclick = function() {
        legend.style.display = 'none';
        legendOpenButton.style.display = 'block';
      }
    }
  }

  google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>

<body>
  <div id="googft-mapCanvas"></div>
</body>
</html>

对于少于几百行的表,一个选项是使用GViz查询表中的数据,并使用它向地图添加标签


我试过了,但运气不好:你试过什么?请展示你的尝试。我试图在网上搜索类似的问题!我找到的唯一解决方案是使用markerwithlabels.js库,但我无法与Fusion表集成。非常感谢!!我不认识GViz。。我将搜索文档。一个问题:为什么要限制几百行?性能问题?再次感谢你!谷歌可视化API接口内置了对FusionTables的限制。不记得记录在哪里了。如果您使用Fusionables API,则不存在此限制。再次感谢您!我搜索了限制,发现有500行。关于JT。
google.load('visualization', '1', {'packages':['corechart', 'table', 'geomap']});

var tableid ="1e8PEAUCopFkL9XqgVp1gJAv6Hh6ttGkMViOGhSZx"
var map;
var labels = [];
function displayLabels() {
  //set the query using the current bounds
  var queryStr = "SELECT Posizione, Nome FROM "+ tableid;   
  var queryText = encodeURIComponent(queryStr);
  var query = new google.visualization.Query('http://www.google.com/fusiontables/gvizdata?tq='  + queryText);
  // alert(queryStr);

  //set the callback function
  query.send(displayLabelText);

}
function displayLabelText(response) {
if (!response) {
  alert('no response');
  return;
}
if (response.isError()) {
  alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
  return;
} 

  FTresponse = response;
  //for more information on the response object, see the documentation
  //http://code.google.com/apis/visualization/documentation/reference.html#QueryResponse
  numRows = response.getDataTable().getNumberOfRows();
  numCols = response.getDataTable().getNumberOfColumns();
  // alert(numRows);
  // var bounds = new google.maps.LatLngBounds();
  for(i = 0; i < numRows; i++) {
      var label = response.getDataTable().getValue(i, 1);
      var labelStr = label.toString()
      var positionStr = response.getDataTable().getValue(i, 0);
      var position = positionStr.split(',');
      var point = new google.maps.LatLng(
          parseFloat(position[0]),
          parseFloat(position[1]));
      // bounds.extend(point);
      labels.push(new InfoBox({
     content: labelStr
    ,boxStyle: {
       border: "1px solid black"
      ,textAlign: "center"
          ,backgroundColor:"white"
      ,fontSize: "8pt"
      ,width: "50px"
     }
    ,disableAutoPan: true
    ,pixelOffset: new google.maps.Size(-25, 0)
    ,position: point
    ,closeBoxURL: ""
    ,isHidden: false
    ,enableEventPropagation: true
      }));
      labels[labels.length-1].open(map);
  }
  // zoom to the bounds
  // map.fitBounds(bounds);
}
google.setOnLoadCallback(displayLabels);