[ka-Map-dev] [Bug 1493] New: [ka-Map] Prevent error if oSelect
undefined in myMapinitialized()
bugzilla-daemon at bugzilla.maptools.org
bugzilla-daemon at bugzilla.maptools.org
Thu Jun 15 10:10:31 EDT 2006
http://bugzilla.maptools.org/show_bug.cgi?id=1493
Summary: [ka-Map] Prevent error if oSelect undefined in
myMapinitialized()
Product: ka-Map
Version: 0.3
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: core
AssignedTo: ka-map-dev at lists.maptools.org
ReportedBy: dmorissette at mapgears.com
Using ka-Map 0.3 from CVS, if I remove the "maps" <select> list from index.html
to let ka-Map use only the default mapfile, then I get an error in
myMapInitialized() because oSelect is undefined.
I'd propose adding an 'if (oSelect)' around the block that populates the list of
maps in myMapInitialized() in startUp.js. Here is the patch to do it.
Any objection to applying it to CVS? Any other places with similar code that
should be updated?
--- startUp.js 21 Apr 2006 15:57:39 -0000 1.28
+++ startUp.js 15 Jun 2006 14:09:48 -0000
@@ -137,24 +137,29 @@
function myMapInitialized( eventID, mapName ) {
//get list of maps and populate the maps select box
var aMaps = myKaMap.getMaps();
+ // Update map selection list if one is available
var oSelect = document.forms[0].maps;
- var j = 0;
- var opt = new Option( 'select a map', '', true, true );
- oSelect[j++] = opt;
- for(var i in aMaps) {
- oSelect[j++] = new Option(aMaps[i].title,aMaps[i].name,false,false);
- }
+ if (oSelect)
+ {
+ var j = 0;
+ var opt = new Option( 'select a map', '', true, true );
+ oSelect[j++] = opt;
+ for(var i in aMaps) {
+ oSelect[j++] = new Option(aMaps[i].title,aMaps[i].name,false,false);
+ }
- //make sure the map is selected ...
- var oSelect = document.forms[0].maps;
- if (oSelect.options[oSelect.selectedIndex].value != mapName) {
- for(var i = 0; i < oSelect.options.length; i++ ) {
- if (oSelect.options[i].value == mapName) {
- oSelect.options[i].selected = true;
- break;
- }
+ //make sure the map is selected ...
+ var oSelect = document.forms[0].maps;
+ if (oSelect.options[oSelect.selectedIndex].value != mapName) {
+ for(var i = 0; i < oSelect.options.length; i++ ) {
+ if (oSelect.options[i].value == mapName) {
+ oSelect.options[i].selected = true;
+ break;
+ }
+ }
}
- }
+ }
+
//update the scales select
var currentMap = myKaMap.getCurrentMap();
var scales = currentMap.getScales();
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
Please do NOT reply to this email, use the link above instead to
login to bugzilla and submit your comment. Any email reply to this
address will be lost.
More information about the ka-Map-dev
mailing list