Saturday, February 4, 2017

Method gives a different result than Javascript after wrapping it using JsInterop.

Hello, 

I am experiencing a weird behavior from JsInterop in this project: gwty-leaflet. The Map class has a zoomIn(Number delta) method that is supposed to zoom in the map with the specified delta. This method works fine in javascript: 

var mymap = L.map('map', {
         
    center
: [51.505, -0.09],
    zoom
: 13,
    minZoom
: 5,
    maxZoom
: 400
       
}
     
);

      console
.log(mymap.getZoom());
      console
.log(mymap.getMinZoom());
      console
.log(mymap.getMaxZoom());


      mymap
.zoomIn(20);

     
// Give 33
      console
.log("after zoom" + mymap.getZoom());

However, in the JsInterop version the result is different, and after using zoomIn() with any delta, the zoom jumps directly to the maxZoom value which is odd: 

LeafletResources.whenReady(
 e
->
             
{  
 
//Map options required values: center point, zoom, and a min zoom
   
MapOptions options = new MapOptions.Builder(L.latLng(51.505, -0.09), 13, 5)
                           
.maxZoom(400).build();
 
 
final Map map = L.map("map", options);
 
 
//Same as javascript
 GWT
.log(map.getZoom());
 GWT
.log(map.getMinZoom());
 GWT
.log(map.getMaxZoom());
     
 map
.zoomIn(33, null);


 
// result is 400 -> jumps straight to maxZoom
 GWT
.log("after zoom"+map.getZoom());
});

The same thing happens with the Transformation class. 


Any help is much appreciated. 

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment