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