0
我正在处理小册子w block块集成。StreamField:添加地图块
https://github.com/frague59/wagtail-leaflet
我和小部件的渲染困难时,我add
新块到流:没有显示。来自django-leaflet/django-geojson的窗口小部件涉及设置geojson参数'window wide',这并不反映在模板实例中。
在我leaflet/widget.html
:
<script type="text/javascript">
{% block vars %}var {{ module }} = {};
{{ module }}.fieldid = '{{ id_css }}';
{{ module }}.modifiable = {{ modifiable|yesno:"true,false" }};
{{ module }}.geom_type = '{{ geom_type }}';
{{ module }}.srid = {{ map_srid }};
{% endblock vars %}
function {{ id_map_callback }}(map, options) {
window.LEAFLET_DATA['{{ module }}'].store_class = {{ field_store_class }};
(new {{ geometry_field_class}}(window.LEAFLET_DATA['{{ module }}'])).addTo(map);
{% block callback %}{% endblock callback %}
};
{% if target_map %}
window.addEventListener('map:init', function (e) {
var target_map = e.detail.map;
target_map.on('map:loadfield', function (me) {
if (me.fieldid == 'id_{{ target_map }}') {
setTimeout(function() {
{{ id_map_callback }}(target_map, e.detail.options);
}, 0);
}
});
}, false);
{% endif %}
</script>
从text/template
元素:
<script type="text/javascript">
var geodjango___prefix___value = {};
geodjango___prefix___value.fieldid = '__prefix__-value';
geodjango___prefix___value.modifiable = true;
geodjango___prefix___value.geom_type = 'Geometry';
geodjango___prefix___value.srid = 4326;
function __prefix___value_map_callback(map, options) {
geodjango___prefix___value.store_class = L.FieldStore;
(new L.GeometryField(geodjango___prefix___value)).addTo(map);
};
</script>
的Streamfield块API并没有明确说明这个用例。
你有这种块的工作块的例子吗?
谢谢!
请提供[最小,完整且可验证的](https://stackoverflow.com/help/mcve)代码示例。 – gasman
https://github.com/makinacorpus/django-leaflet/issues/189 – frague
@gasman在我的仓库 相关代码: https://github.com/frague59/wagtail-leaflet这里 – frague