Skip to content

Commit

Permalink
Try to add listener for load and loading events to tile layer (not
Browse files Browse the repository at this point in the history
working yet)
  • Loading branch information
dve committed Jul 24, 2014
1 parent bb930e5 commit 2c92719
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/org/peimari/gleaflet/client/LoadListener.java
@@ -0,0 +1,6 @@
package org.peimari.gleaflet.client;

public interface LoadListener
{
void onLoad(Event event);
}
@@ -0,0 +1,6 @@
package org.peimari.gleaflet.client;

public interface LoadingListener
{
void onLoading(Event event);
}
51 changes: 51 additions & 0 deletions src/main/java/org/peimari/gleaflet/client/TileLayer.java
Expand Up @@ -20,4 +20,55 @@ public native final void bringToBack()
/*-{
this.bringToBack();
}-*/;

/**
* Adds load listener to the layer.
* <p>
* The listeners are called when all visible tiles are loaded.
* @param listener
* @return a handle that can be used to remove this specific listener from
* the map
* @see {@link http://leafletjs.com/reference.html#tilelayer-load}
*/
public native final JavaScriptObject addLoadListener(LoadListener listener)
/*-{
var fn = function(e) {
$entry(listener.@org.peimari.gleaflet.client.LoadListener::onLoad(Lorg/peimari/gleaflet/client/Event;)(e));
}
fn.prototype['gname'] = "load";
this.on(fn.prototype['gname'], fn);
return fn;
}-*/;

/**
* Adds loading listener to the layer.
* <p>
* The listeners are called when the tile layer starts loading tiles.
* @param listener
* @return a handle that can be used to remove this specific listener from
* the map
* @see {@link http://leafletjs.com/reference.html#tilelayer-loading}
*/
public native final JavaScriptObject addLoadingListener(LoadingListener listener)
/*-{
var fn = function(e) {
$entry(listener.@org.peimari.gleaflet.client.LoadingListener::onLoading(Lorg/peimari/gleaflet/client/Event;)(e));
}
fn.prototype['gname'] = "loading";
this.on(fn.prototype['gname'], fn);
return fn;
}-*/;

/**
* Removes listener from layer. The listener is detected on listener
* registration object returned by listener addition method.
*
* @param listenerRegistration
* the object returned by listener addition method
*/
public native final void removeListener(
JavaScriptObject listenerRegistration)
/*-{
this.off(listenerRegistration.prototype.gname, listenerRegistration);
}-*/;
}

0 comments on commit 2c92719

Please sign in to comment.