我使用的是GeoDjango,我的底图是BingMaps。当我查看源代码GeoJSON数据时,但它没有显示为图层。在我的管理员中使用OSMGeoAdmin,它确实显示。
这是我的JS的片段:
var styles = [
'Road',
'Aerial',
'AerialWithLabels'];
var layers = [];
var i, ii;
for (i = 0, ii = styles.length; i < ii; ++i) {
layers.push(new ol.layer.Tile({
visible: false,
preload: Infinity,
source: new ol.source.BingMaps({
key: 'Ak-dzM4wZjSqTlzveKz5u0d4IQ4bRzVI309GxmkgSVr1ewS6iPSrOvOKhA-CJlm3',
imagerySet: styles[i]
// use maxZoom 19 to see stretched tiles instead of the BingMaps
// "no photos at this zoom level" tiles
// maxZoom: 19
})
}));
}
var vectorLayer = new ol.layer.Vector({
source: new ol.source.GeoJSON({
{
flood_hazard | safe
}
})
});
var map = new ol.Map({
layers: [layers, vectorLayer],
renderer: exampleNS.getRendererFromQueryString(),
// Improve user experience by loading tiles while dragging/zooming. Will make
// zooming choppy on mobile or slow devices.
loadTilesWhileInteracting: true,
target: 'map',
view: new ol.View({
center: [13973849.17, 1000783.15],
zoom: 13
})
});
$('#layer-select').change(function () {
var style = $(this).find(':selected').val();
var i, ii;
for (i = 0, ii = layers.length; i < ii; ++i) {
layers[i].setVisible(styles[i] == style);
}
});
$('#layer-select').trigger('change');
我的基础地图是问题吗?它的SRID或转换值?错误说明:Uncaught TypeError: undefined is not a function
def home(request):
qry_flood_hazard = FloodHazard.objects.all()
djf = Django.Django(geodjango='geom', properties=['hazard', 'date_field'])
geoj = GeoJSON.GeoJSON()
flood_hazard = geoj.encode(djf.decode(qry_flood_hazard.transform(900913)))
return render(request,"index.html",{
'flood_hazard': flood_hazard,
})
我的模型FloodHazard
有这个srid,geom geometry(MultiPolygon,32651)