It is a little clearer now, couple of things were no correct in my
code and it took a while to get everything a little more straight.
I performed the following : click on an openLayers point to launch
java function. It works like that :

First, my native Js function largely inspired by Openlayers example
page :
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 private static native JavaScriptObject _select(JavaScriptObject map,
JavaScriptObject layer,VectorLayer x)

    /*-{

        var mylayer=layer

          function select(feature)
          {

       [email protected]::selected
(Lcom/google/gwt/core/client/JavaScriptObject;)(feature.attributes[0])
          }


           var drawControl=new $wnd.OpenLayers.Control.SelectFeature
           (
                    mylayer,
                    {
                        clickout: true,
                        toggle: true,
                        multiple: true,
                        hover: false,
                        toggleKey: "ctrlKey", // ctrl key removes from
selection
                        multipleKey: "shiftKey", // shift key adds to
selection
                        box: true,
                        onSelect:select

                    }
            );

            map.addControl(drawControl);
            drawControl.activate();

        }-*/;

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Note that :
Those three objects are passed JavaScriptObject map, JavaScriptObject
layer,VectorLayer x (VectorLayer is the self reference of the class :
this)
The path to the class in JSNI context is :
[email protected]
To adress a function in my class :
[email protected]::selected()()



On 10 mar, 15:26, Gilles <[email protected]> wrote:
> We are using GWT andOpenLayersin several projects making use of theJSNI.
> Until now we could use simpleOpenlayersjs function such as Zoom. It
> was clear to me that to use a zoom usingJSNII have to do :
>
>  private static native void _zoomTo(JavaScriptObject map, int
> zoomLevel) /*-{
>         map.zoomTo(zoomLevel);
>     }-*/;
>
> I could do a lot with this simple methods. But now, as complexity is
> increasing I would need to use more complex feature ofOpenlayers.
> For example what would be the smartest way to apply those settings to
> my map so I can detect double click and get the event to my gwt
> application :
>
>        <script src="../OpenLayers.js"></script>
>         <script type="text/javascript">
>            OpenLayers.Control.Click =OpenLayers.Class
> (OpenLayers.Control, {
>                 defaultHandlerOptions: {
>                     'single': false,
>                     'double': true,
>                     'pixelTolerance': 0,
>                     'stopSingle': false,
>                     'stopDouble': false
>                 },
>
>                 initialize: function(options) {
>                     this.handlerOptions =OpenLayers.Util.extend(
>                         {}, this.defaultHandlerOptions
>                     );
>                    OpenLayers.Control.prototype.initialize.apply(
>                         this, arguments
>                     );
>                     this.handler = newOpenLayers.Handler.Click(
>                         this, {
>                             'click': this.trigger
>                         }, this.handlerOptions
>                     );
>                 },
>
>                 trigger: function(e) {
>                     var lonlat = map.getLonLatFromViewPortPx(e.xy);
>                     alert("You clicked near " + lonlat.lat + " N, " +
>                                               + lonlat.lon + " E");
>                 }
>
>             });
>
>            var map;
>
>             function init(){
>                 map = newOpenLayers.Map('map');
>
>                 var click = newOpenLayers.Control.Click();
>                 map.addControl(click);
>             }
>         </script>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to