Skip to content

Commit

Permalink
Merge pull request wicketstuff#606 from ageery/openlayers3_enhancements
Browse files Browse the repository at this point in the history
This looks good, thank you for your contribution!
  • Loading branch information
cmiles74 authored Aug 7, 2017
2 parents 5900a52 + 24a454e commit 569ad1a
Show file tree
Hide file tree
Showing 33 changed files with 2,766 additions and 2,482 deletions.

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions openlayers3-parent/openlayers3-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@
<artifactId>wicketstuff-annotation</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>de.agilecoders.wicket</groupId>
<artifactId>wicket-bootstrap-extensions</artifactId>
<version>0.10.0</version>
</dependency>

<!-- LOGGING DEPENDENCIES - LOG4J -->
<dependency>
Expand All @@ -55,6 +60,10 @@
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</dependency>

<!-- JUNIT DEPENDENCY FOR TESTING -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package org.wicketstuff.openlayers3.examples;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import java.util.Arrays;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.model.Model;
import org.apache.wicket.util.string.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.wicketstuff.annotation.mount.MountPath;
import org.wicketstuff.openlayers3.DefaultOpenLayersMap;
import org.wicketstuff.openlayers3.OpenLayersMap;
Expand All @@ -21,27 +17,32 @@
import org.wicketstuff.openlayers3.api.layer.Vector;
import org.wicketstuff.openlayers3.api.overlay.Overlay;
import org.wicketstuff.openlayers3.api.proj.Projection;
import org.wicketstuff.openlayers3.api.source.vector.Cluster;
import org.wicketstuff.openlayers3.api.source.tile.Osm;
import org.wicketstuff.openlayers3.api.source.vector.Cluster;
import org.wicketstuff.openlayers3.api.source.vector.VectorSource;
import org.wicketstuff.openlayers3.api.source.vector.loader.DefaultGeoJsonLoader;
import org.wicketstuff.openlayers3.api.style.*;
import org.wicketstuff.openlayers3.api.style.Circle;
import org.wicketstuff.openlayers3.api.style.ClusterStyle;
import org.wicketstuff.openlayers3.api.style.Fill;
import org.wicketstuff.openlayers3.api.style.Stroke;
import org.wicketstuff.openlayers3.api.style.Text;
import org.wicketstuff.openlayers3.api.util.Color;
import org.wicketstuff.openlayers3.behavior.ClickFeatureHandler;
import org.wicketstuff.openlayers3.component.MarkerPopover;
import org.wicketstuff.openlayers3.component.PopoverPanel;
import org.wicketstuff.openlayers3.examples.base.BasePage;

import java.util.Arrays;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;

