ooops, I just realized I forgot to CC my answer to the list...
Gilles

-------- Original Message --------
Subject: Re: [Mapbuilder-users] Mapbuilder and Ext js, don't work together???
Date:   Thu, 10 Apr 2008 12:12:52 +0200
From:   Gilles Bassière <[EMAIL PROTECTED]>
To:     Toan Nguyen <[EMAIL PROTECTED]>
References:     <[EMAIL PROTECTED]>



Hi there,

I got a similar problem while using prototype.js. As far as I can remember Ext is based upon prototype, is it ? If it is, the following might help :

The problem is that prototype redefine the operator _each() for the Array class. As a consequence, the for statement behaves differently. A basic solution I changed for loops from:

for (var myObj in myArray) {
}

to:

var i;
for (i=0; i<myArray.length; i++) {
myObj=myArray[i];
}

I feel like this issue comes from a design fault on the prototype side. Array is a common class in Javascript and prototype should better define an alternate PArray class to implement its behavior. Thus it should be corrected in the prototype library. As a temporary workaround (and for convenience), I did the modification in the mapbuilder code. Please see attached patch for FeatureSelectHandler.js.

Regards
Gilles


Toan Nguyen wrote:
Hi all,
I use Mapbuilder to builde my map, and it work well. Now I want to use Ext JS Library (http://extjs.com/) to create tab, dialog, panel for my webpage. But when I import Ext JS script into webpage, (just import js file, haven't create anything yet), the map is blank, I can't see any layer. And some script don't work anymore. Example, when I click on mapPanel, I still see selected features, but the feature list is empty, and error on SelectedFeatureHandler.js

I can't use Ext JS with Mapbuilder?

--
Nguyễn Đình Toán

-------------------------
Neu khong doc duoc tieng Viet, vui long vao menu View --> chon Encoding --> chon Unicode (UTF-8). Cam on.
------------------------------------------------------------------------

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
------------------------------------------------------------------------

_______________________________________________
Mapbuilder-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mapbuilder-users

--
Gilles Bassiere
MAKINA CORPUS
30 rue des Jeuneurs
FR-75002 PARIS
+33 (0) 1 44 82 00 80
http://www.makina-corpus.com




--
Gilles Bassiere
MAKINA CORPUS
30 rue des Jeuneurs
FR-75002 PARIS
+33 (0) 1 44 82 00 80
http://www.makina-corpus.com

Index: FeatureSelectHandler.js
===================================================================
--- FeatureSelectHandler.js	(revision 56)
+++ FeatureSelectHandler.js	(revision 57)
@@ -1,4 +1,4 @@
-/*
+/*
 License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
 $Id: FeatureSelectHandler.js 3739 2007-12-13 22:58:36Z ahocevar $
 */
@@ -88,11 +88,17 @@
       // if we hava a plain model, just use it
       objRef.sourceModels.push(objRef.model);
     } 
+    /* The prototype.js library overloads the Array class making the "for (var in array)" structure buggy...
     for (var i in objRef.sourceModels) {
       objRef.sourceModels[i].addListener('highlightFeature', objRef.highlight, objRef);
       objRef.sourceModels[i].addListener('dehighlightFeature', objRef.dehighlight, objRef);
-
     }
+    */
+    /* This one works better (actually copied from the prototype.js code) */
+    for (var i = 0, length = objRef.sourceModels.length; i < length; i++) {
+      objRef.sourceModels[i].addListener('highlightFeature', objRef.highlight, objRef);
+      objRef.sourceModels[i].addListener('dehighlightFeature', objRef.dehighlight, objRef);
+    }
     
     // init the control
     var layer = objRef.model.getParam('gmlRendererLayer');
@@ -158,7 +164,8 @@
   this.onSelect = function(feature) {
     if (!feature) return;
     var objRef = this.mbFeatureSelectHandler;
-    for (var i in objRef.sourceModels) {
+    //for (var i in objRef.sourceModels) {
+    for (var i = 0, length = objRef.sourceModels.length; i < length; i++) {
       objRef.sourceModels[i].setParam("mouseoverFeature", feature.fid);
     }
     // check if onSelect was triggered by a mouse event. If not, do not register for
@@ -182,7 +189,8 @@
   this.onUnselect = function(feature) {
     if (!feature) return;
     var objRef = this.mbFeatureSelectHandler || feature.mbFeatureSelectHandler;
-    for (var i in objRef.sourceModels) {
+    //for (var i in objRef.sourceModels) {
+    for (var i = 0, length = objRef.sourceModels.length; i < length; i++) {
       objRef.sourceModels[i].setParam("mouseoutFeature", feature.fid);
     }
     objRef.model.setParam("olFeatureOut", feature);
@@ -240,7 +248,8 @@
   this.highlight = function(objRef, fid) {
     var model, feature;
     var layer = objRef.model.getParam('gmlRendererLayer');
-    for (var i in objRef.sourceModels) {
+    //for (var i in objRef.sourceModels) {
+    for (var i = 0, length = objRef.sourceModels.length; i < length; i++) {
       model = objRef.sourceModels[i]
       if (!layer) return;
       if (!fid) {
@@ -267,7 +276,8 @@
   this.dehighlight = function(objRef, fid) {
     var model, feature;
     var layer = objRef.model.getParam('gmlRendererLayer');
-    for (var i in objRef.sourceModels) {
+    //for (var i in objRef.sourceModels) {
+    for (var i = 0, length = objRef.sourceModels.length; i < length; i++) {
       model = objRef.sourceModels[i];
       if (!layer) return;
       if (!fid) {
begin:vcard
fn;quoted-printable:Gilles Bassi=C3=A8re
n;quoted-printable:Bassi=C3=A8re;Gilles
org:Makina Corpus;GIS
adr;quoted-printable:;;30 rue des Je=C3=BBneurs;Paris;;FR-75011;France
email;internet:[EMAIL PROTECTED]
title:Web GIS developper
tel;work:+33 (0) 1 44 82 00 80
x-mozilla-html:FALSE
url:http://www.makina-corpus.com
version:2.1
end:vcard

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Mapbuilder-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mapbuilder-users

Reply via email to