I'm trying to display a custom png TMS layer using olwidget custom layer types in django. The configuration I have below works great when I run the django development server, but fails when I run it on our production server using apache2/mod_wsgi
The error is:
TypeError: map_service is undefined
layers.push(map_service.map(map_type));
Which refers to line 277 in olwidget.js.
for (var i = 0; i < opts.layers.length; i++) {
var parts = opts.layers[i].split(".");
var map_service = olwidget[parts[0]];
var map_type = parts[1];
layers.push(map_service.map(map_type));
The parts reads ['image_map'] which refers to the custom layer defined below. However, it doesn't successfully generate map_service. Not sure why it works in development but not in production. Probably something stupid I'm doing. Great project!
from settings.py:
OLWIDGET_CUSTOM_LAYER_TYPES = {
'image_layer': """OpenLayers.Layer.TMS(
'Image TMS',
'',
{url: '',
serviceVersion: '.',
layername: '.',
alpha: true,
type: 'png',
getURL: overlay_getTileURL
}
)
function overlay_getTileURL(bounds) {
var projectId = sessvars.sessionObj['projectId']
floor = $('#id_floor').val();
var res = this.map.getResolution();
var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));
var y = Math.round((bounds.bottom - this.maxExtent.bottom) / (res * this.tileSize.h));
var z = this.map.getZoom();
if (x >= 0 && y >= 0) {
return "/static/userData/" + projectId + "/" + floor + "/" + z + "/" + x + "/" + y + "." + this.type;
} else {
}
}
"""
}