- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我包含以下代码时,没有出现任何标记,并且控制台中的错误是:
Uncaught TypeError: this.callInitHooks is not a function at pointToLayer.
如果您知道任何解决方案,请分享。
var map = L.map('map', {
center: [53.423933, -7.94069],
zoom: 7,
layers: [grayscale]
});
var url = "howdy.json";
var geojsonMarkerOptions = L.icon({
iconUrl: 'howdy.png',
iconSize: [16, 28],
iconAnchor: [8, 18],
popupAnchor: [-3, -13]
});
function forEachFeature(feature, layer) {
var popupContent =
feature.properties.Cabin+
feature.properties.Crew +
feature.properties.Mobile;
if (feature.properties && feature.properties.popupContent) {
popupContent += feature.properties.popupContent;
}
layer.bindPopup(popupContent);
};
var howdy = L.geoJSON(null, {
onEachFeature: forEachFeature,
pointToLayer: function (feature, latlng) {
return L.Marker(latlng, geojsonMarkerOptions);
}
});
$.getJSON(url, function(data) {
Shelter.addData(data);
});
Shelter.addTo(map);
最佳答案
很可能错误是由您的线路引起的:
return L.Marker(latlng, geojsonMarkerOptions);
...您尝试实例化传单标记调用 L.Marker
类构造函数 而没有触发实例化的 new
JavaScript 关键字。
注意与Leaflet提供的factory L.marker
(小写首字母m
)的区别,它只是的别名新的 L.Marker
.
关于javascript - 如何在 L.geoJSON pointToLayer 中实例化 Marker,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50420327/
我目前正在尝试学习 React,我想使用传单 map (react-leaflet)。 我有两个(点、多边形)GeoJson 对象要显示,它们正在工作,但我想替换默认标记图标。 传单文档 http:/
我正在尝试在 GeoJSON 组件中使用 pointToLayer 参数。我在组件外部(不同的文件)定义了函数 pointToLayer ,但出现了该错误。 Map.js: import {point
我尝试在我的传单 map 中应用 pointTolayer 但它仍然抛出经典图标。代码中有错误。 $.getJSON("https://gist.githubusercontent.com/vassi
当我包含以下代码时,没有出现任何标记,并且控制台中的错误是: Uncaught TypeError: this.callInitHooks is not a function at pointToLa
您好,有什么方法可以将 jsx 组件传递给 bindPopup 函数,以便我可以在按钮单击时推送 redux 命令? pointToLayer={( geoJsonPoint: Feat
我在 Mapbox 中使用此函数与 geoJson 来使用 simplestyle 中的样式标记 var groupThree = new L.LayerGroup(); L.geoJson(laye
我是一名优秀的程序员,十分优秀!