SETUP
OpenLayers / GeoServer + PostGIS
REQUIREMENT
I have a map with multiple WMS layers and of these I need to refresh a few after inserting a polygon in one of the layers.
PROBLEM
Given below are three options of the AJAX success callback function on successful insert of polygon geometry in the PostGIS backend and the corresponding errors/observations.
Option 1:
if(data == "SUCCESS"){ map.getLayersByName('dummy_nodes')[0].redraw(true); map.getLayersByName('bldg_logical')[0].redraw(true); }// Throws error: Uncaught TypeError: Cannot call method 'redraw' of undefinedOption 2:
var tempLayer;if(data == "SUCCESS"){ map.getLayersByName('dummy_nodes')[0].redraw(true); console.log("Prev cmd is successful"); tempLayer = map.getLayersByName('bldg_logical')[0] tempLayer.redraw(true); }// Outputs: 'Prev cmd is successful'// tempLayer gives proper layer object: OpenLayers.Layer.WMS.OpenLayers.Class.initialize {metadata: Object, options: Object, singleTile: true, ratio: 1, isBaseLayer: false…}// But still throws error: Uncaught TypeError: Cannot call method 'redraw' of undefinedOption 3:
if(data == "SUCCESS"){ map.getLayersByName('dummy_nodes')[0].redraw(true);}// Works fine (but I need both layers to be refreshed)QUESTIONS
Could anyone let me know why the error occurs?
Is my usage wrong?
Does it have to do anything with the order in which the layers have been added to the map?
Thanks.
أكثر...
OpenLayers / GeoServer + PostGIS
REQUIREMENT
I have a map with multiple WMS layers and of these I need to refresh a few after inserting a polygon in one of the layers.
PROBLEM
Given below are three options of the AJAX success callback function on successful insert of polygon geometry in the PostGIS backend and the corresponding errors/observations.
Option 1:
if(data == "SUCCESS"){ map.getLayersByName('dummy_nodes')[0].redraw(true); map.getLayersByName('bldg_logical')[0].redraw(true); }// Throws error: Uncaught TypeError: Cannot call method 'redraw' of undefinedOption 2:
var tempLayer;if(data == "SUCCESS"){ map.getLayersByName('dummy_nodes')[0].redraw(true); console.log("Prev cmd is successful"); tempLayer = map.getLayersByName('bldg_logical')[0] tempLayer.redraw(true); }// Outputs: 'Prev cmd is successful'// tempLayer gives proper layer object: OpenLayers.Layer.WMS.OpenLayers.Class.initialize {metadata: Object, options: Object, singleTile: true, ratio: 1, isBaseLayer: false…}// But still throws error: Uncaught TypeError: Cannot call method 'redraw' of undefinedOption 3:
if(data == "SUCCESS"){ map.getLayersByName('dummy_nodes')[0].redraw(true);}// Works fine (but I need both layers to be refreshed)QUESTIONS
Could anyone let me know why the error occurs?
Is my usage wrong?
Does it have to do anything with the order in which the layers have been added to the map?
Thanks.
أكثر...