【发布时间】:2016-08-09 16:45:31
【问题描述】:
我知道我们可以动态地将 label 或 icon image 或 css class 应用于 angularJs 中的 google 标记,但我无法找出我们如何将动态 css 样式应用于标记。我必须在谷歌地图上动态生成标记并动态着色。我们能做到吗?
我已经尝试过,但似乎没有工作
var putMarker = function(lat,long,color) {
var marker = new google.maps.Marker({
position: new google.maps.LatLng(lat,long),
map: map,
labelStyle: {backgroundColor:"#ff00ff", height:"5px", width:"5px", borderRadius:"50px"},
icon: 'img/mapView.png',
label: (markers.length + 1) + '',
animation: google.maps.Animation.DROP,
isDraggable: false
});
markers.push(marker);
//extend the bounds to include each marker's position
bounds.extend(marker.position);
//now fit the map to the newly inclusive bounds
map.fitBounds(bounds);
}
【问题讨论】:
-
你为什么不尝试为你的图标赋予风格?您还可以使用 MarkerImage 类来调整大小等。
-
如何为我的图标赋予风格?任何解决方案.. 什么是 markerImage 类?
标签: javascript css angularjs google-maps google-maps-api-3