/**
* Provides a page demonstrating clustered data.
*/
@MountPath("/cluster")
public class ClusterPage extends BasePage {

private final static Logger logger = LoggerFactory.getLogger(ClusterPage.class);

/**
* Popover for providing detail on markers.
*/
Expand All @@ -57,11 +58,6 @@ public class ClusterPage extends BasePage {
*/
private MarkerPopover markerPopover;

/**
* Layer with our clusters of features.
*/
private Vector cluster;

@Override
protected void onInitialize() {
super.onInitialize();
Expand Down Expand Up @@ -97,7 +93,7 @@ protected void onInitialize() {
new Osm()),

// add our vector layer for the clusters
cluster = new Vector(
new Vector(

// our cluster data source
new Cluster(new GeoJsonFormat(), new Projection("EPSG:3857", "degrees", "nue"),
Expand Down Expand Up @@ -209,7 +205,6 @@ public void handleClick(AjaxRequestTarget target, String featureId, LongLat long

// parse out constructed and architecture
String constructed = parseField(featureThis, "CONSTRUCTI");
String architecture = parseField(featureThis, "ARCHITECTU");

// assemble our description
StringBuilder description = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@
<div class="col-md-12">

<p>Below is a map of the world. This map centered on the location of Miles' office and provides a
helpful marker to ensure that you don't miss it.</p>
helpful marker to ensure that you don't miss it. Use the layer drop-down to toggle between
the street layer and the satellite layer.</p>

<div>
<form wicket:id="form">
<div wicket:id="layer">
<select wicket:id="layerSelector"></select>
</div>
</form>
</div>

<div wicket:id="marker">[MARKER]</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
package org.wicketstuff.openlayers3.examples;

import java.util.Arrays;
import java.util.Collection;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.markup.html.form.EnumChoiceRenderer;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.model.Model;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.wicket.model.util.ListModel;
import org.wicketstuff.annotation.mount.MountPath;
import org.wicketstuff.openlayers3.DefaultOpenLayersMap;
import org.wicketstuff.openlayers3.api.Map;
Expand All @@ -12,46 +20,92 @@
import org.wicketstuff.openlayers3.api.layer.Tile;
import org.wicketstuff.openlayers3.api.overlay.Overlay;
import org.wicketstuff.openlayers3.api.source.tile.Osm;
import org.wicketstuff.openlayers3.api.source.tile.TileArcGISRest;
import org.wicketstuff.openlayers3.api.source.tile.XYZ;
import org.wicketstuff.openlayers3.api.util.Color;
import org.wicketstuff.openlayers3.component.Marker;
import org.wicketstuff.openlayers3.examples.base.BasePage;

import java.util.Arrays;
import de.agilecoders.wicket.core.markup.html.bootstrap.form.BootstrapForm;
import de.agilecoders.wicket.core.markup.html.bootstrap.form.FormGroup;
import de.agilecoders.wicket.extensions.markup.html.bootstrap.form.select.BootstrapSelect;

/**
* Provides a page with a mpa that includes a marker.
*/
@MountPath("/marker")
public class MarkerPage extends BasePage {

private final static Logger logger = LoggerFactory.getLogger(MarkerPage.class);
private static final String MA_ORTHO_URL = "http://tiles.arcgis.com/tiles/hGdibHYSPO59RG1h/arcgis/rest/services/USGS_Orthos_2013_2014/MapServer/tile/{z}/{y}/{x}";
private static final String MA_OPEN_SPACE_URL = "http://gisprpxy.itd.state.ma.us/arcgisserver/rest/services/AGOL/OpenSpaceLevProt/MapServer";

private enum LayerOption {
STREET,
SATELLITE,
OPEN_SPACE;
}

/**
* Marker over Miles' office.
*/
private Marker marker;
private static class LayerSelectedModel extends LoadableDetachableModel<Boolean> {

@Override
protected void onInitialize() {
super.onInitialize();
private IModel<LayerOption> model;
private Collection<LayerOption> layerOption;

// create and add our marker
add(marker = new Marker("marker", Model.of(new Color("#4169E1"))));
public LayerSelectedModel(IModel<LayerOption> model, LayerOption... layerOption) {
this.model = model;
this.layerOption = Arrays.asList(layerOption);
}

@Override
protected Boolean load() {
return layerOption.contains(model.getObject());
}

}

public MarkerPage() {
super();

// model of the selected layer
final IModel<LayerOption> model = Model.of(LayerOption.STREET);

// create and add our marker over Miles' office
Marker marker = new Marker("marker", Model.of(new Color("#4169E1")));
add(marker);

// create and add our marker
add(new DefaultOpenLayersMap("map",
final DefaultOpenLayersMap map = new DefaultOpenLayersMap("map",

// create the model for our map
Model.of(new Map(

// list of layers
Arrays.<Layer>asList(

// a new tile layer with the map of the world
// a new tile layer with the street map of Noho
new Tile("Streets",

// a new web map service tile layer
new Osm())),
new Osm(),
// visible when the layer selector is street
new LayerSelectedModel(model, LayerOption.STREET)),

// a new tile layer with the satellite map of Noho
new Tile("Ortho",

// MA ortho-imagery layer
new XYZ().setUrl(MA_ORTHO_URL),
// visible when the layer selector is satellite or open space
new LayerSelectedModel(model, LayerOption.OPEN_SPACE, LayerOption.SATELLITE)),

// a new tile layer with the open space map of Noho
new Tile("Open Space",

// MA open space layer
new TileArcGISRest().setUrl(MA_OPEN_SPACE_URL),
// visible when the layer selector is open space
new LayerSelectedModel(model, LayerOption.OPEN_SPACE))
// fractional opacity so we can see the base map underneath
.setOpacityModel(Model.of(.5))),

// list of overlays
Arrays.<Overlay>asList(
Expand All @@ -73,6 +127,28 @@ protected void onInitialize() {
new LongLat(-72.638382, 42.313181, "EPSG:4326").transform(View.DEFAULT_PROJECTION),

// zoom level for the view
16)))));
16))));
add(map);

// form for changing the layer
Form<LayerOption> form = new BootstrapForm<>("form", model);
add(form);

// layer selector -- refresh the map's layers on change
form.add(new FormGroup("layer")
.add(new BootstrapSelect<>("layerSelector", model,
new ListModel<>(Arrays.asList(LayerOption.values())),
new EnumChoiceRenderer<LayerOption>())
.setLabel(Model.of("Layer"))
.add(new AjaxFormComponentUpdatingBehavior("change") {

@Override
protected void onUpdate(AjaxRequestTarget target) {
map.updateLayers(target);
}

})));

}

}
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package org.wicketstuff.openlayers3.examples;

import com.google.gson.JsonObject;
import java.util.Arrays;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.model.Model;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.wicketstuff.annotation.mount.MountPath;
import org.wicketstuff.openlayers3.DefaultOpenLayersMap;
import org.wicketstuff.openlayers3.OpenLayersMap;
Expand All @@ -28,24 +27,16 @@
import org.wicketstuff.openlayers3.api.style.Style;
import org.wicketstuff.openlayers3.api.util.CorsPolicy;
import org.wicketstuff.openlayers3.behavior.FeatureChangeListener;
import org.wicketstuff.openlayers3.component.Marker;
import org.wicketstuff.openlayers3.examples.base.BasePage;

import java.util.Arrays;
import com.google.gson.JsonObject;

/**
* Provides a page with a mpa that includes a marker.
*/
@MountPath("/modify")
public class ModifyPage extends BasePage {

private final static Logger logger = LoggerFactory.getLogger(MarkerPage.class);

/**
* Marker over Miles' office.
*/
private Marker marker;

/**
* Map in view.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.wicketstuff.openlayers3.examples;

import com.google.common.collect.ImmutableMap;
import java.util.Arrays;

import org.apache.wicket.model.Model;
import org.wicketstuff.annotation.mount.MountPath;
import org.wicketstuff.openlayers3.DefaultOpenLayersMap;
Expand All @@ -10,11 +11,8 @@
import org.wicketstuff.openlayers3.api.layer.Layer;
import org.wicketstuff.openlayers3.api.layer.Tile;
import org.wicketstuff.openlayers3.api.source.tile.Osm;
import org.wicketstuff.openlayers3.api.source.tile.TileWms;
import org.wicketstuff.openlayers3.examples.base.BasePage;

import java.util.Arrays;

/**
* Provides a simple map with one layer.
*/
Expand Down
Loading

0 comments on commit 569ad1a

Please sign in to comment.