Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge pull-request #30 in master into devel #31

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ modification, are permitted provided that the following conditions are met:
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the <organization> nor the
* Neither the name of DISCO Open Source Foundation nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Following parts of Leaflet API are implemented:

###<a href="gwt-leaflet/tree/master/src/gwtl-label">Label Module (GWT)</a>###

**Dependency**: Leaflet.label [master/f41dabbd6af7b1c156f055d3c6ee974fb683b918d](https://github.com/igieon/Leaflet.label/commit/f41dabbd6af7b1c156f055d3c6ee974fb683b918d) (git)
**Dependency**: Leaflet.label [master/3c13acff459c36a222e9fdefd718af95396a0a9f](https://github.com/igieon/Leaflet.label/commit/3c13acff459c36a222e9fdefd718af95396a0a9f) (git)

+ Leaflet label - Simple label plugin for Leaflet ([Leaflet.label](https://github.com/igieon/Leaflet.label))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@
*/
public class Control extends IControl {

/**
* The position of the control (one of the map corners).
*/
public static final String POSITION = "position";

protected Control(JSObject element) {
super(element);
}

/**
* Default constructor
* Custom constructor
* @param options
*/
public Control(Options options) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ public static native String getPosition(JSObject self) /*-{
}-*/;


public static native JSObject setPosition(JSObject self,String position) /*-{
public static native void setPosition(JSObject self,String position) /*-{
self.setPosition(position);
}-*/;

public static native JSObject addTo(JSObject self, JSObject map)/*-{
return self.addTo(map);
public static native void addTo(JSObject self, JSObject map)/*-{
self.addTo(map);
}-*/;

public static native JSObject removeFrom(JSObject self,JSObject map) /*-{
self.removeFrom(map);
public static native void removeFrom(JSObject self, JSObject map) /*-{
self.removeFrom(map);
}-*/;

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@
public class ControlOptions extends Options {

public ControlOptions() {
super();
super();
}

public ControlOptions(String position) {
super();
setPosition(position);
}

public ControlOptions setPosition(String position) {
return (ControlOptions)setProperty("position", position);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,36 +48,58 @@ protected IControl(JSObject jsObject) {
/**
* <b>Add control to given {@link Map} instance</b>.
* <p>
* Should contain code that creates all the necessary {@link DOM} elements for the control,
* adds listeners on relevant map events, and returns the element containing the control.
* <p>
* Called on {@link Map#addControl(ILControl)} or control.addTo(map).
* </p>
* @param map - {@link Map} instance
* @return {@link Element}
* @see #onAdd(JavaScriptObject)
*/
public final Element onAdd(Map map) {
return onAdd(map.getJSObject());
}

/**
* JSNI Callback invoked when this is added to given map.
* <p>
* This callback is activated by {@link IControlImpl#onAdd(Control, JSObject)}
* <p>
* Should contain code that creates all the necessary {@link DOM} elements for the control,
* adds listeners on relevant map events, and returns the element containing the control.
* <p>
* <b>Note</b>: Default implementation forwards to JSNI implementation,
* making this a wrapper around a third-party implementation.
* <p>
* @return {@link Element}
*/
protected Element onAdd(JavaScriptObject map) {
return IControlImpl.onAdd(getJSObject(), map);
}

/**
* <b>Remove control from given {@link Map} instance (optional)</b>
* <p>
* Should contain all clean up code (removes control's event listeners etc).
*
* Called on map.removeControl(control) or control.removeFrom(map).
* The control's DOM container is removed automatically.
*
* @param map -
*/
public final IControl onRemove(Map map) {
return onRemove(map.getJSObject());
}

/**
* JSNI callback invoked when this is removed to given map.
* <p>
* This callback is activated by {@link IControlImpl#onRemove(Control, JSObject)}
* <p>
* Should contain all clean up code (removes control's event listeners etc).
* The control's DOM container is removed automatically.
* <p>
* <b>Note</b>: Default implementation forwards to JSNI implementation,
* making this a wrapper around a third-party implementation.
*
* @param map
* @return
*/
protected IControl onRemove(JavaScriptObject map) {
IControlImpl.onRemove(getJSObject(), map);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,31 +44,41 @@ public Attribution(AttributionOptions options) {
}

public Attribution(String text, AttributionOptions options) {
super(AttributionImpl.create(text, options.getJSObject()));
super(AttributionImpl.create(text, options.getJSObject()));
}


/**
* Get the string before the attributions ("Powered by Leaflet" by default).
*/
public String getPrefix() {
return AttributionImpl.getPrefix(getJSObject());
}

/**
* Sets the string before the attributions ("Powered by Leaflet" by default).
* @param text - {@link Attribution} prefix.
*/
void setPrefix(String text) {
public Attribution setPrefix(String text) {
AttributionImpl.setPrefix(getJSObject(), text);
return this;
}

/**
* Adds an attribution text (e.g. "Vector data &copy; CloudMade").
* @param text - {@link Attribution} text.
*/
void addAttribution(String text) {
public Attribution addAttribution(String text) {
AttributionImpl.addAttribution(getJSObject(), text);
return this;
}

/**
* Removes an attribution text.
* @param text - {@link Attribution} text.
*/
void removeAttribution(String text) {
public Attribution removeAttribution(String text) {
AttributionImpl.removeAttribution(getJSObject(), text);
return this;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@ public static native JSObject create(String text, JSObject options) /*-{
return a;
}-*/;

public static native void setPrefix(JSObject self, String text) /*-{
return self.setPrefix(text);
public static native String getPrefix(JSObject self) /*-{
return self.options.prefix;
}-*/;

public static native void setPrefix(JSObject self, String text) /*-{
self.setPrefix(text);
}-*/;

public static native void addAttribution(JSObject self, String text) /*-{
return self.addAttribution(text);
self.addAttribution(text);
}-*/;

public static native void removeAttribution(JSObject self, String text) /*-{
return self.addAttribution(text);
self.removeAttribution(text);
}-*/;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ public class AttributionOptions extends ControlOptions {
public AttributionOptions() {
super();
}

public AttributionOptions(String prefix, String position) {
super();
setPrefix(prefix);
setPosition(position);
}


/**
* The position of the control (one of the map corners).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public LayerGroup(String alias, ILayer[] layers) {
*
*/
public LayerGroup addLayer(ILayer layer) {
LayerGroupImpl.addTo(getJSObject(), layer.getJSObject());
LayerGroupImpl.addLayer(getJSObject(), layer.getJSObject());
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import org.discotools.gwt.leaflet.client.types.LatLngBounds;
import org.discotools.gwt.leaflet.client.types.Point;

import com.google.gwt.dom.client.Element;

/**
* The central class of the API — it is used to create a map on a page and manipulate it.
*
Expand All @@ -26,10 +28,25 @@ protected Map(JSObject e) {
super(e);
}

public Map(String name) {
this(name, new MapOptions());
}

public Map(String name, MapOptions options) {
this(MapImpl.create(name, options.getJSObject()));
}

/**
* Sets the view of the map (geographical center and zoom).
* <p>
* If 'reset' is set to <code>true</code>, the map is reloaded
* even if it's eligible for pan or zoom animation (false by default).
*
* @param center - {@link LatLng} instance
* @param zoom - Map zoom
* @param reset - Force reset of map
* @return {@link Map}
*/
public Map setView(LatLng center, double zoom, boolean reset) {
MapImpl.setView(getJSObject(), center.getJSObject(), zoom, reset);
return this;
Expand Down Expand Up @@ -60,11 +77,27 @@ public Map addLayer(ILayer layer) {
return this;
}

/**
* Adds the given control to the map.
* @param control - {@link IControl} instance
* @return {@link Map}
*/
public Map addControl(IControl control) {
MapImpl.addControl(getJSObject(), control.getJSObject());
return this;
}

/**
* Removes the given control from the map.
* @param control
* @return {@link Map}
*/
public Map removeControl(IControl control) {
MapImpl.removeControl(getJSObject(), control.getJSObject());
return this;
}


public Map fitBounds(LatLngBounds bounds) {
MapImpl.fitBounds(getJSObject(), bounds.getJSObject());
return this;
Expand Down Expand Up @@ -146,4 +179,22 @@ public Map invalidateSize(boolean animate){
MapImpl.invalidateSize(getJSObject(),animate);
return this;
}

/**
*
* @return Returns the container element of the map.
*/
public Element getContainer() {
return MapImpl.getContainer(getJSObject());
}

/**
* Pans the map to the closest view that would lie inside the given bounds (if it's not already).
* @param bounds
* @return
*/
public Map panInsideBounds(LatLngBounds bounds) {
MapImpl.panInsideBounds(getJSObject(),bounds.getJSObject());
return this;
}
}
Loading