【问题标题】:Multiple map markers with numbers on top of the markers?标记顶部有数字的多个地图标记?
【发布时间】:2014-06-17 04:16:24
【问题描述】:

我的多个标记被添加到带有自定义标记图标的地图中,没有任何问题。

我现在要做的是在自定义标记图标顶部添加数字 - 它们似乎没有出现。这些数字应与位置编号相对应,在我的示例中为 i,从 1 到末尾排列。

我正在使用markerwithlabel 示例,并在页面上添加了 CSS 和 JS。

infowindow = new google.maps.InfoWindow();
      var temp;
      for(var i=0;i<data.length;i++){ 
        temp=new google.maps.LatLng(data[i][0],data[i][1]);
        marker= new google.maps.Marker({
          position: temp,
          labelContent: "test",
          labelAnchor: new google.maps.Point(22, 0),
          labelClass: "labels", // the CSS class for the label
          labelStyle: {opacity: 1.0},
          icon:'http://www.example.com/my_custom_marker.png',
          map: map
        });
        //console.info("single marker Lat is: ",data[i][0]," Lng is: ",data[i][1]," count is: ",data[i][2]); 
        google.maps.event.addListener(marker,'click',function(marker,i){
          var p=i+1;
          return function() {
            map.setZoom(19);
              map.setCenter(marker.getPosition());
                    infowindow.setContent("Step "+p+" - "+data[i][2]);
                    infowindow.open(map, marker);
                }
        }(marker,i));

【问题讨论】:

    标签: javascript google-maps google-maps-api-3 google-maps-markers


    【解决方案1】:

    所有使用marker = new MarkerWithLabel({.

    【讨论】:

      猜你喜欢
      • 2021-12-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-09
      相关资源
      最近更新 更多