离子和 LeafletJS 设置标记
ionic & LeafletJS set marker
我正在尝试使用
为我的 $scope.map
变量设置标记
L.marker([location.lat,location.lng]).addTo($scope.map);
,但我不断收到此错误:
TypeError: t.addLayer is not a function at
o.Marker.o.Class.extend.addTo (leaflet.js:7) at mapController.js:82
我不知道为什么,因为我基本上和http://leafletjs.com/examples/custom-icons.html
一样
并且在 API 中指定
http://leafletjs.com/reference.html#marker
我想添加自定义图标,但现在挂了。
我建议您添加 angular-leaflet-directives 这是为 angular JS 打包的传单。
然后要添加标记,请执行以下操作:
创建你的标记
var iconTemplate = {
'lat': lat, // your lat value
'lng': lng, // your lng value
'focus': false,
'layer': layerValue, // if you add your marker to a layer
'draggable': false,
'message': popupContent, // your popupcontent
getMessageScope: function() {
return $scope;
},
compileMessage: true,
'icon': {
'type': "awesomeMarker", // i use awesomeMarker for font awesome
'icon': markerIcon, // a variable for my icon
'markerColor': markerColor // a variable for my color
}
};
将您的标记添加到您的标记列表(绑定到 HTML)
$scope.markers.push(iconTemplate)
就是这样
我正在尝试使用
为我的$scope.map
变量设置标记
L.marker([location.lat,location.lng]).addTo($scope.map);
,但我不断收到此错误:
TypeError: t.addLayer is not a function at o.Marker.o.Class.extend.addTo (leaflet.js:7) at mapController.js:82
我不知道为什么,因为我基本上和http://leafletjs.com/examples/custom-icons.html
一样并且在 API 中指定 http://leafletjs.com/reference.html#marker
我想添加自定义图标,但现在挂了。
我建议您添加 angular-leaflet-directives 这是为 angular JS 打包的传单。
然后要添加标记,请执行以下操作:
创建你的标记
var iconTemplate = { 'lat': lat, // your lat value 'lng': lng, // your lng value 'focus': false, 'layer': layerValue, // if you add your marker to a layer 'draggable': false, 'message': popupContent, // your popupcontent getMessageScope: function() { return $scope; }, compileMessage: true, 'icon': { 'type': "awesomeMarker", // i use awesomeMarker for font awesome 'icon': markerIcon, // a variable for my icon 'markerColor': markerColor // a variable for my color } };
将您的标记添加到您的标记列表(绑定到 HTML)
$scope.markers.push(iconTemplate)
就是这样