Skip to content

Commit

Permalink
mstahv#220 - add tileSize option to gridLayer
Browse files Browse the repository at this point in the history
  • Loading branch information
dve committed Aug 13, 2021
1 parent 4814c36 commit 9bf6997
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 9 deletions.
13 changes: 12 additions & 1 deletion src/main/java/org/vaadin/addon/leaflet/LGridLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public void onLoading() {
});
}

protected LeafletGridLayerState getState() {
@Override
protected LeafletGridLayerState getState() {
return (LeafletGridLayerState) super.getState();
}

Expand Down Expand Up @@ -83,6 +84,16 @@ public Bounds getBounds() {
return getState().bounds;
}

public void setTileSize(int tileSize)
{
getState().tileSize = tileSize;
}

public int getTileSize()
{
return getState().tileSize;
}

@Override
public Geometry getGeometry() {
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
package org.vaadin.addon.leaflet.client;

import com.vaadin.client.communication.RpcProxy;
import com.vaadin.shared.ui.Connect;
import org.peimari.gleaflet.client.*;
import org.peimari.gleaflet.client.Event;
import org.peimari.gleaflet.client.GridLayer;
import org.peimari.gleaflet.client.GridLayerOptions;
import org.peimari.gleaflet.client.LatLng;
import org.peimari.gleaflet.client.LatLngBounds;
import org.peimari.gleaflet.client.Layer;
import org.peimari.gleaflet.client.LoadListener;
import org.peimari.gleaflet.client.LoadingListener;
import org.vaadin.addon.leaflet.shared.EventId;
import org.vaadin.addon.leaflet.shared.LeafletGridLayerServerRpc;
import org.vaadin.addon.leaflet.shared.LeafletGridLayerState;

import com.vaadin.client.communication.RpcProxy;
import com.vaadin.shared.ui.Connect;

@Connect(org.vaadin.addon.leaflet.LGridLayer.class)
public class LeafletGridLayerConnector extends AbstractLeafletLayerConnector<GridLayerOptions> {

protected Layer layer;
protected LeafletGridLayerServerRpc gridLayerServerRpc = RpcProxy.create(LeafletGridLayerServerRpc.class, this);

public LeafletGridLayerState getState() {
@Override
public LeafletGridLayerState getState() {
return (LeafletGridLayerState) super.getState();
}

Expand Down Expand Up @@ -44,6 +53,10 @@ protected GridLayerOptions createOptions() {
o.setBounds(LatLngBounds.create(LatLng.create(s.bounds.getSouthWestLat(), s.bounds.getSouthWestLon()),
LatLng.create(s.bounds.getNorthEastLat(), s.bounds.getNorthEastLon())));
}
if (s.tileSize != null)
{
o.setTileSize(s.tileSize);
}
return o;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ public class LeafletGridLayerState extends AbstractLeafletComponentState {
public Integer minNativeZoom;
public Boolean noWrap;
public String attributionString;
public Integer tileSize;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@
import java.util.ArrayList;
import java.util.Arrays;

import org.vaadin.addon.leaflet.*;
import org.vaadin.addon.leaflet.LLayerGroup;
import org.vaadin.addon.leaflet.LMap;
import org.vaadin.addon.leaflet.LTileLayer;
import org.vaadin.addon.leaflet.LWmsLayer;
import org.vaadin.addon.leaflet.LeafletLoadEvent;
import org.vaadin.addon.leaflet.LeafletLoadListener;
import org.vaadin.addon.leaflet.LeafletLoadingEvent;
import org.vaadin.addon.leaflet.LeafletLoadingListener;
import org.vaadin.addon.leaflet.shared.Control;
import org.vaadin.addonhelpers.AbstractTest;

import com.vaadin.ui.*;
import com.vaadin.ui.Component;
import com.vaadin.ui.Notification;
import com.vaadin.ui.Notification.Type;
import org.vaadin.addonhelpers.AbstractTest;

public class LayersTest extends AbstractTest {

Expand Down Expand Up @@ -93,7 +101,7 @@ public void onLoading(LeafletLoadingEvent event)
Notification.show("onLoanding", Type.TRAY_NOTIFICATION);
}
});

leafletMap.addOverlay(groupAreas,"Populated Areas & Water");
leafletMap.addOverlay(layerWmsStreets, "Streets");
leafletMap.addOverlay(layerWmsAbiesAlbaGermany, "Distribution of Abies Alba in Germany");
Expand Down

0 comments on commit 9bf6997

Please sign in to comment.