Google Maps API-从融合表的字符串列中获取图标标记。

| 我正在使用JavaScript和Maps API的v3从Fusion Table中提取一些数据。我已成功将某些自定义标记添加到某些点,但现在尝试将我创建的标记“默认”添加到表中名为“图标”的列中指定的图标。我不使用融合表层,而是在for循环中根据数据创建标记。我的表格中的“图标”列具有以下条目:\'poi \',\'star \'等... 有什么办法可以使用名称字符串以某种方式像融合表层那样获得“默认”图标吗?另外,有人知道我可以在哪里找到默认融合表图标(例如POI和Star)的绝对位置,以便可以在脚本中定义指向它们的路径吗? 这是一些示例代码。如果有人知道Google图标的绝对URL,我可以编写一个函数来基于\'Icon \'列中的字符串进行输入。
      //if there\'s an image, use it as marker, else use default      
  if(row[3] != \'\'){
      // Create the marker
      var marker = new google.maps.Marker({
        map: map, 
        position: coordinate,
        icon: new google.maps.MarkerImage(row[3])
      });      
  } else {
      // Create the marker
      var marker = new google.maps.Marker({
        map: map, 
        position: coordinate

        //icon: row[2] (row[2] is the Icon column. 
        // I\'m assuming I\'ll just need a conditional to check
        // for the name (such as \'poi\') and then to put in the absolute URL for each respectively
        // the problem is I don\'t know the absolute URL\'s for these icons. Thanks.
      });
        }
    
已邀请:
        我一直想做几乎相同的确切过程。不过,我所做的只是在Fusion Table中用我的列描述了标记,因此,在您的情况下,将是\“ Poi,\” \“ Star,\”等。我的是\“ photo,\” \ “视频”,“歌曲”。然后,代码如下:
  var image = new google.maps.MarkerImage(\'img/CF_Orange.png\',
  new google.maps.Size(25, 25),
  new google.maps.Point(0,0),
  new google.maps.Point(12.5,12.5));

  var image2 = new google.maps.MarkerImage(\'img/CF_Purple.png\',
  new google.maps.Size(25, 25),
  new google.maps.Point(0,0),
  new google.maps.Point(12.5,12.5));

  var image3 = new google.maps.MarkerImage(\'img/CF_Green.png\',
  new google.maps.Size(25, 25),
  new google.maps.Point(0,0),
  new google.maps.Point(12.5,12.5));

if(row[5] == \'photo\'){
  var marker = new google.maps.Marker({
    map: map, 
    position: coordinate,
    icon: image
  });      
} else if(row[5] == \'video\'){
  var marker = new google.maps.Marker({
    map: map, 
    position: coordinate,
    icon: image2
  });
} else {
  var marker = new google.maps.Marker({
    map: map, 
    position: coordinate,
    icon: image3
  });
    }
    

要回复问题请先登录注册