0
리플렛 wagtail 블록 통합 작업 중입니다. 아무것도 표시 : I 스트림에 새 블록을 add
때StreamField :지도 추가 블록
https://github.com/frague59/wagtail-leaflet
나는 위젯 렌더링 어려움을했습니다. django-leaflet/django-geojson의 위젯은 템플릿 창안에 반영되지 않은 geojson 매개 변수 'window wide'의 설정을 포함합니다. 내 leaflet/widget.html
에서
:
이<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가 명확하게 사용 사례를 언급하지 않습니다 text/template
요소에서
<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>
.
이런 종류의 블록이있는 작동중인 블록 예가 있습니까?
감사합니다.
[최소, 완전하고 검증 가능한] (https://stackoverflow.com/help/mcve) 코드 예제를 제공해주십시오. 이 https://github.com/frague59/wagtail-leaflet 여기 – gasman
https://github.com/makinacorpus/django-leaflet/issues/189 – frague
내 저장소에 관련 코드 @gasman 전체 프로젝트를 조사하여 문제가 무엇인지 확인하십시오. https://stackoverflow.com/help/mcve에서 설명한 것처럼 코드를 문제를 나타내는 가장 작은 예제로 줄여야합니다. – frague