问题描述
我在 django 3 和 ol6 中有一个 webapp。
我的views.py是这样的
def highlightboundary(request):
searchArr = []
output = {}
dist = district.objects.filter(created_on__year__in=[2020,2021])
for d in dist:
searchArr.append({'type': 'Feature','properties': {'id': d.id,'code': d.code},'geometry': {'type': d.the_geom.geom_type,'coordinates': d.the_geom.geojson}})
output = {'type': 'FeatureCollection','features': searchArr}
return JsonResponse(output)
而我的 openlayer 代码是:
window.highltSubmit = function highltSubmit(event) {
$.post('/webapp/highlight/',function(data){ //Returns data from the above view
dist_highlt = new VectorLayer({
title:'Boundary Highlight',source: new VectorSource({
features: new GeoJSON().readFeatures(data,{
dataProjection: 'epsg:32643',featureProjection: 'epsg:32643',}),style: new Style({
stroke: new stroke({
color: '#319FD3',width: 2,fill: new Fill({
color: 'rgba(255,255,0.6))',opacity: 0.5,});
map.addLayer(dist_highlt);
});
}
}
视图highlightboundary 将数据返回给上述post 函数。 但我的问题是多边形(multipolygon)没有突出显示或颜色没有填充到多边形内。如果它是一个点字段,它工作正常。我的代码有什么问题。
我收到错误
未捕获的类型错误:f.getLayout 不是函数 Multipolygon.js:94:27
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)