Hi,
You can define an interface like :
package myPackage;
interface GetUrlCallback{
String getUrl(Bounds bounds);
}
and change the method TMSOptions#setGetURL() to accept a GetUrlCallback
parameter :
public native void setGetURL(GetUrlCallback callback)/*-{
this.getURL = function(bounds){return [email protected]
::getUrl(LmyPackage/Bounds;)(bounds);};
}-*/
This should work.
Alexandre.
2011/9/6 Fabe <[email protected]>
> Hi,
>
> I want to write JSNI method that can pass a Java function as
> parameter, but that function will not be used by me, but by the
> underlying API (OpenLayers in my case).
>
> "Full" JavaScript example:
> var tms = OpenLayers.Layer.TMS('My TMS Layer', '', {
> serviceVersion: '.',
> layername: 'dir1/dir2',
> type: 'png',
> getURL: overlay_getTileURL, // This function will be called each
> time the user moves or zooms on the map
> isBaseLayer: true,
> visibility:false
> });
> map.addLayer(tms);
>
> function overlay_getTileURL(bounds) {
> // my code
> // return URL (string)
> }
>
>
> I have a very complete wrapper for the TMS and Bounds objects, so I
> can write in Java:
> TMSOptions myTmsOptions = new TMSOptions();
> TMS tms = new TMS("My TMS Layer", "", myTmsOptions);
> map.addLayer(tms);
>
> What I want to do now is something like this in Java:
> myTmsOptions.setGetURL("overlayGetTileUrl);
>
> // Can be in any class, in any package
> public String overlayGetTileUrl(Bounds bounds) {
> String url = "";
> // build a string url
> return url;
> }
>
> I've looked in the documentation but only found how to call a Java
> function for which I already know the name (and the package's name).
> I've searched a little in that forum but didn't find something looking
> like this.
>
> Is that possible ? If yes, how ?
>
> --
> 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.
>
>
--
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.