Hello Pierre,<br>yes sure, we tryied! <br>Unfortunately the problem was related to ExtJs and Mozilla Firefox 3, not to $ function.<br>Anyway what you indicate remains the only solution for using OpenLayers and jQuery library together (unless you want to change the name of $ function in OL or in jQuery).<br>
Thank you very much!<br><br>Fabio D&#39;Ovidio<br><br><div class="gmail_quote">2009/3/12 Pierre GIRAUD <span dir="ltr">&lt;<a href="mailto:bluecarto@gmail.com">bluecarto@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Fabio,<br>
<br>
This might be stupid but did you try the following ?<br>
<br>
var map = new OpenLayers.Map(&#39;map&#39;);<br>
<br>
OpenLayers.Map constructor can be given either a DOM Element or the id<br>
of a DOM Element.<br>
<br>
Hope this helps,<br>
Pierre<br>
<div><div></div><div class="h5"><br>
<br>
On Wed, Mar 11, 2009 at 5:46 PM, Fabio D&#39;Ovidio &lt;<a href="mailto:fabiodovidio@gmail.com">fabiodovidio@gmail.com</a>&gt; wrote:<br>
&gt; Hello,<br>
&gt; in order to use jquery library toghether with mapfish client i try to<br>
&gt; summarize the problems related to:<br>
&gt;<br>
&gt;    * $ function definition in OpenLayers<br>
&gt;    * Extjs usage with jquery<br>
&gt;<br>
&gt; OpenLayers uses part of prototype library (without include it) in the<br>
&gt; following files:<br>
&gt;<br>
&gt;    * Util.js<br>
&gt;    * Ajax.js<br>
&gt;    * Events.js<br>
&gt;    * Calss.js<br>
&gt;<br>
&gt; In particular in Util.js $ function is defined as following:<br>
&gt; /**<br>
&gt;  * Maintain $() from prototype<br>
&gt;  */<br>
&gt; if ($ == null) {<br>
&gt;    var $ = OpenLayers.Util.getElement;<br>
&gt; }<br>
&gt;<br>
&gt; jQuery library also define a $ function as: $ = jQuery<br>
&gt;<br>
&gt; Than, jQuery library is shipped with ExtJS, and MapFish ships with<br>
&gt; ExtJS. In particular ExtJS does not load jQuery dynamically, you need to<br>
&gt; include it in your HTML<br>
&gt; with script tags in this order:<br>
&gt;<br>
&gt;   1. jquery.js<br>
&gt;   2. ext-jquery-adapter.js<br>
&gt;   3. ext-all.js (or your choice of files)<br>
&gt;<br>
&gt; Now, my HTML script with script tags is as following:<br>
&gt;<br>
&gt;    viewport:null;<br>
&gt;    map:null;<br>
&gt;<br>
&gt;    // reference local blank image<br>
&gt;    Ext.BLANK_IMAGE_URL = &#39;../../mfbase/ext/resources/images/default/s.gif&#39;;<br>
&gt;<br>
&gt;    Ext.onReady(function(){<br>
&gt;<br>
&gt;        var map = new OpenLayers.Map(*$(&#39;map&#39;)*);<br>
&gt;        this.map = map;<br>
&gt;<br>
&gt;        var wms = new OpenLayers.Layer.WMS(&quot;OpenLayers WMS&quot;,<br>
&gt;            &quot;<a href="http://labs.metacarta.com/wms/vmap0" target="_blank">http://labs.metacarta.com/wms/vmap0</a>&quot;, {layers: &#39;basic&#39;},<br>
&gt; {buffer: 0});<br>
&gt;<br>
&gt;        map.addLayers([wms]);<br>
&gt;        map.addControl(new OpenLayers.Control.LayerSwitcher());<br>
&gt;        map.setCenter(new OpenLayers.LonLat(17, 2), 2);<br>
&gt;<br>
&gt;      var window = new Ext.Window({<br>
&gt;            title: &#39;Map&#39;,<br>
&gt;            width: 500,<br>
&gt;            height: 300,<br>
&gt;            minWidth: 300,<br>
&gt;            minHeight: 200,<br>
&gt;            layout: &#39;fit&#39;,<br>
&gt;            plain: true,<br>
&gt;            bodyStyle: &#39;padding:5px;&#39;,<br>
&gt;            items: [{<br>
&gt;                xtype: &#39;mapcomponent&#39;,<br>
&gt;                map: map<br>
&gt;            }]<br>
&gt;        });<br>
&gt;        window.show();<br>
&gt;<br>
&gt; });<br>
&gt;<br>
&gt; and obviously I have a div in HTML template to display the map:<br>
&gt;<br>
&gt;  &lt;div id=&quot;map&quot;&gt;&lt;/div&gt;<br>
&gt;<br>
&gt; For all these reasons I must solve two problems:<br>
&gt;<br>
&gt;   1. re-name $ function in Util.js<br>
&gt;   2. include js files in the correct way to use mapfish with jQuery<br>
&gt;<br>
&gt; So I try in this way:<br>
&gt;<br>
&gt;   1. I changed Util.js like this:<br>
&gt;<br>
&gt;      var jq = OpenLayers.Util.getElement;<br>
&gt;<br>
&gt;      and my script become:<br>
&gt;<br>
&gt;          viewport:null;<br>
&gt;          map:null;<br>
&gt;<br>
&gt;          // reference local blank image<br>
&gt;          Ext.BLANK_IMAGE_URL =<br>
&gt;      &#39;../../mfbase/ext/resources/images/default/s.gif&#39;;<br>
&gt;<br>
&gt;          Ext.onReady(function(){<br>
&gt;<br>
&gt;              var map = new OpenLayers.Map(*jq(&#39;map&#39;)*);<br>
&gt;              this.map = map;<br>
&gt;<br>
&gt;              var wms = new OpenLayers.Layer.WMS(&quot;OpenLayers WMS&quot;,<br>
&gt;                  &quot;<a href="http://labs.metacarta.com/wms/vmap0" target="_blank">http://labs.metacarta.com/wms/vmap0</a>&quot;, {layers:<br>
&gt;      &#39;basic&#39;}, {buffer: 0});<br>
&gt;<br>
&gt;              map.addLayers([wms]);<br>
&gt;              map.addControl(new OpenLayers.Control.LayerSwitcher());<br>
&gt;              map.setCenter(new OpenLayers.LonLat(17, 2), 2);<br>
&gt;<br>
&gt;            var window = new Ext.Window({<br>
&gt;                  title: &#39;Map&#39;,<br>
&gt;                  width: 500,<br>
&gt;                  height: 300,<br>
&gt;                  minWidth: 300,<br>
&gt;                  minHeight: 200,<br>
&gt;                  layout: &#39;fit&#39;,<br>
&gt;                  plain: true,<br>
&gt;                  bodyStyle: &#39;padding:5px;&#39;,<br>
&gt;                  items: [{<br>
&gt;                      xtype: &#39;mapcomponent&#39;,<br>
&gt;                      map: map<br>
&gt;                  }]<br>
&gt;              });<br>
&gt;              window.show();<br>
&gt;<br>
&gt;      });<br>
&gt;<br>
&gt;<br>
&gt;      (I tryed also using *jQuery.noConflict();* before my script<br>
&gt;      without changing Util.js file)<br>
&gt;<br>
&gt;   2. I included in my script JS files in this order:<br>
&gt;      jquery.js,\<br>
&gt;      ext-jquery-adapter.js,\<br>
&gt;      ext-all.js<br>
&gt;<br>
&gt; and the error is:<br>
&gt; &quot;A[C.xtype || D] is not a constructor&quot;<br>
&gt; that deals with ExtJS (maybe on onReady event, I read this post:<br>
&gt; <a href="http://extjs.com/forum/showthread.php?t=53502&amp;highlight=onready+onload" target="_blank">http://extjs.com/forum/showthread.php?t=53502&amp;highlight=onready+onload</a>)<br>
&gt;<br>
&gt; If I don&#39;t chage Util.js (or use *jQuery.noConflict() function*) I have<br>
&gt; the following error:<br>
&gt;<br>
&gt; &quot;this.div.appendChild is not a function&quot;<br>
&gt;<br>
&gt; because:<br>
&gt; 1) I load up jQuery, this defines the $ function<br>
&gt; 2) I load OpenLayers, this checks if $ exists, and because it does exist,<br>
&gt; it is not redefined in the OL (prototype) way<br>
&gt; 3) I initialize my map and send it the string &#39;map&#39; as the first<br>
&gt; argument<br>
&gt; 4) OpenLayers tries to place your map in the DOM element $(&#39;map&#39;), but<br>
&gt; because $() is still a jQuery function that doesn&#39;t return a DOM element,<br>
&gt; and I get the error about appendChild not being defined!<br>
&gt;<br>
&gt; How can I solve these problems? :-(<br>
&gt; Please, help me if you can :-)<br>
&gt;<br>
&gt; Thank you very much!!<br>
&gt;<br>
&gt; --<br>
&gt; Fabio D&#39;Ovidio<br>
&gt; Geospatial solutions<br>
&gt;<br>
&gt; INOVA s.r.l.<br>
&gt; Web : <a href="http://www.inovaos.it" target="_blank">http://www.inovaos.it</a><br>
&gt; Tel.: 081 197 57 600<br>
&gt; mail: <a href="mailto:fabiodovidio@gmail.com">fabiodovidio@gmail.com</a><br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; Users mailing list<br>
&gt; <a href="mailto:Users@openlayers.org">Users@openlayers.org</a><br>
&gt; <a href="http://openlayers.org/mailman/listinfo/users" target="_blank">http://openlayers.org/mailman/listinfo/users</a><br>
&gt;<br>
<font color="#888888"><br>
<br>
<br>
--<br>
Pierre GIRAUD<br>
<a href="http://www.camptocamp.com" target="_blank">http://www.camptocamp.com</a><br>
</font></blockquote></div><br>