我目前正在尝试学习反应,我想使用传单地图(反应传单)。
我有两个要显示的(点,多边形)GeoJson对象,该对象正在运行,但是我想替换默认的标记图标。
传单文档http://leafletjs.com/examples/geojson/告诉我使用pointToLayer选项。
码:
onEachFeaturePoint,onEachfeaturePolygon,pointToLayer
onEachFeaturePoint(feature, layer) {
console.log('feature: ', feature);
console.log('layer: ', layer);
layer.on({
'click': function (e) {
console.log('e: ', e);
console.log('click');
}
})
}
onEachFeaturePolygon(feature, layer) {
console.log('feature: ', feature);
console.log('layer: ', layer);
layer.on({
'click': function (e) {
console.log('e: ', e);
console.log('click');
}
})
}
pointToLayer(feature, latlng) {
console.log('--- Point to layer');
console.log('feature: ', feature);
console.log('latlng: ', latlng);
return <CircleMarker center={latlng} />;
}
Run Code Online (Sandbox Code Playgroud)
渲染
render() {
const center = [9.4921875, 51.83577752045248];
return (
<Map center={center} zoom={1}> …Run Code Online (Sandbox Code Playgroud)