├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── autoDeploy └── settings.xml ├── pom.xml └── src ├── main └── java │ └── com │ └── gwidgets │ └── api │ ├── GwtyLeaflet.gwt.xml │ ├── leaflet │ ├── Attribution.java │ ├── Bounds.java │ ├── CRS.java │ ├── Canvas.java │ ├── Circle.java │ ├── CircleMarker.java │ ├── Control.java │ ├── DivIcon.java │ ├── DivOverlay.java │ ├── Evented.java │ ├── FeatureGroup.java │ ├── GeoJSON.java │ ├── GridLayer.java │ ├── Handler.java │ ├── Icon.java │ ├── ImageOverlay.java │ ├── L.java │ ├── LatLng.java │ ├── LatLngBounds.java │ ├── Layer.java │ ├── LayerGroup.java │ ├── Layers.java │ ├── Map.java │ ├── MapPanes.java │ ├── Marker.java │ ├── Path.java │ ├── Point.java │ ├── Polygon.java │ ├── Polyline.java │ ├── Popup.java │ ├── Projection.java │ ├── Rectangle.java │ ├── Renderer.java │ ├── SVG.java │ ├── Scale.java │ ├── TileLayer.java │ ├── Tooltip.java │ ├── WMS.java │ ├── Zoom.java │ ├── events │ │ ├── DragEndEvent.java │ │ ├── ErrorEvent.java │ │ ├── Event.java │ │ ├── EventCallback.java │ │ ├── EventTypes.java │ │ ├── GeoJSONEvent.java │ │ ├── KeyboardEvent.java │ │ ├── LayerEvent.java │ │ ├── LayersControlEvent.java │ │ ├── LocationEvent.java │ │ ├── MouseEvent.java │ │ ├── PopupEvent.java │ │ ├── ResizeEvent.java │ │ ├── TileErrorEvent.java │ │ ├── TileEvent.java │ │ └── TooltipEvent.java │ ├── options │ │ ├── CircleOptions.java │ │ ├── ControlAttributionOptions.java │ │ ├── ControlLayersOptions.java │ │ ├── ControlOptions.java │ │ ├── ControlScaleOptions.java │ │ ├── ControlZoomOptions.java │ │ ├── DivIconOptions.java │ │ ├── FitBoundsOptions.java │ │ ├── GeoJSONOptions.java │ │ ├── GridLayerOptions.java │ │ ├── IconOptions.java │ │ ├── ImageOverlayOptions.java │ │ ├── LocateOptions.java │ │ ├── MapOptions.java │ │ ├── MarkerOptions.java │ │ ├── PanOptions.java │ │ ├── PathOptions.java │ │ ├── PolylineOptions.java │ │ ├── PopupOptions.java │ │ ├── RendererOptions.java │ │ ├── TileLayerOptions.java │ │ ├── TileLayerWMSOptions.java │ │ ├── TooltipOptions.java │ │ ├── ZoomOptions.java │ │ └── ZoomPanOptions.java │ └── utils │ │ ├── JsFn.java │ │ └── LeafletResources.java │ └── public │ └── leaflet │ ├── images │ ├── layers-2x.png │ ├── layers.png │ ├── marker-icon-2x.png │ ├── marker-icon.png │ └── marker-shadow.png │ ├── leaflet-src.js │ ├── leaflet-src.map │ ├── leaflet.css │ └── leaflet.js └── test └── java └── com └── gwidgets └── leaflet ├── GwtyLeafletTest.gwt.xml └── test ├── CRSTest.java ├── EventTest.java ├── GwtyLeafletTestCase.java ├── GwtyLeafletTestSuite.java ├── InjectedLeafletResources.java ├── MapTest.java ├── MarkerTest.java ├── PathTest.java ├── ProjectionTest.java ├── TransformationTest.java └── VersionTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | dependency-reduced-pom.xml 3 | .settings 4 | .classpath 5 | .project 6 | 7 | bin/ 8 | 9 | maven-sign-and-deploy.bat 10 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: 3 | - oraclejdk8 4 | 5 | after_success: 6 | - mvn -s autoDeploy/settings.xml deploy -Dmaven.test.skip=true 7 | 8 | -------------------------------------------------------------------------------- /autoDeploy/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ossrh 5 | ${env.CI_DEPLOY_USERNAME} 6 | ${env.CI_DEPLOY_PASSWORD} 7 | 8 | 9 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | com.gwidgets 5 | gwty-leaflet 6 | 1.1.1 7 | gwt-lib 8 | 9 | 10 | 2.8.2 11 | 1.0.0-RC1 12 | 1.8 13 | 1.8 14 | 15 | 16 | 17 | 18 | Zakaria Amine 19 | zamine 20 | zakaria.amine88@gmail.com 21 | G-Widgets 22 | 23 | 24 | 25 | 26 | 27 | The Apache License, Version 2.0 28 | http://www.apache.org/licenses/LICENSE-2.0.txt 29 | 30 | 31 | 32 | 33 | scm:git:git@github.com:zak905/gwty-leaflet.git 34 | scm:git:git@github.com:zak905/gwty-leaflet.git 35 | git@github.com:zak905/gwty-leaflet.git 36 | 37 | 38 | 39 | 40 | com.google.gwt 41 | gwt-user 42 | ${gwtVersion} 43 | provided 44 | 45 | 46 | com.google.gwt 47 | gwt-dev 48 | ${gwtVersion} 49 | test 50 | 51 | 52 | com.google.elemental2 53 | elemental2-core 54 | ${elementalVersion} 55 | 56 | 57 | com.google.elemental2 58 | elemental2-dom 59 | ${elementalVersion} 60 | 61 | 62 | com.google.elemental2 63 | elemental2-svg 64 | ${elementalVersion} 65 | 66 | 67 | junit 68 | junit 69 | 4.13.1 70 | test 71 | 72 | 73 | 74 | 75 | 76 | 77 | src/main/java 78 | true 79 | 80 | 81 | 82 | 83 | net.ltgt.gwt.maven 84 | gwt-maven-plugin 85 | 1.0.0 86 | true 87 | 88 | com.gwidgets.api.GwtyLeaflet 89 | 90 | 91 | 92 | org.apache.maven.plugins 93 | maven-jar-plugin 94 | 3.0.1 95 | 96 | 97 | org.apache.maven.plugins 98 | maven-gpg-plugin 99 | 3.0.1 100 | 101 | 102 | sign-artifacts 103 | verify 104 | 105 | sign 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | org.apache.maven.plugins 115 | maven-source-plugin 116 | 3.2.0 117 | 118 | 119 | attach-sources 120 | package 121 | 122 | jar-no-fork 123 | 124 | 125 | 126 | 127 | 128 | org.apache.maven.plugins 129 | maven-javadoc-plugin 130 | 3.3.1 131 | 132 | false 133 | false 134 | 135 | 136 | 137 | attach-sources 138 | package 139 | 140 | jar 141 | 142 | 143 | 144 | 145 | 146 | 147 | gwty-leaflet 148 | 149 | a JsInterop wrapper for the Leaflet js library 150 | 151 | 152 | G-Widgets 153 | http://www.g-widgets.com/ 154 | 155 | 156 | 157 | 158 | ossrh 159 | https://oss.sonatype.org/content/repositories/snapshots 160 | 161 | 162 | ossrh 163 | https://oss.sonatype.org/service/local/staging/deploy/maven2/ 164 | 165 | 166 | 167 | 168 | 169 | release 170 | 171 | 172 | https://github.com/gwidgets/gwty-leaflet 173 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/GwtyLeaflet.gwt.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/Attribution.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet; 2 | 3 | /** 4 | * Copyright 2016 G-Widgets 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | import jsinterop.annotations.JsMethod; 18 | import jsinterop.annotations.JsType; 19 | 20 | 21 | /** 22 | * The attribution control allows you to display attribution data in a small text box on a map. It is put on the map by default unless you set its attributionControl option to false, and it fetches attribution texts from layers with getAttribution method automatically. 23 | * 24 | * @author Zakaria Amine 25 | * @version $Id: $Id 26 | */ 27 | @JsType(isNative = true) 28 | public class Attribution extends Control{ 29 | 30 | 31 | 32 | 33 | private Attribution() { 34 | 35 | } 36 | 37 | /** 38 | * Sets the text before the attributions. 39 | * 40 | * @param prefix the prefix 41 | * @return the L class 42 | */ 43 | @JsMethod 44 | public native L setPrefix(String prefix); 45 | 46 | /** 47 | * Adds an attribution text 48 | * 49 | * @param text the text 50 | * @return the L class 51 | */ 52 | @JsMethod 53 | public native L addAttribution(String text); 54 | 55 | /** 56 | * Removes an attribution text. 57 | * 58 | * @param text the text 59 | * @return the L class 60 | */ 61 | @JsMethod 62 | public native L removeAttribution(String text); 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/Bounds.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet; 2 | 3 | /** 4 | * Copyright 2016 G-Widgets 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | import jsinterop.annotations.JsMethod; 18 | import jsinterop.annotations.JsType; 19 | 20 | 21 | /** 22 | * Represents a rectangular area in pixel coordinates. 23 | * 24 | * @author Zakaria Amine 25 | * @version $Id: $Id 26 | */ 27 | @JsType(isNative = true) 28 | public class Bounds { 29 | 30 | 31 | 32 | private Bounds() { 33 | 34 | } 35 | 36 | /** 37 | * Extends the bounds to contain the given point. 38 | * 39 | * @param point the point 40 | */ 41 | @JsMethod 42 | public native void extend(Point point); 43 | 44 | /** 45 | * Returns the center point of the bounds. 46 | * 47 | * @return the center 48 | */ 49 | @JsMethod 50 | public native Point getCenter(); 51 | 52 | /** 53 | * Returns true if the rectangle contains the given one. 54 | * 55 | * @param otherBounds the bounds 56 | * @return true/false 57 | */ 58 | @JsMethod 59 | public native Boolean contains(Bounds otherBounds); 60 | 61 | /** 62 | * Returns true if the rectangle contains the given point. 63 | * 64 | * @return true/false 65 | * @param point a {@link com.gwidgets.api.leaflet.Point} object 66 | */ 67 | @JsMethod 68 | public native Boolean contains(Point point); 69 | 70 | /** 71 | * Returns true if the rectangle intersects the given bounds. 72 | * 73 | * @param otherBounds the other bounds 74 | * @return true/false 75 | */ 76 | @JsMethod 77 | public native Boolean intersects(Bounds otherBounds); 78 | 79 | /** 80 | * Returns true if the bounds are properly initialized. 81 | * 82 | * @return true/false 83 | */ 84 | @JsMethod 85 | public native Boolean isValid(); 86 | 87 | /** 88 | * Returns the size of the given bounds. 89 | * 90 | * @return the size 91 | */ 92 | @JsMethod 93 | public native Point getSize(); 94 | 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/CRS.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet; 2 | import jsinterop.annotations.JsMethod; 3 | import jsinterop.annotations.JsProperty; 4 | /** 5 | * Copyright 2016 G-Widgets 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | import jsinterop.annotations.JsType; 19 | 20 | /** 21 | * Defines coordinate reference systems for projecting geographical points into pixel (screen) coordinates and back (and to coordinates in other units for WMS services). 22 | * 23 | * @author Zakaria Amine 24 | * @version $Id: $Id 25 | */ 26 | @JsType(isNative = true) 27 | public abstract class CRS { 28 | 29 | 30 | 31 | /** Standard code name of the CRS passed into WMS services (e.g. 'EPSG:3857') */ 32 | @JsProperty 33 | public String code; 34 | 35 | /** An array of two numbers defining whether the longitude (horizontal) coordinate axis wraps around a given range and how. Defaults to [-180, 180] in most geographical CRSs. If undefined, the longitude axis does not wrap around. */ 36 | @JsProperty 37 | public double[] wrapLng; 38 | 39 | /** Like wrapLng, but for the latitude (vertical) axis. */ 40 | @JsProperty 41 | public double[] wrapLat; 42 | 43 | /** If true, the coordinate space will be unbounded (infinite in both axes) */ 44 | @JsProperty 45 | public Boolean infinite; 46 | 47 | /** 48 | * Projects geographical coordinates on a given zoom into pixel coordinates. 49 | * 50 | * @param latlng the latlng 51 | * @param zoom the zoom 52 | * @return the point 53 | */ 54 | @JsMethod 55 | public native Point latLngToPoint(LatLng latlng, double zoom); 56 | 57 | /** 58 | * The inverse of latLngToPoint. Projects pixel coordinates on a given zoom into geographical coordinates. 59 | * 60 | * @param point the point 61 | * @param zoom the zoom 62 | * @return the lat lng 63 | */ 64 | @JsMethod 65 | public native LatLng pointToLatLng(Point point, double zoom); 66 | 67 | /** 68 | * Projects geographical coordinates into coordinates in units accepted for this CRS (e.g. meters for EPSG:3857, for passing it to WMS services). 69 | * 70 | * @param latlng the latlng 71 | * @return the point 72 | */ 73 | @JsMethod 74 | public native Point project(LatLng latlng); 75 | 76 | /** 77 | * Given a projected coordinate returns the corresponding LatLng. The inverse of project. 78 | * 79 | * @param point the point 80 | * @return the latlng 81 | */ 82 | @JsMethod 83 | public native LatLng unproject(Point point); 84 | 85 | /** 86 | * Returns the scale used when transforming projected coordinates into pixel coordinates for a particular zoom. For example, it returns 256 * 2^zoom for Mercator-based CRS. 87 | * 88 | * @param zoom the zoom 89 | * @return the number 90 | */ 91 | @JsMethod 92 | public native double scale(double zoom); 93 | 94 | 95 | /** 96 | * Inverse of scale(), returns the zoom level corresponding to a scale factor of scale. 97 | * 98 | * @param scale the scale 99 | * @return the zoom level 100 | */ 101 | @JsMethod 102 | public native double zoom(double scale); 103 | 104 | /** 105 | * Returns the projection's bounds scaled and transformed for the provided zoom. 106 | * 107 | * @param zoom the zoom level 108 | * @return the bounds 109 | */ 110 | @JsMethod 111 | public native Bounds getProjectedBounds(double zoom); 112 | 113 | /** 114 | * Returns the distance between two geographical coordinates. 115 | * 116 | * @param latlng1 a {@link com.gwidgets.api.leaflet.LatLng} object 117 | * @param latlng2 a {@link com.gwidgets.api.leaflet.LatLng} object 118 | * @return the distance 119 | */ 120 | @JsMethod 121 | public native double distance(LatLng latlng1, LatLng latlng2); 122 | 123 | /** 124 | * Returns a LatLng where lat and lng has been wrapped according to the CRS's wrapLat and wrapLng properties, if they are outside the CRS's bounds. 125 | * 126 | * @param latlng a {@link com.gwidgets.api.leaflet.LatLng} object 127 | * @return the LatLng 128 | */ 129 | @JsMethod 130 | public native double wrapLatLng(LatLng latlng); 131 | 132 | } 133 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/Canvas.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet; 2 | 3 | import jsinterop.annotations.JsType; 4 | 5 | 6 | 7 | /** 8 | * Used to create Canvas-based tile layers where tiles get drawn on the browser side. 9 | * 10 | * @version $Id: $Id 11 | */ 12 | @JsType(isNative = true) 13 | public class Canvas extends Renderer { 14 | 15 | private Canvas() { 16 | 17 | } 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/Circle.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet; 2 | 3 | import jsinterop.annotations.JsType; 4 | 5 | /** 6 | * A class for drawing circle overlays on a map. Extends Path. Use addLayer method of the Map class to add it to the map. 7 | * 8 | * @author zakaria 9 | * @version $Id: $Id 10 | */ 11 | @JsType(isNative = true) 12 | public class Circle extends CircleMarker { 13 | 14 | 15 | 16 | 17 | /** 18 | *

Constructor for Circle.

19 | */ 20 | protected Circle() { 21 | super(); 22 | 23 | 24 | } 25 | 26 | 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/Control.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet; 2 | 3 | import elemental2.dom.HTMLElement; 4 | /** 5 | * Copyright 2016 G-Widgets 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | import jsinterop.annotations.JsMethod; 19 | import jsinterop.annotations.JsType; 20 | 21 | 22 | /** 23 | * The base class for all Leaflet controls. Implements IControl interface. You can add controls to the map like this: 24 | *
 25 |  *{@code control.addTo(map);
 26 |  *       // or
 27 |  *  map.addControl(control);}
 28 |  *
29 | * 30 | *@author Zakaria Amine 31 | * @version $Id: $Id 32 | */ 33 | @JsType(isNative = true) 34 | public class Control { 35 | 36 | 37 | 38 | 39 | /** 40 | *

Constructor for Control.

41 | */ 42 | protected Control() { 43 | 44 | } 45 | 46 | /** 47 | * Sets the position of the control. 48 | * 49 | * @param position the position 50 | * @return the L class 51 | */ 52 | @JsMethod 53 | public native L setPosition(String position); 54 | 55 | /** 56 | * Returns the current position of the control. 57 | * 58 | * @return the position 59 | */ 60 | @JsMethod 61 | public native String getPosition(); 62 | 63 | /** 64 | * Adds the control to the map. 65 | * 66 | * @param map the map 67 | * @return the L class 68 | */ 69 | @JsMethod 70 | public native L addTo(Map map); 71 | 72 | /** 73 | * Removes the control from the map. 74 | * 75 | * @return the L class 76 | * @param map a {@link com.gwidgets.api.leaflet.Map} object 77 | */ 78 | @JsMethod 79 | public native L remove(Map map); 80 | 81 | /** 82 | * Returns the HTML container of the control. 83 | * 84 | * @return the container 85 | */ 86 | @JsMethod 87 | public native HTMLElement getContainer(); 88 | 89 | /** 90 | * Should contain code that creates all the neccessary DOM elements for the control, adds listeners on relevant map events, and returns the element containing the control. Called on map.addControl(control) or control.addTo(map). 91 | * 92 | * @param map the map 93 | * @return the HTML element of the control 94 | */ 95 | public native HTMLElement onAdd(Map map); 96 | 97 | /** 98 | * Optional, should contain all clean up code (e.g. removes control's event listeners). Called on map.removeControl(control) or control.removeFrom(map). The control's DOM container is removed automatically. 99 | * 100 | * @param map the map 101 | */ 102 | public native void onRemove(Map map); 103 | } 104 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/DivIcon.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet; 2 | 3 | /** 4 | * Copyright 2016 G-Widgets 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | import jsinterop.annotations.JsType; 18 | 19 | /** 20 | * Represents a lightweight icon for markers that uses a simple div element instead of an image. 21 | * 22 | * @author Zakaria Amine 23 | * @version $Id: $Id 24 | */ 25 | @JsType(isNative = true) 26 | public class DivIcon extends Icon{ 27 | 28 | /** 29 | *

Constructor for DivIcon.

30 | */ 31 | protected DivIcon() { 32 | super(); 33 | 34 | } 35 | 36 | 37 | 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/DivOverlay.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet; 2 | 3 | import jsinterop.annotations.JsType; 4 | 5 | /** 6 | *

DivOverlay class.

7 | * 8 | * @author zakaria 9 | * @version $Id: $Id 10 | */ 11 | @JsType(isNative = true) 12 | public class DivOverlay { 13 | 14 | /** 15 | *

Constructor for DivOverlay.

16 | */ 17 | protected DivOverlay() { 18 | 19 | } 20 | 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/Evented.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet; 2 | 3 | import com.gwidgets.api.leaflet.events.EventCallback; 4 | 5 | import jsinterop.annotations.JsType; 6 | 7 | /** 8 | *

Evented interface.

9 | * 10 | * @author zakaria 11 | * @version $Id: $Id 12 | */ 13 | @JsType(isNative = true) 14 | public interface Evented { 15 | 16 | /** 17 | * Clear all event listeners. 18 | * 19 | * @return the L class 20 | */ 21 | public L clearAllEventListeners(); 22 | 23 | /** 24 | * Adds a set of type/listener pairs. 25 | * 26 | * @param type the type 27 | * @param fn the callback function 28 | * @return the L class 29 | */ 30 | public L on(String type, EventCallback fn); 31 | 32 | /** 33 | * the listener will only get fired once and then removed. 34 | * 35 | * @param type the type 36 | * @param fn the callback function 37 | * @return the L class 38 | */ 39 | public L once(String type, EventCallback fn); 40 | 41 | /** 42 | * Removes a listener 43 | * 44 | * @param type the type 45 | * @return the L class 46 | */ 47 | public L off(String type); 48 | 49 | /** 50 | * Removes a set of listener 51 | * 52 | * @param type the type 53 | * @return the L class 54 | */ 55 | public L off(String[] type); 56 | 57 | /** 58 | * Removes all listener 59 | * 60 | * @return the L class 61 | */ 62 | public L off(); 63 | 64 | /** 65 | * Fires an event of the specified type. You can optionally provide an data object — the first argument of the listener function will contain its properties. 66 | * 67 | * @param type the type 68 | * @return the L class 69 | */ 70 | public L fire(String type); 71 | 72 | 73 | /** 74 | * Returns true if a particular event type has any listeners attached to it. 75 | * 76 | * @return true if there is listener, false otherwise 77 | * @param type a {@link java.lang.String} object 78 | */ 79 | public Boolean listens(String type); 80 | 81 | 82 | /** 83 | * Adds an event parent - an Evented that will receive propagated events 84 | * 85 | * @return the L class 86 | * @param obj a {@link com.gwidgets.api.leaflet.Evented} object 87 | */ 88 | public L addEventParent(Evented obj); 89 | 90 | 91 | /** 92 | * Removes an event parent, so it will stop receiving propagated events 93 | * 94 | * @return the L class 95 | * @param obj a {@link com.gwidgets.api.leaflet.Evented} object 96 | */ 97 | public L removeEventParent(Evented obj); 98 | 99 | 100 | 101 | 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/FeatureGroup.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet; 2 | 3 | import com.gwidgets.api.leaflet.options.PathOptions; 4 | 5 | /** 6 | * Copyright 2016 G-Widgets 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | import jsinterop.annotations.JsMethod; 20 | import jsinterop.annotations.JsType; 21 | 22 | 23 | /** 24 | * Extended layerGroup that also has mouse events (propagated from members of the group) and a shared bindPopup method. 25 | * 26 | * @author Zakaria Amine 27 | * @version $Id: $Id 28 | */ 29 | @JsType(isNative = true) 30 | public class FeatureGroup extends LayerGroup { 31 | 32 | 33 | 34 | 35 | /** 36 | *

Constructor for FeatureGroup.

37 | */ 38 | protected FeatureGroup() { 39 | 40 | } 41 | 42 | /** 43 | * Returns the LatLngBounds of the Feature Group (created from bounds and coordinates of its children). 44 | * 45 | * @return the bounds 46 | */ 47 | @JsMethod 48 | public native LatLngBounds getBounds(); 49 | 50 | /** 51 | * Sets the given path options to each layer of the group that has a setStyle method. 52 | * 53 | * @param style the style 54 | * @return the L class 55 | */ 56 | @JsMethod 57 | public native L setStyle(PathOptions style); 58 | 59 | /** 60 | * Brings the layer group to the top of all other layers. 61 | * 62 | * @return the L class 63 | */ 64 | @JsMethod 65 | public native L bringToFront(); 66 | 67 | /** 68 | * Brings the layer group to the bottom of all other layers. 69 | * 70 | * @return the L class 71 | */ 72 | @JsMethod 73 | public native L bringToBack(); 74 | 75 | 76 | 77 | 78 | 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/GeoJSON.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet; 2 | 3 | /** 4 | * Copyright 2016 G-Widgets 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | import com.gwidgets.api.leaflet.options.GeoJSONOptions; 18 | 19 | import elemental2.core.JsObject; 20 | import jsinterop.annotations.JsMethod; 21 | import jsinterop.annotations.JsType; 22 | 23 | 24 | /** 25 | *Represents a GeoJSON object or an array of GeoJSON objects. Allows you to parse GeoJSON data and display it on the map. 26 | * 27 | *@author Zakaria Amine 28 | * @version $Id: $Id 29 | */ 30 | @JsType(isNative = true) 31 | public class GeoJSON extends FeatureGroup { 32 | 33 | 34 | private GeoJSON() { 35 | 36 | } 37 | 38 | /** 39 | * Adds a GeoJSON object to the layer. 40 | * 41 | * @param data the data 42 | * @return the L class 43 | */ 44 | @JsMethod 45 | public native L addData(JsObject data); 46 | 47 | /** 48 | * Changes styles of GeoJSON vector layers with the given style function. 49 | * 50 | * @param style the style function 51 | * @return the L class 52 | */ 53 | @JsMethod 54 | public native L setStyle(GeoJSONOptions.StyleFunction style); 55 | 56 | /** 57 | * Resets the given vector layer's style to the original GeoJSON style, useful for resetting style after hover events. 58 | * 59 | * @param layer the layer to reset 60 | * @return the L class 61 | */ 62 | @JsMethod 63 | public native L resetStyle(Path layer); 64 | 65 | /** 66 | * Creates a layer from a given GeoJSON feature. 67 | * 68 | * @param featureData the feature data 69 | * @param pointToLayer the point to layer 70 | * @return the layer 71 | */ 72 | @JsMethod 73 | public native static Layer geometryToLayer(JsObject featureData, 74 | GeoJSONOptions.PointToLayerFunction pointToLayer); 75 | 76 | /** 77 | * Creates a LatLng object from an array of 2 numbers (latitude, longitude) used in GeoJSON for points. If reverse is set to true, the numbers will be interpreted as (longitude, latitude). 78 | * 79 | * @param coords the coordinates 80 | * @return the lat lng 81 | */ 82 | @JsMethod 83 | public native static LatLng coordsToLatlng(double[] coords); 84 | 85 | 86 | /** 87 | * Creates a multidimensional array of LatLngs from a GeoJSON coordinates array. levelsDeep specifies the nesting level (0 is for an array of points, 1 for an array of arrays of points, etc., 0 by default). Can use a custom coordsToLatLng function. 88 | * 89 | * @param coords the coordinates 90 | * @param levelsDeep specifies the nesting level 91 | * @return js array of coordinates 92 | * @param coordsToLatlngs a {@link com.gwidgets.api.leaflet.options.GeoJSONOptions.CoordsToLatLngFunction} object 93 | */ 94 | @JsMethod 95 | public native static JsObject[] coordsToLatlngs(JsObject[] coords, double levelsDeep, 96 | GeoJSONOptions.CoordsToLatLngFunction coordsToLatlngs); 97 | 98 | 99 | /** 100 | * Reverse of coordsToLatLng. 101 | * 102 | * @param latlng the latlng 103 | * @return the js array 104 | */ 105 | @JsMethod 106 | public native JsObject[] latLngToCoords(LatLng latlng); 107 | 108 | 109 | /** 110 | * Reverse of coordsToLatLngs closed determines whether the first point should be appended to the end of the array to close the feature, only used when levelsDeep is 0. False by default. 111 | * 112 | * @param latlngs the latlngs 113 | * @param levelsDeep the levels deep 114 | * @param closed closed 115 | * @return the js array 116 | */ 117 | @JsMethod 118 | public native JsObject[] latLngsToCoords(JsObject[] latlngs, double levelsDeep, Boolean closed); 119 | 120 | 121 | /** 122 | * Normalize GeoJSON geometries/features into GeoJSON features. 123 | * 124 | * @param geojson the geojson 125 | * @return the java script object 126 | */ 127 | @JsMethod 128 | public native JsObject asFeature(JsObject geojson); 129 | 130 | 131 | 132 | 133 | } 134 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/Handler.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet; 2 | 3 | /** 4 | * Copyright 2016 G-Widgets 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | import jsinterop.annotations.JsType; 18 | 19 | 20 | /** 21 | * An interface implemented by interaction handlers. 22 | * 23 | * @author Zakaria Amine 24 | * @version $Id: $Id 25 | */ 26 | @JsType(isNative = true) 27 | public interface Handler { 28 | 29 | 30 | /** 31 | * Enables the handler. 32 | */ 33 | public void enable(); 34 | 35 | 36 | /** 37 | * Disables the handler. 38 | */ 39 | public void disable(); 40 | 41 | 42 | 43 | /** 44 | * Returns true if the handler is enabled. 45 | * 46 | * @return the boolean 47 | */ 48 | public Boolean enabled(); 49 | 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/LatLng.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet; 2 | 3 | /** 4 | * Copyright 2016 G-Widgets 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | import jsinterop.annotations.JsConstructor; 18 | import jsinterop.annotations.JsMethod; 19 | import jsinterop.annotations.JsProperty; 20 | import jsinterop.annotations.JsType; 21 | 22 | /** 23 | * Represents a geographical point with a certain latitude and longitude. 24 | * 25 | * @author Zakaria Amine 26 | * @version $Id: $Id 27 | */ 28 | @JsType(isNative = true) 29 | public class LatLng { 30 | 31 | 32 | 33 | 34 | 35 | private LatLng() { 36 | 37 | } 38 | 39 | /** Latitude in degrees. */ 40 | @JsProperty 41 | public Double lat; 42 | 43 | /** Longitude in degrees.The lng. */ 44 | @JsProperty 45 | public Double lng; 46 | 47 | 48 | 49 | /** 50 | * Instantiates a new lat lng. 51 | * 52 | * @param lat the lat 53 | * @param lng the lng 54 | */ 55 | @JsConstructor 56 | public LatLng(double lat, double lng) { 57 | 58 | } 59 | 60 | /** 61 | * Returns the distance (in meters) to the given LatLng calculated using the Haversine formula. 62 | * 63 | * @param otherLatlng the other latlng 64 | * @return the distance (in meters) 65 | */ 66 | @JsMethod 67 | public native double distanceTo(LatLng otherLatlng); 68 | 69 | /** 70 | * Returns true if the given LatLng point is at the same position (within a small margin of error). 71 | * 72 | * @param otherLatlng the other latlng 73 | * @return true/false 74 | */ 75 | @JsMethod 76 | public native Boolean equals(LatLng otherLatlng); 77 | 78 | /* (non-Javadoc) 79 | * @see java.lang.Object#toString() 80 | */ 81 | /** 82 | *

toString.

83 | * 84 | * @return a {@link java.lang.String} object 85 | */ 86 | @JsMethod 87 | public native String toString(); 88 | 89 | /** 90 | * Returns a new LatLng object with the longitude wrapped around left and right boundaries (-180 to 180 by default). 91 | * 92 | * @param left the left 93 | * @param right the right 94 | * @return the lat lng 95 | */ 96 | @JsMethod 97 | public native LatLng wrap(double left, double right); 98 | 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/LatLngBounds.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet; 2 | 3 | /** 4 | * Copyright 2016 G-Widgets 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | import jsinterop.annotations.JsMethod; 18 | import jsinterop.annotations.JsType; 19 | 20 | 21 | /** 22 | * Represents a rectangular geographical area on a map. 23 | * 24 | * @author Zakaria Amine 25 | * @version $Id: $Id 26 | */ 27 | @JsType(isNative = true) 28 | public class LatLngBounds { 29 | 30 | 31 | 32 | private LatLngBounds() { 33 | 34 | } 35 | 36 | /** 37 | * Extends the bounds to contain the given point. 38 | * 39 | * @param latlng the latlng 40 | * @return the L class 41 | */ 42 | @JsMethod 43 | public native L extend(LatLng latlng); 44 | 45 | /** 46 | * Extends the bounds to contain the given bounds. 47 | * 48 | * @param latlng the latlng 49 | * @return the L class 50 | */ 51 | @JsMethod 52 | public native L extend(LatLngBounds latlng); 53 | 54 | /** 55 | * Returns the south-west point of the bounds. 56 | * 57 | * @return the south west 58 | */ 59 | @JsMethod 60 | public native LatLng getSouthWest(); 61 | 62 | /** 63 | * Returns the north-east point of the bounds. 64 | * 65 | * @return the north east 66 | */ 67 | @JsMethod 68 | public native LatLng getNorthEast(); 69 | 70 | /** 71 | * Returns the north-west point of the bounds. 72 | * 73 | * @return the north west 74 | */ 75 | @JsMethod 76 | public native LatLng getNorthWest(); 77 | 78 | /** 79 | * Returns the south-east point of the bounds. 80 | * 81 | * @return the south east 82 | */ 83 | @JsMethod 84 | public native LatLng getSouthEast(); 85 | 86 | /** 87 | * Returns the west longitude of the bounds. 88 | * 89 | * @return the west 90 | */ 91 | @JsMethod 92 | public native double getWest(); 93 | 94 | /** 95 | * Returns the south latitude of the bounds. 96 | * 97 | * @return the south 98 | */ 99 | @JsMethod 100 | public native double getSouth(); 101 | 102 | /** 103 | * Returns the east longitude of the bounds. 104 | * 105 | * @return the east 106 | */ 107 | @JsMethod 108 | public native double getEast(); 109 | 110 | /** 111 | * Returns the north latitude of the bounds. 112 | * 113 | * @return the north 114 | */ 115 | @JsMethod 116 | public native double getNorth(); 117 | 118 | /** 119 | * Returns the center point of the bounds. 120 | * 121 | * @return the center 122 | */ 123 | @JsMethod 124 | public native LatLng getCenter(); 125 | 126 | /** 127 | * Returns true if the rectangle contains the given one. 128 | * 129 | * @param otherBounds the other bounds 130 | * @return true/false 131 | */ 132 | @JsMethod 133 | public native Boolean contains(LatLngBounds otherBounds); 134 | 135 | /** 136 | * Returns true if the rectangle contains the given point. 137 | * 138 | * @param latlng the latlng 139 | * @return true/false 140 | */ 141 | @JsMethod 142 | public native Boolean contains(LatLng latlng); 143 | 144 | /** 145 | * Returns true if the rectangle intersects the given bounds. 146 | * 147 | * @param otherBounds the other bounds 148 | * @return true/false 149 | */ 150 | @JsMethod 151 | public native Boolean intersects(LatLngBounds otherBounds); 152 | 153 | /** 154 | * Returns true if the rectangle is equivalent (within a small margin of error) to the given bounds. 155 | * 156 | * @param otherBounds the other bounds 157 | * @return true/flase 158 | */ 159 | @JsMethod 160 | public native Boolean equals(LatLngBounds otherBounds); 161 | 162 | /** 163 | * Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for sending requests to web services that return geo data 164 | * 165 | * @return the string 166 | */ 167 | @JsMethod 168 | public native String toBBoxString(); 169 | 170 | /** 171 | * Returns bigger bounds created by extending the current bounds by a given percentage in each direction. 172 | * 173 | * @param bufferRatio the buffer ratio 174 | * @return the lat lng bounds 175 | */ 176 | @JsMethod 177 | public native LatLngBounds pad(double bufferRatio); 178 | 179 | /** 180 | * Returns true if the bounds are properly initialized. 181 | * 182 | * @return true/false 183 | */ 184 | @JsMethod 185 | public native Boolean isValid(); 186 | 187 | } 188 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/Layer.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet; 2 | 3 | /** 4 | * Copyright 2016 G-Widgets 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | import com.gwidgets.api.leaflet.options.PopupOptions; 19 | import com.gwidgets.api.leaflet.options.TooltipOptions; 20 | 21 | import elemental2.dom.HTMLElement; 22 | import jsinterop.annotations.JsType; 23 | 24 | /** 25 | * Represents an object attached to a particular location (or a set of locations) on a map. Implemented by tile layers, markers, popups, image overlays, vector layers and layer groups. 26 | * @author Zakaria Amine 27 | */ 28 | @JsType(isNative = true) 29 | public interface Layer { 30 | 31 | 32 | 33 | /** 34 | * Binds a popup to the layer with the passed content and sets up the neccessary event listeners. 35 | * 36 | * @param content the element on which to binds the pop up 37 | * @param options the popup options 38 | * @return the L class 39 | */ 40 | 41 | public L bindPopup(HTMLElement content, PopupOptions options); 42 | 43 | /*** Binds a popup to the layer with the passed content and sets up the neccessary event listeners. 44 | * 45 | * @param id the id of the element 46 | * @param options the popup options 47 | * @return the L class 48 | */ 49 | 50 | public L bindPopup(String id, PopupOptions options); 51 | 52 | /*** Removes the popup previously bound with bindPopup. 53 | * 54 | * @return the L class 55 | */ 56 | 57 | public L unbindPopup(); 58 | 59 | 60 | 61 | /*** Opens the bound popup at the specificed latlng or at the default popup anchor if no latlng is passed. 62 | * 63 | * @param latlng the latlng where to open the pop up 64 | * @return the L class 65 | */ 66 | 67 | public L openPopup(LatLng latlng); 68 | 69 | 70 | /*** Closes the popup bound to this layer if it is open. 71 | * 72 | * @return the L class 73 | */ 74 | 75 | public L closePopup(); 76 | 77 | 78 | /*** Opens or closes the popup bound to this layer depending on its current state. 79 | * 80 | * @return the L class 81 | */ 82 | 83 | public L togglePopup(); 84 | 85 | /*** Returns true if the popup bound to this layer is currently open. 86 | * 87 | * @return true if pop up is open false if closed 88 | */ 89 | 90 | public boolean isPopupOpen(); 91 | 92 | /*** Sets the content of the popup bound to this layer. 93 | ** @param content content of the popup as a String 94 | * @return the L class 95 | */ 96 | 97 | public L setPopupContent(String content); 98 | 99 | /*** Sets the content of the popup bound to this layer. 100 | ** @param content content of the popup as a HTMLElement 101 | * @return the L class 102 | */ 103 | 104 | public L setPopupContent(HTMLElement content); 105 | 106 | 107 | /*** Sets the content of the popup bound to this layer. 108 | ** @param content content of the popup as a Popup Object 109 | * @return the L class 110 | */ 111 | 112 | public L setPopupContent(Popup content); 113 | 114 | /*** Returns the popup bound to this layer. 115 | * @return Popup the Pop bound to this layer. 116 | */ 117 | 118 | public Popup getPopup(); 119 | 120 | 121 | /** 122 | * Binds a tooltip to the layer with the passed *content and sets up the neccessary event listeners. If a Function is passed it will receive the layer as the first argument and should return a String or HTMLElement. 123 | * 124 | * @param content the tooltip content as a string 125 | * @param options the options object of this tooltip 126 | * @return the L class 127 | */ 128 | 129 | public L bindTooltip(String content, TooltipOptions options); 130 | 131 | /** 132 | * Binds a tooltip to the layer with the passed *content and sets up the neccessary event listeners. If a Function is passed it will receive the layer as the first argument and should return a String or HTMLElement. 133 | * 134 | * @param content the tooltip content as a HTMLElement object 135 | * @param options the options object of this tooltip 136 | * @return the L class 137 | */ 138 | 139 | public L bindTooltip(HTMLElement content, TooltipOptions options); 140 | 141 | /** 142 | * Binds a tooltip to the layer with the passed content and sets up the neccessary event listeners. If a Function is passed it will receive the layer as the first argument and should return a String or HTMLElement. 143 | * 144 | * @param content the tooltip content as a ToolTip object 145 | * @param options the options object of this tooltip 146 | * @return the L class 147 | */ 148 | 149 | public L bindTooltip(Tooltip content, TooltipOptions options); 150 | 151 | 152 | /** 153 | * Removes the tooltip previously bound with *bindTooltip. 154 | * 155 | * @return the L class 156 | */ 157 | 158 | public L unbindTooltip(); 159 | 160 | 161 | /** 162 | * Opens the bound tooltip at the specificed latlng or at the default tooltip anchor if no latlng is passed. 163 | * 164 | * @param latlng the latlng where the tooltip is opened 165 | * @return the L class 166 | */ 167 | 168 | public L openTooltip(LatLng latlng); 169 | 170 | /** 171 | * Closes the tooltip bound to this layer if it is open. 172 | * 173 | * @return the L class 174 | */ 175 | 176 | public L closeTooltip(); 177 | 178 | /** 179 | * Opens or closes the tooltip bound to this layer depending on its current state. 180 | * 181 | * @return the L class 182 | */ 183 | 184 | public L toggleTooltip(); 185 | 186 | /** 187 | * Returns true if the tooltip bound to this layer is currently open. 188 | * 189 | * @return boolean true if tooltip is open, false otherwise 190 | */ 191 | 192 | public boolean isTooltipOpen(); 193 | 194 | 195 | /** 196 | * Sets the content of the tooltip bound to this layer. 197 | * 198 | * @param content the content of the tooltip as a string 199 | * @return the L class 200 | */ 201 | 202 | public L setTooltipContent(String content); 203 | 204 | /** 205 | * Sets the content of the tooltip bound to this layer. 206 | * 207 | * @param content the content of the tooltip as a HTMLELement object 208 | * @return the L class 209 | */ 210 | 211 | public L setTooltipContent(HTMLElement content); 212 | 213 | 214 | /** 215 | * Sets the content of the tooltip bound to this layer. 216 | * 217 | * @param content the content of the tooltip as a Tooltip object 218 | * @return the L class 219 | */ 220 | 221 | public L setTooltipContent(Tooltip content); 222 | 223 | 224 | /** 225 | * Returns the tooltip bound to this layer. 226 | * 227 | * @return ToolTip the tooltip 228 | */ 229 | 230 | public Tooltip getTooltip(); 231 | 232 | /** Adds the tooltip to the given map 233 | * @param map the map object to which to add this toolltip 234 | * @return the L class 235 | */ 236 | 237 | public L addTo(Map map); 238 | 239 | 240 | /** Removes the tooltip from the map it is currently active on. 241 | * @return the L class 242 | */ 243 | public L remove(); 244 | 245 | 246 | /** Removes the tooltip from the given map 247 | * @param map the map object from which to remove this toolltip 248 | * @return the L class 249 | */ 250 | public L removeFrom(Map map); 251 | 252 | 253 | /** Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer. 254 | * @param name the map object from which to remove this toolltip 255 | * @return HTMLElement the element 256 | */ 257 | public HTMLElement getPane(String name); 258 | 259 | 260 | } -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/Layers.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet; 2 | 3 | import jsinterop.annotations.JsMethod; 4 | import jsinterop.annotations.JsType; 5 | 6 | 7 | /** 8 | * The layers control gives users the ability to switch between different base layers and switch overlays on/off 9 | * 10 | * @author Zakaria Amine 11 | * @version $Id: $Id 12 | */ 13 | @JsType(isNative = true) 14 | public class Layers extends Control{ 15 | 16 | 17 | 18 | /** 19 | * Adds a base layer (radio button entry) with the given name to the control. 20 | * 21 | * @param layer the layer 22 | * @param name the name 23 | * @return the l 24 | */ 25 | @JsMethod 26 | public native L addBaseLayer(Layer layer, String name); 27 | 28 | /** 29 | * Adds an overlay (checkbox entry) with the given name to the control. 30 | * 31 | * @param layer the layer 32 | * @param name the name 33 | * @return the l 34 | */ 35 | @JsMethod 36 | public native L addOverlay(Layer layer, String name); 37 | 38 | /** 39 | * Remove the given layer from the control. 40 | * 41 | * @param layer the layer 42 | * @return the l 43 | */ 44 | @JsMethod 45 | public native L removeLayer(Layer layer); 46 | 47 | /** 48 | * Expand the control container if collapsed. 49 | * 50 | * @return the l 51 | */ 52 | @JsMethod 53 | public native L expand(); 54 | 55 | /** 56 | * Collapse the control container if expanded. 57 | * 58 | * @return the l 59 | */ 60 | @JsMethod 61 | public native L collapse(); 62 | 63 | 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/MapPanes.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet; 2 | 3 | import elemental2.dom.HTMLElement; 4 | 5 | /** 6 | * Copyright 2016 G-Widgets 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | //import com.gwidgets.api.leaflet.elemental.HTMLElement; 20 | 21 | import jsinterop.annotations.JsProperty; 22 | import jsinterop.annotations.JsType; 23 | 24 | 25 | /** 26 | * An object literal (returned by map.getPanes) that contains different map panes that you can use to put your custom overlays in. The difference is mostly in zIndex order that such overlays get. 27 | * 28 | * @author Zakaria Amine 29 | * @version $Id: $Id 30 | */ 31 | @JsType 32 | public class MapPanes { 33 | 34 | private MapPanes() { 35 | 36 | } 37 | 38 | /** Pane that contains all other map panes. */ 39 | @JsProperty 40 | public HTMLElement mapPane; 41 | 42 | /** Pane for tile layers. */ 43 | @JsProperty 44 | public HTMLElement tilePane; 45 | 46 | /** Pane that contains all the panes except tile pane. */ 47 | @JsProperty 48 | public HTMLElement objectsPane; 49 | 50 | /** Pane for overlay shadows (e.g. marker shadows). */ 51 | @JsProperty 52 | public HTMLElement shadowPane; 53 | 54 | /** Pane for overlays like polylines and polygons. */ 55 | @JsProperty 56 | public HTMLElement overlayPane; 57 | 58 | /** Pane for marker icons. */ 59 | @JsProperty 60 | public HTMLElement markerPane; 61 | 62 | /** Pane for popups. */ 63 | @JsProperty 64 | public HTMLElement popupPane; 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/Path.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet; 2 | 3 | import com.gwidgets.api.leaflet.options.PathOptions; 4 | import com.gwidgets.api.leaflet.options.PopupOptions; 5 | 6 | import elemental2.dom.HTMLElement; 7 | /** 8 | * Copyright 2016 G-Widgets 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | import jsinterop.annotations.JsMethod; 22 | import jsinterop.annotations.JsType; 23 | 24 | /** 25 | * An abstract class that contains options and constants shared between vector overlays (Polygon, Polyline, Circle). Do not use it directly. 26 | * 27 | * @author Zakaria Amine 28 | * @version $Id: $Id 29 | */ 30 | @JsType(isNative = true) 31 | public abstract class Path { 32 | 33 | 34 | 35 | /** 36 | * Adds the layer to the map. 37 | * 38 | * @param map the map 39 | * @return the L class 40 | */ 41 | @JsMethod 42 | public native L addTo(Map map); 43 | 44 | /** 45 | * Bind popup. 46 | * 47 | * @param html the html 48 | * @param options the options 49 | * @return the l 50 | */ 51 | @JsMethod 52 | public native L bindPopup(String html, PopupOptions options); 53 | 54 | /** 55 | * Binds a popup with a particular HTML content to a click on this path. 56 | * 57 | * @param el the element 58 | * @param options the options 59 | * @return the L class 60 | */ 61 | @JsMethod 62 | public native L bindPopup(HTMLElement el, PopupOptions options); 63 | 64 | /** 65 | * Binds a popup with a particular HTML content to a click on this path. 66 | * 67 | * @param popup the popup 68 | * @param options the options 69 | * @return the L class 70 | */ 71 | @JsMethod 72 | public native L bindPopup(Popup popup, PopupOptions options); 73 | 74 | /** 75 | * Unbind popup. 76 | * 77 | * @return the L class 78 | */ 79 | @JsMethod 80 | public native L unbindPopup(); 81 | 82 | /** 83 | * Opens the popup previously bound by the bindPopup method in the given point, or in one of the path's points if not specified. 84 | * 85 | * @param latlng the latlng 86 | * @return the L class 87 | */ 88 | @JsMethod 89 | public native L openPopup(LatLng latlng); 90 | 91 | /** 92 | * Closes the path's bound popup if it is opened. 93 | * 94 | * @return the L class 95 | */ 96 | @JsMethod 97 | public native L closePopup(); 98 | 99 | /** 100 | * Changes the appearance of a Path based on the options in the Path options object. 101 | * 102 | * @param object the object 103 | * @return the L class 104 | */ 105 | @JsMethod 106 | public native L setStyle(PathOptions object); 107 | 108 | /** 109 | * Returns the LatLngBounds of the path. 110 | * 111 | * @return the bounds 112 | */ 113 | @JsMethod 114 | public native LatLngBounds getBounds(); 115 | 116 | /** 117 | * Brings the layer to the top of all path layers. 118 | * 119 | * @return the L class 120 | */ 121 | @JsMethod 122 | public native L bringToFront(); 123 | 124 | /** 125 | * Brings the layer to the bottom of all path layers. 126 | * 127 | * @return the L class 128 | */ 129 | @JsMethod 130 | public native L bringToBack(); 131 | 132 | /** 133 | * Redraws the layer. Sometimes useful after you changed the coordinates that the path uses. 134 | * 135 | * @return the L class 136 | */ 137 | @JsMethod 138 | public native L redraw(); 139 | 140 | 141 | } 142 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/Point.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet; 2 | 3 | import jsinterop.annotations.JsMethod; 4 | import jsinterop.annotations.JsProperty; 5 | import jsinterop.annotations.JsType; 6 | 7 | // TODO: Auto-generated Javadoc 8 | /** 9 | *Represents a point with x and y coordinates in pixels. 10 | * 11 | *@author Zakaria Amine 12 | * @version $Id: $Id 13 | */ 14 | @JsType(isNative = true) 15 | public class Point { 16 | 17 | 18 | 19 | /** The x coordinate. */ 20 | @JsProperty 21 | public double x; 22 | 23 | /** The The y coordinate. */ 24 | @JsProperty 25 | public double y; 26 | 27 | 28 | 29 | /** 30 | * Returns the result of addition of the current and the given points. 31 | * 32 | * @param otherPoint the other point 33 | * @return the point 34 | */ 35 | @JsMethod 36 | public native Point add(Point otherPoint); 37 | 38 | /** 39 | * Returns the result of subtraction of the given point from the current. 40 | * 41 | * @param otherPoint the other point 42 | * @return the point 43 | */ 44 | @JsMethod 45 | public native Point subtract(Point otherPoint); 46 | 47 | /** 48 | * Returns the result of multiplication of the current point by the given number. 49 | * 50 | * @param number the number 51 | * @return the point 52 | */ 53 | @JsMethod 54 | public native Point multiplyBy(double number); 55 | 56 | /** 57 | * Returns the result of division of the current point by the given number. If optional round is set to true, returns a rounded result. 58 | * 59 | * @param number the number 60 | * @param round the round 61 | * @return the point 62 | */ 63 | @JsMethod 64 | public native Point divideBy(double number, Boolean round); 65 | 66 | /** 67 | * Returns the distance between the current and the given points. 68 | * 69 | * @param otherPoint the other point 70 | * @return the number 71 | */ 72 | @JsMethod 73 | public native double distanceTo(Point otherPoint); 74 | 75 | /* (non-Javadoc) 76 | * @see java.lang.Object#clone() 77 | */ 78 | /** 79 | *

clone.

80 | * 81 | * @return a {@link com.gwidgets.api.leaflet.Point} object 82 | */ 83 | @JsMethod 84 | public native Point clone(); 85 | 86 | /** 87 | * Returns a copy of the current point with rounded coordinates. 88 | * 89 | * @return the point 90 | */ 91 | @JsMethod 92 | public native Point round(); 93 | 94 | 95 | /** 96 | * Returns a copy of the current point with floored coordinates (rounded down). 97 | * 98 | * @return the point 99 | */ 100 | @JsMethod 101 | public native Point floor(); 102 | 103 | 104 | 105 | /** 106 | * Returns true if the both coordinates of the given point are less than the corresponding current point coordinates (in absolute values). 107 | * 108 | * @param point the point 109 | * @return true/false 110 | */ 111 | @JsMethod 112 | public native Boolean contains(Point point); 113 | 114 | /** 115 | * Returns true if the given point has the same coordinates. 116 | * 117 | * @param otherPoint the other point 118 | * @return true/false 119 | */ 120 | @JsMethod 121 | public native Boolean equals(Point otherPoint); 122 | 123 | /* (non-Javadoc) 124 | * @see java.lang.Object#toString() 125 | */ 126 | /** 127 | *

toString.

128 | * 129 | * @return a {@link java.lang.String} object 130 | */ 131 | @JsMethod 132 | public native String toString(); 133 | 134 | } 135 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/Polygon.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet; 2 | 3 | /** 4 | * Copyright 2016 G-Widgets 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | import elemental2.core.JsObject; 18 | import jsinterop.annotations.JsMethod; 19 | import jsinterop.annotations.JsType; 20 | 21 | 22 | /** 23 | * A class for drawing polygon overlays on a map. Extends Polyline. Use addLayer method of map to add it to the map. 24 | * Note that points you pass when creating a polygon shouldn't have an additional last point equal to the first one — it's better to filter out such points. 25 | * 26 | * @author Zakaria Amine 27 | * @version $Id: $Id 28 | */ 29 | @JsType(isNative = true) 30 | public class Polygon extends Polyline { 31 | 32 | 33 | 34 | /** 35 | *

Constructor for Polygon.

36 | */ 37 | protected Polygon() { 38 | super(); 39 | } 40 | 41 | /* (non-Javadoc) 42 | * @see com.gwidgets.api.leaflet.Polyline#toGeoJSON() 43 | */ 44 | /** 45 | *

toGeoJSON.

46 | * 47 | * @return a {@link elemental2.core.JsObject} object 48 | */ 49 | @JsMethod 50 | public native JsObject toGeoJSON(); 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/Projection.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet; 2 | 3 | import jsinterop.annotations.JsMethod; 4 | import jsinterop.annotations.JsProperty; 5 | /** 6 | * Copyright 2016 G-Widgets 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | import jsinterop.annotations.JsType; 20 | 21 | /** 22 | * An object with methods for projecting geographical coordinates of the world onto a flat surface (and back). 23 | * 24 | * @author Zakaria Amine 25 | * @version $Id: $Id 26 | */ 27 | @JsType(isNative = true) 28 | public class Projection { 29 | 30 | @JsProperty 31 | public LatLngBounds bounds; 32 | 33 | 34 | private Projection() { 35 | 36 | 37 | } 38 | /** 39 | * Projects geographical coordinates into a 2D point. 40 | * 41 | * @param latlng the latlng 42 | * @return the point 43 | */ 44 | @JsMethod 45 | public native Point project(LatLng latlng); 46 | 47 | /** 48 | * The inverse of project. Projects a 2D point into geographical location. 49 | * 50 | * @param point the point 51 | * @return the lat lng 52 | */ 53 | @JsMethod 54 | public native LatLng unproject(Point point); 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/Rectangle.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet; 2 | 3 | /** 4 | * Copyright 2016 G-Widgets 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | import jsinterop.annotations.JsMethod; 18 | import jsinterop.annotations.JsType; 19 | 20 | 21 | /** 22 | * A class for drawing rectangle overlays on a map. Extends Polygon. 23 | * 24 | * @author Zakaria Amine 25 | * @version $Id: $Id 26 | */ 27 | @JsType(isNative = true) 28 | public class Rectangle extends Polygon{ 29 | 30 | 31 | 32 | private Rectangle() { 33 | 34 | } 35 | 36 | /** 37 | * Redraws the rectangle with the passed bounds. 38 | * 39 | * @param bounds a {@link com.gwidgets.api.leaflet.LatLngBounds} object 40 | * @return the L class 41 | */ 42 | @JsMethod 43 | public native L setBounds(LatLngBounds bounds); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/Renderer.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet; 2 | 3 | import com.gwidgets.api.leaflet.events.EventCallback; 4 | import com.gwidgets.api.leaflet.options.PopupOptions; 5 | import com.gwidgets.api.leaflet.options.TooltipOptions; 6 | 7 | import elemental2.dom.HTMLElement; 8 | import jsinterop.annotations.JsMethod; 9 | import jsinterop.annotations.JsType; 10 | 11 | /** 12 | *

Renderer class.

13 | * 14 | * @author zakaria 15 | * @version $Id: $Id 16 | */ 17 | @JsType(isNative = true) 18 | public class Renderer implements Evented, Layer { 19 | 20 | 21 | 22 | 23 | /** 24 | *

Constructor for Renderer.

25 | */ 26 | protected Renderer() { 27 | 28 | } 29 | 30 | 31 | // Events 32 | /* (non-Javadoc) 33 | * @see com.gwidgets.api.leaflet.Evented#clearAllEventListeners() 34 | */ 35 | /** 36 | *

clearAllEventListeners.

37 | * 38 | * @return a {@link com.gwidgets.api.leaflet.L} object 39 | */ 40 | public native L clearAllEventListeners(); 41 | 42 | 43 | /* (non-Javadoc) 44 | * @see com.gwidgets.api.leaflet.Evented#on(java.lang.String, com.gwidgets.api.leaflet.elemental.Function) 45 | */ 46 | /** {@inheritDoc} */ 47 | public native L on(String type, EventCallback fn); 48 | 49 | 50 | /* (non-Javadoc) 51 | * @see com.gwidgets.api.leaflet.Evented#once(java.lang.String, com.gwidgets.api.leaflet.elemental.Function) 52 | */ 53 | /** {@inheritDoc} */ 54 | public native L once(String type, EventCallback fn); 55 | 56 | 57 | /* (non-Javadoc) 58 | * @see com.gwidgets.api.leaflet.Evented#off(java.lang.String) 59 | */ 60 | /** 61 | *

off.

62 | * 63 | * @param type a {@link java.lang.String} object 64 | * @return a {@link com.gwidgets.api.leaflet.L} object 65 | */ 66 | public native L off(String type); 67 | 68 | 69 | /* (non-Javadoc) 70 | * @see com.gwidgets.api.leaflet.Evented#off(java.lang.String[]) 71 | */ 72 | /** 73 | *

off.

74 | * 75 | * @param type an array of {@link java.lang.String} objects 76 | * @return a {@link com.gwidgets.api.leaflet.L} object 77 | */ 78 | public native L off(String[] type); 79 | 80 | 81 | /* (non-Javadoc) 82 | * @see com.gwidgets.api.leaflet.Evented#off() 83 | */ 84 | /** 85 | *

off.

86 | * 87 | * @return a {@link com.gwidgets.api.leaflet.L} object 88 | */ 89 | public native L off(); 90 | 91 | 92 | /* (non-Javadoc) 93 | * @see com.gwidgets.api.leaflet.Evented#fire(java.lang.String) 94 | */ 95 | /** {@inheritDoc} */ 96 | public native L fire(String type); 97 | 98 | 99 | /* (non-Javadoc) 100 | * @see com.gwidgets.api.leaflet.Evented#listens(java.lang.String) 101 | */ 102 | /** {@inheritDoc} */ 103 | public native Boolean listens(String type); 104 | 105 | 106 | /* (non-Javadoc) 107 | * @see com.gwidgets.api.leaflet.Evented#addEventParent(com.gwidgets.api.leaflet.Evented) 108 | */ 109 | /** {@inheritDoc} */ 110 | public native L addEventParent(Evented obj); 111 | 112 | 113 | /* (non-Javadoc) 114 | * @see com.gwidgets.api.leaflet.Evented#removeEventParent(com.gwidgets.api.leaflet.Evented) 115 | */ 116 | /** {@inheritDoc} */ 117 | public native L removeEventParent(Evented obj); 118 | 119 | /* (non-Javadoc) 120 | * @see com.gwidgets.api.leaflet.Layer#bindPopup(com.gwidgets.api.leaflet.elemental.HTMLElement, com.gwidgets.api.leaflet.options.PopupOptions) 121 | */ 122 | /** {@inheritDoc} */ 123 | @JsMethod 124 | public native L bindPopup(HTMLElement content, PopupOptions options); 125 | 126 | 127 | /* (non-Javadoc) 128 | * @see com.gwidgets.api.leaflet.Layer#bindPopup(java.lang.String, com.gwidgets.api.leaflet.options.PopupOptions) 129 | */ 130 | /** {@inheritDoc} */ 131 | @JsMethod 132 | public native L bindPopup(String id, PopupOptions options); 133 | 134 | 135 | /* (non-Javadoc) 136 | * @see com.gwidgets.api.leaflet.Layer#unbindPopup() 137 | */ 138 | /** 139 | *

unbindPopup.

140 | * 141 | * @return a {@link com.gwidgets.api.leaflet.L} object 142 | */ 143 | @JsMethod 144 | public native L unbindPopup(); 145 | 146 | 147 | 148 | /* (non-Javadoc) 149 | * @see com.gwidgets.api.leaflet.Layer#openPopup(com.gwidgets.api.leaflet.LatLng) 150 | */ 151 | /** {@inheritDoc} */ 152 | @JsMethod 153 | public native L openPopup(LatLng latlng); 154 | 155 | 156 | /* (non-Javadoc) 157 | * @see com.gwidgets.api.leaflet.Layer#closePopup() 158 | */ 159 | /** 160 | *

closePopup.

161 | * 162 | * @return a {@link com.gwidgets.api.leaflet.L} object 163 | */ 164 | @JsMethod 165 | public native L closePopup(); 166 | 167 | 168 | /* (non-Javadoc) 169 | * @see com.gwidgets.api.leaflet.Layer#togglePopup() 170 | */ 171 | /** 172 | *

togglePopup.

173 | * 174 | * @return a {@link com.gwidgets.api.leaflet.L} object 175 | */ 176 | @JsMethod 177 | public native L togglePopup(); 178 | 179 | 180 | /* (non-Javadoc) 181 | * @see com.gwidgets.api.leaflet.Layer#isPopupOpen() 182 | */ 183 | /** 184 | *

isPopupOpen.

185 | * 186 | * @return a boolean 187 | */ 188 | @JsMethod 189 | public native boolean isPopupOpen(); 190 | 191 | 192 | /* (non-Javadoc) 193 | * @see com.gwidgets.api.leaflet.Layer#setPopupContent(java.lang.String) 194 | */ 195 | /** {@inheritDoc} */ 196 | @JsMethod 197 | public native L setPopupContent(String content); 198 | 199 | 200 | /* (non-Javadoc) 201 | * @see com.gwidgets.api.leaflet.Layer#setPopupContent(com.gwidgets.api.leaflet.elemental.HTMLElement) 202 | */ 203 | /** 204 | *

setPopupContent.

205 | * 206 | * @param content a {@link elemental2.dom.HTMLElement} object 207 | * @return a {@link com.gwidgets.api.leaflet.L} object 208 | */ 209 | @JsMethod 210 | public native L setPopupContent(HTMLElement content); 211 | 212 | 213 | /* (non-Javadoc) 214 | * @see com.gwidgets.api.leaflet.Layer#setPopupContent(com.gwidgets.api.leaflet.Popup) 215 | */ 216 | /** 217 | *

setPopupContent.

218 | * 219 | * @param content a {@link com.gwidgets.api.leaflet.Popup} object 220 | * @return a {@link com.gwidgets.api.leaflet.L} object 221 | */ 222 | @JsMethod 223 | public native L setPopupContent(Popup content); 224 | 225 | 226 | /* (non-Javadoc) 227 | * @see com.gwidgets.api.leaflet.Layer#getPopup() 228 | */ 229 | /** 230 | *

getPopup.

231 | * 232 | * @return a {@link com.gwidgets.api.leaflet.Popup} object 233 | */ 234 | @JsMethod 235 | public native Popup getPopup(); 236 | 237 | 238 | /* (non-Javadoc) 239 | * @see com.gwidgets.api.leaflet.Layer#bindTooltip(java.lang.String, com.gwidgets.api.leaflet.options.TooltipOptions) 240 | */ 241 | /** {@inheritDoc} */ 242 | public native L bindTooltip(String content, TooltipOptions options); 243 | 244 | 245 | /* (non-Javadoc) 246 | * @see com.gwidgets.api.leaflet.Layer#bindTooltip(com.gwidgets.api.leaflet.elemental.HTMLElement, com.gwidgets.api.leaflet.options.TooltipOptions) 247 | */ 248 | /** {@inheritDoc} */ 249 | public native L bindTooltip(HTMLElement content, TooltipOptions options); 250 | 251 | 252 | /* (non-Javadoc) 253 | * @see com.gwidgets.api.leaflet.Layer#bindTooltip(com.gwidgets.api.leaflet.Tooltip, com.gwidgets.api.leaflet.options.TooltipOptions) 254 | */ 255 | /** {@inheritDoc} */ 256 | public native L bindTooltip(Tooltip content, TooltipOptions options); 257 | 258 | 259 | /* (non-Javadoc) 260 | * @see com.gwidgets.api.leaflet.Layer#unbindTooltip() 261 | */ 262 | /** 263 | *

unbindTooltip.

264 | * 265 | * @return a {@link com.gwidgets.api.leaflet.L} object 266 | */ 267 | public native L unbindTooltip(); 268 | 269 | 270 | /* (non-Javadoc) 271 | * @see com.gwidgets.api.leaflet.Layer#openTooltip(com.gwidgets.api.leaflet.LatLng) 272 | */ 273 | /** {@inheritDoc} */ 274 | public native L openTooltip(LatLng latlng); 275 | 276 | 277 | /* (non-Javadoc) 278 | * @see com.gwidgets.api.leaflet.Layer#closeTooltip() 279 | */ 280 | /** 281 | *

closeTooltip.

282 | * 283 | * @return a {@link com.gwidgets.api.leaflet.L} object 284 | */ 285 | public native L closeTooltip(); 286 | 287 | /* (non-Javadoc) 288 | * @see com.gwidgets.api.leaflet.Layer#toggleTooltip() 289 | */ 290 | /** 291 | *

toggleTooltip.

292 | * 293 | * @return a {@link com.gwidgets.api.leaflet.L} object 294 | */ 295 | public native L toggleTooltip(); 296 | 297 | /* (non-Javadoc) 298 | * @see com.gwidgets.api.leaflet.Layer#isTooltipOpen() 299 | */ 300 | /** 301 | *

isTooltipOpen.

302 | * 303 | * @return a boolean 304 | */ 305 | public native boolean isTooltipOpen(); 306 | 307 | /* (non-Javadoc) 308 | * @see com.gwidgets.api.leaflet.Layer#setTooltipContent(java.lang.String) 309 | */ 310 | /** 311 | *

setTooltipContent.

312 | * 313 | * @param content a {@link java.lang.String} object 314 | * @return a {@link com.gwidgets.api.leaflet.L} object 315 | */ 316 | public native L setTooltipContent(String content); 317 | 318 | /* (non-Javadoc) 319 | * @see com.gwidgets.api.leaflet.Layer#setTooltipContent(com.gwidgets.api.leaflet.elemental.HTMLElement) 320 | */ 321 | /** {@inheritDoc} */ 322 | public native L setTooltipContent(HTMLElement content); 323 | 324 | 325 | /* (non-Javadoc) 326 | * @see com.gwidgets.api.leaflet.Layer#setTooltipContent(com.gwidgets.api.leaflet.Tooltip) 327 | */ 328 | /** 329 | *

setTooltipContent.

330 | * 331 | * @param content a {@link com.gwidgets.api.leaflet.Tooltip} object 332 | * @return a {@link com.gwidgets.api.leaflet.L} object 333 | */ 334 | public native L setTooltipContent(Tooltip content); 335 | 336 | 337 | /* (non-Javadoc) 338 | * @see com.gwidgets.api.leaflet.Layer#getTooltip() 339 | */ 340 | /** 341 | *

getTooltip.

342 | * 343 | * @return a {@link com.gwidgets.api.leaflet.Tooltip} object 344 | */ 345 | public native Tooltip getTooltip(); 346 | 347 | /* (non-Javadoc) 348 | * @see com.gwidgets.api.leaflet.Layer#addTo(com.gwidgets.api.leaflet.Map) 349 | */ 350 | /** {@inheritDoc} */ 351 | public native L addTo(Map map); 352 | 353 | 354 | /* (non-Javadoc) 355 | * @see com.gwidgets.api.leaflet.Layer#remove() 356 | */ 357 | /** 358 | *

remove.

359 | * 360 | * @return a {@link com.gwidgets.api.leaflet.L} object 361 | */ 362 | public native L remove(); 363 | 364 | /* (non-Javadoc) 365 | * @see com.gwidgets.api.leaflet.Layer#removeFrom(com.gwidgets.api.leaflet.Map) 366 | */ 367 | /** {@inheritDoc} */ 368 | public native L removeFrom(Map map); 369 | 370 | 371 | /* (non-Javadoc) 372 | * @see com.gwidgets.api.leaflet.Layer#getPane(java.lang.String) 373 | */ 374 | /** {@inheritDoc} */ 375 | public native HTMLElement getPane(String name); 376 | 377 | } 378 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/SVG.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet; 2 | 3 | 4 | 5 | import elemental2.svg.SVGElement; 6 | import jsinterop.annotations.JsType; 7 | 8 | /** 9 | *

SVG class.

10 | * 11 | * @author zakaria 12 | * @version $Id: $Id 13 | */ 14 | @JsType(isNative = true) 15 | public class SVG extends Renderer{ 16 | 17 | 18 | 19 | 20 | private SVG() { 21 | super(); 22 | 23 | } 24 | 25 | 26 | /** 27 | * Returns a instance of SVGElement, corresponding to the class name passed. For example, using 'line' will return an instance of SVGLineElement. 28 | * 29 | * @return SVGElement 30 | * @param name a {@link java.lang.String} object 31 | */ 32 | public static native SVGElement create(String name); 33 | 34 | 35 | /** 36 | * Generates a SVG path string for multiple rings, with each ring turning into "M..L..L.." instructions 37 | * 38 | * @return String the path string 39 | * @param rings an array of {@link com.gwidgets.api.leaflet.Point} objects 40 | * @param closed a {@link java.lang.Boolean} object 41 | */ 42 | public static native String pointsToPath(Point[] rings, Boolean closed); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/Scale.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet; 2 | 3 | /** 4 | * Copyright 2016 G-Widgets 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | import jsinterop.annotations.JsType; 18 | 19 | /** 20 | * A simple scale control that shows the scale of the current center of screen in metric (m/km) and imperial (mi/ft) systems. Extends Control. 21 | * 22 | * @author Zakaria Amine 23 | * @version $Id: $Id 24 | */ 25 | @JsType(isNative = true) 26 | public class Scale extends Control{ 27 | 28 | /** 29 | *

Constructor for Scale.

30 | */ 31 | protected Scale() { 32 | super(); 33 | 34 | } 35 | 36 | 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/TileLayer.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet; 2 | 3 | import elemental2.dom.HTMLElement; 4 | /** 5 | * Copyright 2016 G-Widgets 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | import jsinterop.annotations.JsMethod; 19 | import jsinterop.annotations.JsType; 20 | 21 | 22 | /** 23 | * Used to load and display tile layers on the map,. 24 | * 25 | * @author Zakaria Amine 26 | * @version $Id: $Id 27 | */ 28 | @JsType(isNative = true) 29 | public class TileLayer extends GridLayer{ 30 | 31 | 32 | 33 | 34 | 35 | /** 36 | *

Constructor for TileLayer.

37 | */ 38 | protected TileLayer() { 39 | 40 | 41 | 42 | } 43 | 44 | 45 | 46 | /** 47 | * Updates the layer's URL template and redraws it. 48 | * 49 | * @param urlTemplate the url template 50 | * @return the L class 51 | */ 52 | @JsMethod 53 | public native L setUrl(String urlTemplate); 54 | 55 | /** 56 | * Returns the HTML element that contains the tiles for this layer. 57 | * 58 | * @return the container 59 | */ 60 | @JsMethod 61 | public native HTMLElement getContainer(); 62 | 63 | //Events 64 | 65 | 66 | 67 | 68 | 69 | 70 | } 71 | 72 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/WMS.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet; 2 | 3 | import com.gwidgets.api.leaflet.options.TileLayerWMSOptions; 4 | 5 | /** 6 | * Copyright 2016 G-Widgets 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | import jsinterop.annotations.JsMethod; 20 | import jsinterop.annotations.JsType; 21 | 22 | /** 23 | * Used to display WMS services as tile layers on the map. 24 | * 25 | * @author Zakaria Amine 26 | * @version $Id: $Id 27 | */ 28 | @JsType(isNative = true) 29 | public class WMS extends TileLayer{ 30 | 31 | 32 | 33 | private WMS() { 34 | 35 | } 36 | 37 | /** 38 | * Merges an object with the new parameters and re-requests tiles on the current screen (unless noRedraw was set to true). 39 | * 40 | * @param params the params 41 | * @param noRedraw the no redraw 42 | * @return the l 43 | */ 44 | @JsMethod 45 | public static native L setParams(TileLayerWMSOptions params, 46 | Boolean noRedraw); 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/Zoom.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet; 2 | 3 | /** 4 | * Copyright 2016 G-Widgets 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | import jsinterop.annotations.JsType; 18 | 19 | /** 20 | * A basic zoom control with two buttons (zoom in and zoom out). It is put on the map by default unless you set its zoomControl option to false. 21 | * 22 | * @author Zakaria Amine 23 | * @version $Id: $Id 24 | */ 25 | @JsType(isNative = true) 26 | public class Zoom extends Control { 27 | 28 | private Zoom() { 29 | super(); 30 | } 31 | 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/events/DragEndEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 G-Widgets 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | package com.gwidgets.api.leaflet.events; 16 | 17 | import jsinterop.annotations.JsProperty; 18 | import jsinterop.annotations.JsType; 19 | 20 | /** 21 | * The Class DragEndEvent. 22 | * 23 | * @author Zakaria Amine 24 | * @version $Id: $Id 25 | */ 26 | @JsType(isNative=true, name="Object", namespace=jsinterop.annotations.JsPackage.GLOBAL) 27 | public class DragEndEvent extends Event { 28 | 29 | 30 | private DragEndEvent() { 31 | 32 | } 33 | 34 | /** 35 | * Gets the distance in pixels the draggable element was moved by. 36 | * 37 | * @return the distance 38 | */ 39 | @JsProperty 40 | public final native double getDistance(); 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/events/ErrorEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 G-Widgets 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | package com.gwidgets.api.leaflet.events; 16 | 17 | import jsinterop.annotations.JsProperty; 18 | import jsinterop.annotations.JsType; 19 | 20 | /** 21 | * The Class ErrorEvent. 22 | * 23 | * @author Zakaria Amine 24 | * @version $Id: $Id 25 | */ 26 | @JsType(isNative=true, name="Object", namespace=jsinterop.annotations.JsPackage.GLOBAL) 27 | public class ErrorEvent extends Event { 28 | 29 | 30 | private ErrorEvent(){ 31 | 32 | 33 | } 34 | 35 | 36 | /** 37 | * Gets the error message. 38 | * 39 | * @return the message 40 | */ 41 | @JsProperty 42 | public final native String getMessage(); 43 | 44 | /** 45 | * Gets the error code (if applicable). 46 | * 47 | * @return the code 48 | */ 49 | public final native double getCode(); 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/events/Event.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 G-Widgets 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | package com.gwidgets.api.leaflet.events; 16 | 17 | 18 | 19 | import elemental2.dom.HTMLElement; 20 | import jsinterop.annotations.JsProperty; 21 | import jsinterop.annotations.JsType; 22 | 23 | 24 | 25 | /** 26 | * The base event object. All other event objects contain these properties too. 27 | * 28 | * @author Zakaria Amine 29 | * @version $Id: $Id 30 | */ 31 | @JsType(isNative=true, name="Object", namespace=jsinterop.annotations.JsPackage.GLOBAL) 32 | public class Event { 33 | 34 | 35 | /** 36 | *

Constructor for Event.

37 | */ 38 | public Event(){ 39 | 40 | 41 | } 42 | 43 | /** 44 | * Gets the event type (e.g. 'click'). 45 | * 46 | * @return the type 47 | */ 48 | @JsProperty 49 | public final native String getType(); 50 | 51 | /** 52 | * Gets the object that fired the event.. 53 | * 54 | * @return the target 55 | */ 56 | @JsProperty 57 | public final native HTMLElement getTarget(); 58 | 59 | 60 | 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/events/EventCallback.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet.events; 2 | 3 | import jsinterop.annotations.JsFunction; 4 | 5 | /** 6 | * Created by zakaria on 7/2/2017. 7 | * 8 | * @author zakaria 9 | * @version $Id: $Id 10 | */ 11 | @JsFunction 12 | public interface EventCallback { 13 | 14 | /** 15 | *

call.

16 | * 17 | * @param event a T object 18 | */ 19 | void call(T event); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/events/GeoJSONEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 G-Widgets 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | package com.gwidgets.api.leaflet.events; 16 | 17 | import com.gwidgets.api.leaflet.Layer; 18 | 19 | import jsinterop.annotations.JsProperty; 20 | import jsinterop.annotations.JsType; 21 | 22 | /** 23 | * The Class GeoJSONEvent. 24 | * 25 | * @author Zakaria Amine 26 | * @version $Id: $Id 27 | */ 28 | @JsType(isNative=true, name="Object", namespace=jsinterop.annotations.JsPackage.GLOBAL) 29 | public class GeoJSONEvent extends Event { 30 | 31 | 32 | private GeoJSONEvent() { 33 | 34 | } 35 | 36 | /** 37 | * Gets the layer for the GeoJSON feature that is being added to the map. 38 | * 39 | * @return the layer 40 | */ 41 | @JsProperty 42 | public final native Layer getLayer(); 43 | 44 | 45 | /** 46 | * Gets the GeoJSON properties of the feature. 47 | * 48 | * @return the properties 49 | */ 50 | @JsProperty 51 | public final native Object getProperties(); 52 | 53 | /** 54 | * Gets the GeoJSON geometry type of the feature. 55 | * 56 | * @return the geometry type 57 | */ 58 | @JsProperty 59 | public final native String getGeometryType(); 60 | 61 | /** 62 | * Gets the GeoJSON ID of the feature (if present). 63 | * 64 | * @return the id 65 | */ 66 | @JsProperty 67 | public final native String getId(); 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/events/KeyboardEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 G-Widgets 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | package com.gwidgets.api.leaflet.events; 16 | 17 | //import com.gwidgets.api.leaflet.elemental.DOMKeyboardEvent; 18 | 19 | import jsinterop.annotations.JsProperty; 20 | import jsinterop.annotations.JsType; 21 | 22 | 23 | 24 | /** 25 | * The Class KeyboardEvent. 26 | * 27 | * @author Zakaria Amine 28 | * @version $Id: $Id 29 | */ 30 | @JsType(isNative=true, name="Object", namespace=jsinterop.annotations.JsPackage.GLOBAL) 31 | public class KeyboardEvent extends Event { 32 | 33 | 34 | /** 35 | *

Constructor for KeyboardEvent.

36 | */ 37 | protected KeyboardEvent() {} 38 | 39 | /** 40 | * The original Dom KeyboardEvent that triggered this Leaflet event. 41 | * 42 | * @return the popup 43 | */ 44 | @JsProperty 45 | public final native elemental2.dom.KeyboardEvent getOriginalEvent(); 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/events/LayerEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 G-Widgets 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | package com.gwidgets.api.leaflet.events; 16 | 17 | import com.gwidgets.api.leaflet.Layer; 18 | 19 | import jsinterop.annotations.JsProperty; 20 | import jsinterop.annotations.JsType; 21 | 22 | 23 | /** 24 | * The Class LayerEvent. 25 | * 26 | * @author Zakaria Amine 27 | * @version $Id: $Id 28 | */ 29 | @JsType(isNative=true, name="Object", namespace=jsinterop.annotations.JsPackage.GLOBAL) 30 | public class LayerEvent extends Event { 31 | 32 | 33 | private LayerEvent() { 34 | // TODO Auto-generated constructor stub 35 | } 36 | 37 | 38 | /** 39 | * Gets the layer that was added or removed. 40 | * 41 | * @return the layer 42 | */ 43 | @JsProperty 44 | public final native Layer getLayer(); 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/events/LayersControlEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 G-Widgets 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | package com.gwidgets.api.leaflet.events; 16 | 17 | import com.gwidgets.api.leaflet.Layer; 18 | 19 | import jsinterop.annotations.JsProperty; 20 | import jsinterop.annotations.JsType; 21 | 22 | 23 | /** 24 | * The Class LayerControlEvent. 25 | * 26 | * @author Zakaria Amine 27 | * @version $Id: $Id 28 | */ 29 | @JsType(isNative=true, name="Object", namespace=jsinterop.annotations.JsPackage.GLOBAL) 30 | public class LayersControlEvent extends Event { 31 | 32 | 33 | private LayersControlEvent() { 34 | 35 | } 36 | 37 | /** 38 | * Gets the layer that was added or removed. 39 | * 40 | * @return the layer 41 | */ 42 | @JsProperty 43 | public final native Layer getLayer(); 44 | 45 | /** 46 | * Gets the name of the layer that was added or removed. 47 | * 48 | * @return the name 49 | */ 50 | @JsProperty 51 | public final native String getName(); 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/events/LocationEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 G-Widgets 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | package com.gwidgets.api.leaflet.events; 16 | 17 | import com.gwidgets.api.leaflet.LatLng; 18 | import com.gwidgets.api.leaflet.LatLngBounds; 19 | 20 | import jsinterop.annotations.JsProperty; 21 | import jsinterop.annotations.JsType; 22 | 23 | 24 | /** 25 | * The Class LocationEvent. 26 | * 27 | * @author Zakaria Amine 28 | * @version $Id: $Id 29 | */ 30 | @JsType(isNative=true, name="Object", namespace=jsinterop.annotations.JsPackage.GLOBAL) 31 | public class LocationEvent extends Event { 32 | 33 | 34 | private LocationEvent(){} 35 | 36 | 37 | 38 | /** 39 | * Gets the detected geographical location of the user. 40 | * 41 | * @return the latlng 42 | */ 43 | @JsProperty 44 | public final native LatLng getLatlng(); 45 | 46 | /** 47 | * Gets the geographical bounds of the area user is located in (with respect to the accuracy of location). 48 | * 49 | * @return the bounds 50 | */ 51 | @JsProperty 52 | public final native LatLngBounds getBounds(); 53 | 54 | /** 55 | * Gets the accuracy of location in meters. 56 | * 57 | * @return the accuracy 58 | */ 59 | @JsProperty 60 | public final native double getAccuracy(); 61 | 62 | /** 63 | * Gets the height of the position above the WGS84 ellipsoid in meters. 64 | * 65 | * @return the altitude 66 | */ 67 | @JsProperty 68 | public final native double getAltitude(); 69 | 70 | /** 71 | * Gets the accuracy of the altitude in meters. 72 | * 73 | * @return the altitude accuracy 74 | */ 75 | @JsProperty 76 | public final native double getAltitudeAccuracy(); 77 | 78 | /** 79 | * Gets the direction of travel in degrees counting clockwise from true North. 80 | * 81 | * @return the heading 82 | */ 83 | @JsProperty 84 | public final native double getHeading(); 85 | 86 | /** 87 | * Gets the current velocity in meters per second. 88 | * 89 | * @return the speed 90 | */ 91 | @JsProperty 92 | public final native double getSpeed(); 93 | 94 | /** 95 | * Gets the time when the position was acquired. 96 | * 97 | * @return the timestamp 98 | */ 99 | @JsProperty 100 | public final native double getTimestamp(); 101 | 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/events/MouseEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 G-Widgets 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | package com.gwidgets.api.leaflet.events; 16 | 17 | import com.gwidgets.api.leaflet.LatLng; 18 | import com.gwidgets.api.leaflet.Point; 19 | 20 | import jsinterop.annotations.JsProperty; 21 | import jsinterop.annotations.JsType; 22 | 23 | 24 | /** 25 | * The Class MouseEvent. 26 | * 27 | * @author Zakaria Amine 28 | * @version $Id: $Id 29 | */ 30 | @JsType(isNative=true, name="Object", namespace=jsinterop.annotations.JsPackage.GLOBAL) 31 | public class MouseEvent extends Event { 32 | 33 | 34 | private MouseEvent(){} 35 | 36 | /** 37 | * Gets the geographical point where the mouse event occurred. 38 | * 39 | * @return the latlng 40 | */ 41 | @JsProperty 42 | public final native LatLng getLatlng(); 43 | 44 | /** 45 | * Gets the pixel coordinates of the point where the mouse event occurred relative to the map layer. 46 | * 47 | * @return the layer point 48 | */ 49 | @JsProperty 50 | public final native Point getLayerPoint(); 51 | 52 | /** 53 | * Gets the pixel coordinates of the point where the mouse event occurred relative to the map container. 54 | * 55 | * @return the container point 56 | */ 57 | @JsProperty 58 | public final native Point getContainerPoint(); 59 | 60 | /** 61 | * Gets the original DOM mouse event fired by the browser. 62 | * 63 | * @return the original event 64 | */ 65 | @JsProperty 66 | public final native elemental2.dom.MouseEvent getOriginalEvent(); 67 | 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/events/PopupEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 G-Widgets 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | package com.gwidgets.api.leaflet.events; 16 | 17 | 18 | import com.gwidgets.api.leaflet.Popup; 19 | 20 | import jsinterop.annotations.JsProperty; 21 | import jsinterop.annotations.JsType; 22 | 23 | /** 24 | * The Class PopupEvent. 25 | * 26 | * @author Zakaria Amine 27 | * @version $Id: $Id 28 | */ 29 | @JsType(isNative=true, name="Object", namespace=jsinterop.annotations.JsPackage.GLOBAL) 30 | public class PopupEvent extends Event { 31 | 32 | private PopupEvent() {} 33 | 34 | 35 | /** 36 | * Gets the popup that was opened or closed. 37 | * 38 | * @return the popup 39 | */ 40 | @JsProperty 41 | public final native Popup getPopup(); 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/events/ResizeEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 G-Widgets 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | package com.gwidgets.api.leaflet.events; 16 | 17 | 18 | import com.gwidgets.api.leaflet.Point; 19 | 20 | import jsinterop.annotations.JsProperty; 21 | import jsinterop.annotations.JsType; 22 | 23 | /** 24 | * The Class ResizeEvent. 25 | * 26 | * @author Zakaria Amine 27 | * @version $Id: $Id 28 | */ 29 | @JsType(isNative=true, name="Object", namespace=jsinterop.annotations.JsPackage.GLOBAL) 30 | public class ResizeEvent extends Event { 31 | 32 | /** 33 | * Instantiates a new resize event. 34 | */ 35 | private ResizeEvent(){} 36 | 37 | /** 38 | * Gets the old size before resize event. 39 | * 40 | * @return the old size 41 | */ 42 | @JsProperty 43 | public final native Point getOldSize(); 44 | 45 | /** 46 | * Gets the new size after the resize event. 47 | * 48 | * @return the new size 49 | */ 50 | @JsProperty 51 | public final native Point getNewSize(); 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/events/TileErrorEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 G-Widgets 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | package com.gwidgets.api.leaflet.events; 16 | 17 | import com.gwidgets.api.leaflet.Point; 18 | 19 | import elemental2.dom.HTMLElement; 20 | import jsinterop.annotations.JsProperty; 21 | import jsinterop.annotations.JsType; 22 | 23 | 24 | /** 25 | * The Class TileErrorEvent. 26 | * 27 | * @author Zakaria Amine 28 | * @version $Id: $Id 29 | */ 30 | @JsType(isNative=true, name="Object", namespace=jsinterop.annotations.JsPackage.GLOBAL) 31 | public class TileErrorEvent extends Event { 32 | 33 | 34 | private TileErrorEvent() { 35 | 36 | } 37 | 38 | /** 39 | * Gets the tile element (image). 40 | * 41 | * @return the tile 42 | */ 43 | @JsProperty 44 | public final native HTMLElement getTile(); 45 | 46 | 47 | /** 48 | * Point object with tile's x, y, and z (zoom level) coordinates. 49 | * 50 | * @return the coords 51 | */ 52 | @JsProperty 53 | public final native Point getCoords(); 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/events/TileEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 G-Widgets 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | package com.gwidgets.api.leaflet.events; 16 | 17 | 18 | import com.gwidgets.api.leaflet.Point; 19 | 20 | import elemental2.dom.HTMLElement; 21 | import jsinterop.annotations.JsProperty; 22 | import jsinterop.annotations.JsType; 23 | 24 | 25 | /** 26 | * The Class TileEvent. 27 | * 28 | * @author Zakaria Amine 29 | * @version $Id: $Id 30 | */ 31 | @JsType(isNative=true, name="Object", namespace=jsinterop.annotations.JsPackage.GLOBAL) 32 | public class TileEvent extends Event { 33 | 34 | 35 | private TileEvent() {} 36 | 37 | 38 | /** 39 | * Gets the tile element (image). 40 | * 41 | * @return the tile 42 | */ 43 | @JsProperty 44 | public final native HTMLElement getTile(); 45 | 46 | /** 47 | * Point object with tile's x, y, and z (zoom level) coordinates. 48 | * 49 | * @return the coords 50 | */ 51 | @JsProperty 52 | public final native Point getCoords(); 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/events/TooltipEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 G-Widgets 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | package com.gwidgets.api.leaflet.events; 16 | 17 | import com.gwidgets.api.leaflet.Tooltip; 18 | 19 | import jsinterop.annotations.JsProperty; 20 | import jsinterop.annotations.JsType; 21 | 22 | 23 | 24 | // TODO: Auto-generated Javadoc 25 | /** 26 | * The Class TooltipEvent. 27 | * 28 | * @author Zakaria Amine 29 | * @version $Id: $Id 30 | */ 31 | @JsType(isNative=true, name="Object", namespace=jsinterop.annotations.JsPackage.GLOBAL) 32 | public class TooltipEvent extends Event { 33 | 34 | /** 35 | * Instantiates a new tooltip event. 36 | */ 37 | private TooltipEvent() {} 38 | 39 | 40 | /** 41 | * The tooltip that was opened or closed. 42 | * 43 | * @return the popup 44 | */ 45 | @JsProperty 46 | public final native Tooltip getTooltip(); 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/options/CircleOptions.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet.options; 2 | 3 | import static jsinterop.annotations.JsPackage.GLOBAL; 4 | 5 | import com.gwidgets.api.leaflet.Renderer; 6 | 7 | import jsinterop.annotations.JsOverlay; 8 | import jsinterop.annotations.JsType; 9 | 10 | @JsType(isNative = true, namespace = GLOBAL, name = "Object") 11 | public class CircleOptions extends PathOptions { 12 | 13 | protected CircleOptions(){} 14 | 15 | private double radius; 16 | /** 17 | * Returns the current radius of a circle. Units are in meters. 18 | * 19 | * @return the radius 20 | */ 21 | @JsOverlay 22 | public final double getRadius() { 23 | return this.radius; 24 | } 25 | 26 | public static class Builder { 27 | 28 | private Boolean stroke; 29 | 30 | private String color; 31 | 32 | private Double weight; 33 | 34 | private Double opacity; 35 | 36 | private Boolean fill; 37 | 38 | private String fillColor; 39 | 40 | private Double fillOpacity; 41 | 42 | private String fillRule; 43 | 44 | private String dashArray; 45 | 46 | private String lineCap; 47 | 48 | private String lineJoin; 49 | 50 | private String pointerEvents; 51 | 52 | private String className; 53 | 54 | private String dashOffset; 55 | 56 | private Renderer renderer; 57 | 58 | private String pane; 59 | 60 | private String attribution; 61 | 62 | private Boolean interactive; 63 | 64 | private Double radius; 65 | 66 | /** 67 | * Instantiates a new builder. 68 | */ 69 | public Builder() { 70 | 71 | } 72 | 73 | /** 74 | * Whether to draw stroke along the path. Set it to false to disable 75 | * borders on polygons or circles. 76 | * default true 77 | * 78 | * @param stroke 79 | * the stroke 80 | * @return the builder 81 | */ 82 | public Builder stroke(Boolean stroke) { 83 | this.stroke = stroke; 84 | return this; 85 | } 86 | 87 | /** 88 | * Stroke color. 89 | * default "#03f" 90 | * 91 | * @param color 92 | * the color 93 | * @return the builder 94 | */ 95 | public Builder color(String color) { 96 | this.color = color; 97 | return this; 98 | } 99 | 100 | /** 101 | * Stroke width in pixels. 102 | * default 5 103 | * 104 | * @param weight 105 | * the weight 106 | * @return the builder 107 | */ 108 | public Builder weight(Double weight) { 109 | this.weight = weight; 110 | return this; 111 | } 112 | 113 | /** 114 | * Stroke opacity. 115 | * default 0.5 116 | * 117 | * @param opacity 118 | * the opacity 119 | * @return the builder 120 | */ 121 | public Builder opacity(Double opacity) { 122 | this.opacity = opacity; 123 | return this; 124 | } 125 | 126 | /** 127 | * Whether to fill the path with color. Set it to false to disable 128 | * filling on polygons or circles. 129 | * default true 130 | * 131 | * @param fill 132 | * the fill 133 | * @return the builder 134 | */ 135 | public Builder fill(Boolean fill) { 136 | this.fill = fill; 137 | return this; 138 | } 139 | 140 | /** 141 | * Fill color. 142 | * default "#03f" 143 | * 144 | * @param fillColor 145 | * the fill color 146 | * @return the builder 147 | */ 148 | public Builder fillColor(String fillColor) { 149 | this.fillColor = fillColor; 150 | return this; 151 | } 152 | 153 | /** 154 | * Fill opacity. 155 | * default 0.2 156 | * 157 | * @param fillOpacity 158 | * the fill opacity 159 | * @return the builder 160 | */ 161 | public Builder fillOpacity(Double fillOpacity) { 162 | this.fillOpacity = fillOpacity; 163 | return this; 164 | } 165 | 166 | /** 167 | * A string that defines how the inside of a shape is determined. See 168 | * 170 | * docs for more info 171 | * 172 | * @param fillRule 173 | * the fill rule 174 | * @return the builder 175 | */ 176 | public Builder fillRule(String fillRule) { 177 | this.fillRule = fillRule; 178 | return this; 179 | } 180 | 181 | /** 182 | * A string that defines the stroke 184 | * dash pattern. Doesn't work on canvas-powered layers (e.g. Android 185 | * 2). 186 | * default "evenodd" 187 | * 188 | * @param dashArray 189 | * the dash array 190 | * @return the builder 191 | */ 192 | public Builder dashArray(String dashArray) { 193 | this.dashArray = dashArray; 194 | return this; 195 | } 196 | 197 | /** 198 | * A string that defines 200 | * shape to be used at the end of the stroke. 201 | * default null 202 | * 203 | * @param lineCap 204 | * the line cap 205 | * @return the builder 206 | */ 207 | public Builder lineCap(String lineCap) { 208 | this.lineCap = lineCap; 209 | return this; 210 | } 211 | 212 | /** 213 | * A string that defines 215 | * shape to be used at the corners of the stroke. 216 | * default null 217 | * 218 | * @param lineJoin 219 | * the line join 220 | * @return the builder 221 | */ 222 | public Builder lineJoin(String lineJoin) { 223 | this.lineJoin = lineJoin; 224 | return this; 225 | } 226 | 227 | 228 | /** 229 | * Sets the pointer-events attribute on the path if SVG backend is used. 230 | * 231 | * default null 232 | * 233 | * @param pointerEvents 234 | * the pointer events 235 | * @return the builder 236 | */ 237 | public Builder pointerEvents(String pointerEvents) { 238 | this.pointerEvents = pointerEvents; 239 | return this; 240 | } 241 | 242 | /** 243 | * Custom class name set on an element. 244 | * default empty string 245 | * 246 | * @param className 247 | * the class name 248 | * @return the builder 249 | */ 250 | public Builder className(String className) { 251 | this.className = className; 252 | return this; 253 | } 254 | 255 | public Builder dashOffset(String dashOffset){this.dashOffset = dashOffset; return this;} 256 | 257 | public Builder renderer(Renderer renderer){this.renderer = renderer; return this;} 258 | 259 | public Builder attribution(String attribution){this.attribution = attribution; return this;} 260 | 261 | public Builder pane(String pane){this.pane = pane; return this;} 262 | 263 | public Builder interactive(Boolean interactive){this.interactive = interactive; return this;} 264 | 265 | public Builder radius(Double radius){this.radius = radius;return this;} 266 | 267 | /** 268 | * Builds the PathOptions new instance 269 | * 270 | * @return the path options 271 | */ 272 | public CircleOptions build(){ 273 | CircleOptions options = new CircleOptions(); 274 | if(this.stroke != null) 275 | options.stroke = this.stroke; 276 | if(this.color != null) 277 | options.color = this.color; 278 | if(this.opacity != null) 279 | options.opacity = this.opacity; 280 | if(this.weight != null) 281 | options.weight = this.weight; 282 | if(this.fill != null) 283 | options.fill = this.fill; 284 | if(this.fillColor != null) 285 | options.fillColor = this.fillColor; 286 | if(this.fillOpacity != null) 287 | options.fillOpacity = this.fillOpacity; 288 | if(this.fillRule != null) 289 | options.fillRule = this.fillRule; 290 | if(this.dashArray != null) 291 | options.dashArray = this.dashArray; 292 | if(this.lineCap != null) 293 | options.lineCap = this.lineCap; 294 | if(this.lineJoin != null) 295 | options.lineJoin = this.lineJoin; 296 | if(this.pointerEvents != null) 297 | options.pointerEvents = this.pointerEvents; 298 | if(this.className != null) 299 | options.className = this.className; 300 | if(this.dashOffset != null) 301 | options.dashOffset = this.dashOffset; 302 | if(this.renderer != null) 303 | options.renderer = this.renderer; 304 | if(this.pane != null) 305 | options.pane = this.pane; 306 | if(this.attribution != null) 307 | options.attribution = this.attribution; 308 | if(this.interactive != null) 309 | options.interactive = this.interactive; 310 | if(this.radius != null) 311 | options.radius = this.radius; 312 | 313 | return options; 314 | } 315 | } 316 | } 317 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/options/ControlAttributionOptions.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 G-Widgets 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | package com.gwidgets.api.leaflet.options; 16 | 17 | import static jsinterop.annotations.JsPackage.GLOBAL; 18 | 19 | import jsinterop.annotations.JsOverlay; 20 | import jsinterop.annotations.JsProperty; 21 | import jsinterop.annotations.JsType; 22 | 23 | 24 | /** 25 | * The Class ControlAttributionOptions. 26 | * @author Zakaria Amine 27 | */ 28 | @JsType(isNative=true, namespace=GLOBAL, name="Object") 29 | public class ControlAttributionOptions { 30 | 31 | 32 | private ControlAttributionOptions(){ 33 | 34 | 35 | } 36 | 37 | @JsProperty 38 | private String position; 39 | 40 | @JsProperty 41 | private String prefix; 42 | 43 | /** 44 | * Gets the position of the control (one of the map corners). See class constants for possible values 45 | * 46 | *default "bottomright" 47 | * @return the position 48 | */ 49 | @JsOverlay public final String getPosition() { 50 | return this.position; 51 | } 52 | 53 | /** 54 | * Gets the prefix: The HTML text shown before the attributions. Pass false to disable. 55 | * 56 | * default "lealflet" 57 | * @return the prefix 58 | */ 59 | @JsOverlay public final String getPrefix() { 60 | return this.prefix; 61 | } 62 | 63 | /** 64 | * The options Builder. 65 | */ 66 | public static class Builder{ 67 | 68 | 69 | private String position; 70 | 71 | private String prefix; 72 | 73 | /** 74 | * Instantiates a new builder. 75 | */ 76 | public Builder(){ 77 | 78 | 79 | } 80 | 81 | 82 | /** 83 | * The position of the control (one of the map corners). 84 | * 85 | * default "bottomright" 86 | * 87 | * possible values: "topleft", "topright", "bottomleft", "bottomright" 88 | * 89 | * @param position the position 90 | * @return the builder 91 | */ 92 | public Builder position(String position){ 93 | this.position = position; 94 | return this; 95 | } 96 | 97 | /** 98 | * The HTML text shown before the attributions. Pass false to disable. 99 | * 100 | * default "Leaflet" 101 | * @param prefix the prefix 102 | * @return the builder 103 | */ 104 | public Builder prefix(String prefix){ 105 | this.prefix = prefix; 106 | return this; 107 | } 108 | 109 | /** 110 | * Builds a new ControlAttributionOptions instance 111 | * 112 | * @return the control attribution options 113 | */ 114 | public ControlAttributionOptions build(){ 115 | 116 | ControlAttributionOptions options = new ControlAttributionOptions(); 117 | if(this.position != null) 118 | options.position = this.position; 119 | if(this.prefix != null) 120 | options.prefix = this.prefix; 121 | 122 | return options; 123 | } 124 | } 125 | } -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/options/ControlLayersOptions.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 G-Widgets 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | package com.gwidgets.api.leaflet.options; 16 | 17 | import static jsinterop.annotations.JsPackage.GLOBAL; 18 | 19 | import jsinterop.annotations.JsOverlay; 20 | import jsinterop.annotations.JsProperty; 21 | import jsinterop.annotations.JsType; 22 | 23 | /** 24 | * The Class ControlLayersOptions. 25 | * @author Zakaria Amine 26 | */ 27 | @JsType(isNative=true, namespace=GLOBAL, name="Object") 28 | public class ControlLayersOptions { 29 | 30 | 31 | private ControlLayersOptions(){ 32 | 33 | 34 | } 35 | 36 | @JsProperty 37 | private String position; 38 | 39 | @JsProperty 40 | private boolean collapsed; 41 | 42 | @JsProperty 43 | private boolean autoZIndex; 44 | 45 | 46 | /** 47 | * Gets the position of the control (one of the map corners). 48 | * 49 | * default "topright" 50 | * 51 | * @return the position 52 | */ 53 | @JsOverlay public final String getPosition() { 54 | return this.position; 55 | } 56 | 57 | 58 | /** 59 | * Gets whether the control will be collapsed into an icon and expanded on mouse hover or touch. 60 | * 61 | * default true 62 | * @return the collapsed 63 | */ 64 | @JsOverlay public final boolean getCollapsed() { 65 | return this.collapsed; 66 | } 67 | 68 | 69 | /** 70 | * Gets whether the control will assign zIndexes in increasing order to all of its layers so that the order is preserved when switching them on/off. 71 | * 72 | * default true 73 | * @return the auto Z index 74 | */ 75 | @JsOverlay public final boolean getAutoZIndex() { 76 | return this.autoZIndex; 77 | } 78 | 79 | 80 | /** 81 | * The Class Builder. 82 | */ 83 | public static class Builder { 84 | 85 | 86 | private String position; 87 | 88 | private Boolean collapsed; 89 | 90 | private Boolean autoZIndex; 91 | 92 | 93 | public Builder(){ 94 | 95 | 96 | } 97 | 98 | /** 99 | * The position of the control (one of the map corners). 100 | * 101 | * default "topright" 102 | * 103 | * possible values: "topleft", "topright", "bottomleft", "bottomright" 104 | * @param position the position 105 | * @return the builder 106 | */ 107 | public Builder position(String position){this.position = position;return this;} 108 | 109 | /** 110 | * If true, the control will be collapsed into an icon and expanded on mouse hover or touch. 111 | * 112 | * default true 113 | * @param collapsed the collapsed 114 | * @return the builder 115 | */ 116 | public Builder collapsed(Boolean collapsed){this.collapsed = collapsed; return this;} 117 | 118 | /** 119 | * If true, the control will assign zIndexes in increasing order to all of its layers so that the order is preserved when switching them on/off. 120 | * 121 | * default true 122 | * @param autoZIndex the auto Z index 123 | * @return the builder 124 | */ 125 | public Builder autoZIndex(Boolean autoZIndex){this.autoZIndex = autoZIndex; return this;} 126 | 127 | 128 | /** 129 | * Builds the ControlLayersOptions new instance 130 | * 131 | * 132 | * @return the control layers options 133 | */ 134 | public ControlLayersOptions build(){ 135 | 136 | ControlLayersOptions options = new ControlLayersOptions(); 137 | if(this.position != null) 138 | options.position = this.position; 139 | if(this.collapsed != null) 140 | options.collapsed = this.collapsed; 141 | if(this.autoZIndex != null) 142 | options.autoZIndex = this.autoZIndex; 143 | 144 | return options; 145 | 146 | } 147 | 148 | } 149 | 150 | 151 | } -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/options/ControlOptions.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 G-Widgets 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | package com.gwidgets.api.leaflet.options; 16 | 17 | import static jsinterop.annotations.JsPackage.GLOBAL; 18 | 19 | import jsinterop.annotations.JsOverlay; 20 | import jsinterop.annotations.JsProperty; 21 | import jsinterop.annotations.JsType; 22 | 23 | /** 24 | * The Class ControlOptions. 25 | * @author Zakaria Amine 26 | */ 27 | @JsType(isNative=true, namespace=GLOBAL, name="Object") 28 | public class ControlOptions { 29 | 30 | 31 | @JsProperty 32 | private String position; 33 | 34 | 35 | private ControlOptions(){ 36 | 37 | 38 | } 39 | 40 | 41 | /** 42 | * Gets The initial position of the control (one of the map corners). 43 | * 44 | * default "topright" 45 | * @return the position 46 | */ 47 | @JsOverlay public final String getPosition() { 48 | return this.position; 49 | } 50 | 51 | 52 | /** 53 | * The Class Builder. 54 | */ 55 | public static class Builder { 56 | 57 | 58 | private String position; 59 | 60 | 61 | public Builder() { 62 | 63 | } 64 | 65 | /** 66 | * The initial position of the control (one of the map corners). 67 | * 68 | * default "topright" 69 | * 70 | * possible values: "topleft", "topright", "bottomleft", "bottomright" 71 | * @param position the position 72 | * @return the builder 73 | */ 74 | public Builder position(String position){ 75 | this.position = position; 76 | return this; 77 | } 78 | 79 | 80 | /** 81 | * Builds the ControlOptions new instance 82 | * 83 | * @return the control options 84 | */ 85 | public ControlOptions build(){ 86 | ControlOptions options = new ControlOptions(); 87 | if(this.position != null) 88 | options.position = this.position; 89 | 90 | return options; 91 | 92 | } 93 | } 94 | } -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/options/ControlScaleOptions.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet.options; 2 | /** 3 | * Copyright 2016 G-Widgets 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import static jsinterop.annotations.JsPackage.GLOBAL; 17 | 18 | import jsinterop.annotations.JsOverlay; 19 | import jsinterop.annotations.JsProperty; 20 | import jsinterop.annotations.JsType; 21 | 22 | 23 | /** 24 | * The Class ControlScaleOptions. 25 | * 26 | * @author Zakaria Amine 27 | */ 28 | @JsType(isNative = true, namespace = GLOBAL, name = "Object") 29 | public class ControlScaleOptions { 30 | 31 | private ControlScaleOptions() { 32 | 33 | } 34 | 35 | @JsProperty 36 | private String position; 37 | 38 | @JsProperty 39 | private double maxWidth; 40 | 41 | @JsProperty 42 | private boolean metric; 43 | 44 | @JsProperty 45 | private boolean imperial; 46 | 47 | @JsProperty 48 | private boolean updateWhenIdle; 49 | 50 | /** 51 | * Gets the position of the control (one of the map corners) 52 | * 53 | * default "bottomleft" 54 | * @return the position 55 | */ 56 | @JsOverlay 57 | public final String getPosition() { 58 | return this.position; 59 | } 60 | 61 | /** 62 | * Gets Maximum width of the control in pixels. The width is set dynamically to show round values (e.g. 100, 200, 500). 63 | * 64 | * default 100 65 | * @return the max width 66 | */ 67 | @JsOverlay 68 | public final double getMaxWidth() { 69 | return this.maxWidth; 70 | } 71 | 72 | /** 73 | * Gets Whether to show the metric scale line (m/km). 74 | * 75 | * default true 76 | * @return the metric 77 | */ 78 | @JsOverlay 79 | public final boolean getMetric() { 80 | return this.metric; 81 | } 82 | 83 | /** 84 | * Gets Whether to show the imperial scale line (mi/ft). 85 | * 86 | * default true 87 | * @return the imperial 88 | */ 89 | @JsOverlay 90 | public final boolean getImperial() { 91 | return this.imperial; 92 | } 93 | 94 | /** 95 | * Gets whether the control is updated on moveend, otherwise it's always up-to-date (updated on move). 96 | * 97 | * default false 98 | * @return the update when idle 99 | */ 100 | @JsOverlay 101 | public final boolean getUpdateWhenIdle() { 102 | return this.updateWhenIdle; 103 | } 104 | 105 | /** 106 | * The Class Builder. 107 | */ 108 | public static class Builder { 109 | 110 | private String position; 111 | 112 | private Double maxWidth; 113 | 114 | private Boolean metric; 115 | 116 | private Boolean imperial; 117 | 118 | private Boolean updateWhenIdle; 119 | 120 | /** 121 | * Instantiates a new builder. 122 | */ 123 | public Builder() { 124 | 125 | } 126 | 127 | /** 128 | * The position of the control (one of the map corners 129 | * 130 | * possible values: "topleft", "topright", "bottomleft", "bottomright" 131 | * 132 | * @param position the position 133 | * @return the builder 134 | */ 135 | public Builder position(String position) { 136 | this.position = position; 137 | return this; 138 | } 139 | 140 | /** 141 | * Maximum width of the control in pixels. The width is set dynamically to show round values (e.g. 100, 200, 500). 142 | * 143 | * default 100 144 | * @param maxWidth the max width 145 | * @return the builder 146 | */ 147 | public Builder maxWidth(Double maxWidth) { 148 | this.maxWidth = maxWidth; 149 | return this; 150 | } 151 | 152 | /** 153 | * Whether to show the metric scale line (m/km). 154 | * 155 | * default true 156 | * @param metric the metric 157 | * @return the builder 158 | */ 159 | public Builder metric(Boolean metric) { 160 | this.metric = metric; 161 | return this; 162 | } 163 | 164 | /** 165 | * Whether to show the imperial scale line (mi/ft). 166 | * 167 | * default true 168 | * @param imperial the imperial 169 | * @return the builder 170 | */ 171 | public Builder imperial(Boolean imperial) { 172 | this.imperial = imperial; 173 | return this; 174 | } 175 | 176 | /** 177 | * If true, the control is updated on moveend, otherwise it's always up-to-date (updated on move). 178 | * 179 | * default false 180 | * @param updateWhenIdle the update when idle 181 | * @return the builder 182 | */ 183 | public Builder updateWhenIdle(Boolean updateWhenIdle) { 184 | this.updateWhenIdle = updateWhenIdle; 185 | return this; 186 | } 187 | 188 | /** 189 | * Builds the ControlScaleOptions new instance 190 | * 191 | * @return the control scale options 192 | */ 193 | public ControlScaleOptions build() { 194 | ControlScaleOptions options = new ControlScaleOptions(); 195 | if(this.position != null) 196 | options.position = this.position; 197 | if(this.maxWidth != null) 198 | options.maxWidth = this.maxWidth; 199 | if(this.metric != null) 200 | options.metric = this.metric; 201 | if(this.imperial != null) 202 | options.imperial = this.imperial; 203 | if(this.updateWhenIdle != null) 204 | options.updateWhenIdle = this.updateWhenIdle; 205 | 206 | return options; 207 | } 208 | } 209 | } -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/options/ControlZoomOptions.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 G-Widgets 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | package com.gwidgets.api.leaflet.options; 16 | 17 | import static jsinterop.annotations.JsPackage.GLOBAL; 18 | 19 | import jsinterop.annotations.JsOverlay; 20 | import jsinterop.annotations.JsProperty; 21 | import jsinterop.annotations.JsType; 22 | 23 | /** 24 | * The Class ControlZoomOptions. 25 | * 26 | * @author Zakaria Amine 27 | */ 28 | @JsType(isNative = true, namespace = GLOBAL, name = "Object") 29 | public class ControlZoomOptions { 30 | 31 | private ControlZoomOptions() { 32 | 33 | } 34 | 35 | @JsProperty 36 | private String position; 37 | 38 | @JsProperty 39 | private String zoomInText; 40 | 41 | @JsProperty 42 | private String zoomOutText; 43 | 44 | @JsProperty 45 | private String zoomInTitle; 46 | 47 | @JsProperty 48 | private String zoomOutTitle; 49 | 50 | /** 51 | * Gets the position of the control (one of the map corners). 52 | * default "topleft" 53 | * 54 | * @return the position 55 | */ 56 | @JsOverlay 57 | public final String getPosition() { 58 | return this.position; 59 | } 60 | 61 | /** 62 | * Gets The text set on the zoom in button. 63 | * default "+" 64 | * 65 | * @return the zoomInText 66 | */ 67 | @JsOverlay 68 | public final String getZoomInText() { 69 | return this.zoomInText; 70 | } 71 | 72 | /** 73 | * Gets The text set on the zoom out button. 74 | * default "-" 75 | * 76 | * @return the zoomOutText 77 | */ 78 | @JsOverlay 79 | public final String getZoomOutText() { 80 | return this.zoomOutText; 81 | } 82 | 83 | /** 84 | * Gets The title set on the zoom in button. 85 | * default "Zoom in" 86 | * 87 | * @return the zoomInTitle 88 | */ 89 | @JsOverlay 90 | public final String getzoomInTitle() { 91 | return this.zoomInTitle; 92 | } 93 | 94 | /** 95 | * Gets The title set on the zoom out button. 96 | * default "Zoom out" 97 | * 98 | * @return the zoomOutTitle 99 | */ 100 | @JsOverlay 101 | public final String getzoomOutTitle() { 102 | return this.zoomOutTitle; 103 | } 104 | 105 | public static class Builder { 106 | 107 | private String position; 108 | 109 | private String zoomInText; 110 | 111 | private String zoomOutText; 112 | 113 | private String zoomInTitle; 114 | 115 | private String zoomOutTitle; 116 | 117 | public Builder() { 118 | 119 | } 120 | 121 | /** 122 | * The position of the control (one of the map corners). 123 | * default "topleft" 124 | * possible values: "topleft", "topright", "bottomleft", "bottomright" 125 | * 126 | * @param position 127 | * the position 128 | * @return the builder 129 | */ 130 | public Builder position(String position) { 131 | 132 | this.position = position; 133 | return this; 134 | } 135 | 136 | /** 137 | * The text set on the zoom in button. 138 | * default "+" 139 | * 140 | * @param zoomInText 141 | * the zoom in text 142 | * @return the builder 143 | */ 144 | public Builder zoomInText(String zoomInText) { 145 | 146 | this.zoomInText = zoomInText; 147 | return this; 148 | } 149 | 150 | /** 151 | * The text set on the zoom out button. 152 | * default "-" 153 | * 154 | * @param zoomOutText 155 | * the zoom out text 156 | * @return the builder 157 | */ 158 | public Builder zoomOutText(String zoomOutText) { 159 | 160 | this.zoomOutText = zoomOutText; 161 | return this; 162 | } 163 | 164 | /** 165 | * The title set on the zoom in button. 166 | * default "Zoom in" 167 | * 168 | * @param zoomInTitle 169 | * the zoom in title 170 | * @return the builder 171 | */ 172 | public Builder zoomInTitle(String zoomInTitle) { 173 | 174 | this.zoomInTitle = zoomInTitle; 175 | return this; 176 | } 177 | 178 | /** 179 | * The title set on the zoom out button. 180 | * default "Zoom out" 181 | * 182 | * @param zoomOutTitle 183 | * the zoom out title 184 | * @return the builder 185 | */ 186 | public Builder zoomOutTitle(String zoomOutTitle) { 187 | 188 | this.zoomOutTitle = zoomOutTitle; 189 | return this; 190 | } 191 | 192 | /** 193 | * Builds the ControlZoomOptions new instance 194 | * 195 | * @return the control zoom options 196 | */ 197 | public ControlZoomOptions build() { 198 | ControlZoomOptions options = new ControlZoomOptions(); 199 | if(this.position != null) 200 | options.position = this.position; 201 | if(this.zoomInText != null) 202 | options.zoomInText = this.zoomInText; 203 | if(this.zoomOutText != null) 204 | options.zoomOutText = this.zoomOutText; 205 | if(this.zoomInTitle != null) 206 | options.zoomInTitle = this.zoomInTitle; 207 | if(this.zoomOutTitle != null) 208 | options.zoomOutTitle = this.zoomOutTitle; 209 | return options; 210 | } 211 | } 212 | } -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/options/FitBoundsOptions.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 G-Widgets 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | package com.gwidgets.api.leaflet.options; 16 | 17 | import static jsinterop.annotations.JsPackage.GLOBAL; 18 | 19 | import com.gwidgets.api.leaflet.L; 20 | import com.gwidgets.api.leaflet.Point; 21 | 22 | import jsinterop.annotations.JsOverlay; 23 | import jsinterop.annotations.JsProperty; 24 | import jsinterop.annotations.JsType; 25 | 26 | 27 | /** 28 | * The Class FitBoundsOptions. 29 | * 30 | * @author Zakaria Amine 31 | */ 32 | @JsType(isNative = true, namespace = GLOBAL, name = "Object") 33 | public class FitBoundsOptions { 34 | 35 | 36 | private FitBoundsOptions() { 37 | 38 | } 39 | 40 | @JsProperty 41 | private Point paddingTopLeft; 42 | 43 | @JsProperty 44 | private Point paddingBottomRight; 45 | 46 | @JsProperty 47 | private Point padding; 48 | 49 | @JsProperty 50 | private double maxZoom; 51 | 52 | /***************************************** 53 | ********************************************/ 54 | @JsProperty 55 | private boolean animate; 56 | /********************************************** 57 | *********************************************/ 58 | 59 | /***************************************** 60 | ********************************************/ 61 | @JsProperty 62 | private double duration; 63 | /********************************************** 64 | *********************************************/ 65 | 66 | /***************************************** 67 | ********************************************/ 68 | @JsProperty 69 | private double easeLinearity; 70 | /********************************************** 71 | *********************************************/ 72 | /***************************************** 73 | ********************************************/ 74 | @JsProperty 75 | private boolean noMoveStart; 76 | /********************************************** 77 | *********************************************/ 78 | 79 | 80 | /** 81 | * Gets the maximum possible zoom to use. 82 | * 83 | * @return the max zoom 84 | */ 85 | @JsOverlay 86 | public final double getMaxZoom() { 87 | return this.maxZoom; 88 | } 89 | 90 | /** 91 | * Gets the amount of padding in the top left corner of a map container that shouldn't be accounted for when setting the view to fit bounds. 92 | * 93 | * @return the padding top left 94 | */ 95 | @JsOverlay 96 | public final Point getPaddingTopLeft() { 97 | return this.paddingTopLeft; 98 | } 99 | 100 | /** 101 | * Gets the same for bottom right corner of the map. 102 | * 103 | * @return the padding bottom right 104 | */ 105 | @JsOverlay 106 | public final Point getPaddingBottomRight() { 107 | return this.paddingBottomRight; 108 | } 109 | 110 | /** 111 | * Gets the equivalent of setting both top left and bottom right padding to the same value. 112 | * 113 | * @return the padding 114 | */ 115 | @JsOverlay 116 | public final Point getPadding() { 117 | return this.padding; 118 | } 119 | 120 | @JsOverlay 121 | public final boolean getAnimate() { 122 | return this.animate; 123 | } 124 | 125 | @JsOverlay 126 | public final double getDuration() { 127 | return this.duration; 128 | } 129 | 130 | @JsOverlay 131 | public final double getEaseLinearity() { 132 | return this.easeLinearity; 133 | } 134 | 135 | @JsOverlay 136 | public final boolean getNoMoveStart() { 137 | return this.noMoveStart; 138 | } 139 | 140 | /** 141 | * The Class Builder. 142 | */ 143 | public static class Builder { 144 | 145 | private Point paddingTopLeft; 146 | 147 | private Point paddingBottomRight; 148 | 149 | private Point padding; 150 | 151 | private Double maxZoom; 152 | 153 | private Boolean animate; 154 | 155 | private Double duration; 156 | 157 | private Double easeLinearity; 158 | 159 | private Boolean noMoveStart; 160 | 161 | /** 162 | * Instantiates a new builder. 163 | */ 164 | public Builder() { 165 | 166 | } 167 | 168 | /** 169 | * Sets the amount of padding in the top left corner of a map container that shouldn't be accounted for when setting the view to fit bounds. Useful if you have some control overlays on the map like a sidebar and you don't want them to obscure objects you're zooming to. 170 | * 171 | * default [0, 0] 172 | * 173 | * @param paddingTopLeft the padding top left 174 | * @return the builder 175 | */ 176 | public Builder paddingTopLeft(Point paddingTopLeft) { 177 | this.paddingTopLeft = paddingTopLeft; 178 | return this; 179 | } 180 | 181 | /** 182 | * The same for bottom right corner of the map. 183 | * 184 | * default [0, 0] 185 | * 186 | * @param paddingBottomRight the padding bottom right 187 | * @return the builder 188 | */ 189 | public Builder paddingBottomRight(Point paddingBottomRight) { 190 | this.paddingBottomRight = paddingBottomRight; 191 | return this; 192 | } 193 | 194 | /** 195 | * Equivalent of setting both top left and bottom right padding to the same value. 196 | * 197 | * default [0, 0] 198 | * 199 | * @param padding the padding 200 | * @return the builder 201 | */ 202 | public Builder padding(Point padding) { 203 | this.padding = padding; 204 | return this; 205 | } 206 | 207 | /** 208 | * The maximum possible zoom to use. 209 | * 210 | * default null 211 | * 212 | * @param maxZoom the max zoom 213 | * @return the builder 214 | */ 215 | public Builder maxZoom(Double maxZoom) { 216 | this.maxZoom = maxZoom; 217 | return this; 218 | } 219 | 220 | public Builder animate(Boolean animate){this.animate = animate; return this;} 221 | 222 | public Builder duration(Double duration){this.duration = duration; return this;} 223 | 224 | public Builder easeLinearity(Double easeLinearity){this.easeLinearity = easeLinearity; return this;} 225 | 226 | public Builder noMoveStart(Boolean noMoveStart){this.noMoveStart = noMoveStart; return this;} 227 | 228 | /** 229 | * Builds the FitBoundsOptions new instance 230 | * 231 | * @return the fit bounds options 232 | */ 233 | public FitBoundsOptions build() { 234 | FitBoundsOptions options = new FitBoundsOptions(); 235 | if(this.paddingTopLeft != null) 236 | options.paddingTopLeft = this.paddingTopLeft; 237 | if(this.paddingBottomRight != null) 238 | options.paddingBottomRight = this.paddingBottomRight; 239 | if(this.padding != null) 240 | options.padding = this.padding; 241 | if(this.maxZoom != null) 242 | options.maxZoom = this.maxZoom; 243 | if(this.animate != null) 244 | options.animate = this.animate; 245 | if(this.duration != null) 246 | options.duration = this.duration; 247 | if(this.easeLinearity != null) 248 | options.easeLinearity = this.easeLinearity; 249 | if(this.noMoveStart != null) 250 | options.noMoveStart = this.noMoveStart; 251 | 252 | return options; 253 | } 254 | } 255 | } -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/options/GeoJSONOptions.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet.options; 2 | 3 | import com.gwidgets.api.leaflet.LatLng; 4 | import com.gwidgets.api.leaflet.Layer; 5 | import com.gwidgets.api.leaflet.Marker; 6 | 7 | import elemental2.core.JsObject; 8 | import jsinterop.annotations.JsFunction; 9 | import jsinterop.annotations.JsOverlay; 10 | import jsinterop.annotations.JsProperty; 11 | import jsinterop.annotations.JsType; 12 | 13 | import static jsinterop.annotations.JsPackage.GLOBAL; 14 | 15 | /** 16 | * The Interface GeoJSONOptions. 17 | * 18 | * @author Zakaria Amine 19 | */ 20 | @JsType(isNative = true, namespace = GLOBAL, name = "Object") 21 | public class GeoJSONOptions { 22 | 23 | @JsProperty 24 | String attribution; 25 | 26 | @JsProperty 27 | String pane; 28 | 29 | 30 | /** 31 | * By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default. 32 | * 33 | * @return the attribution 34 | */ 35 | @JsOverlay 36 | public final String getAttribution() { 37 | return this.attribution; 38 | } 39 | 40 | /** 41 | * String to be shown in the attribution control, describes the layer data, e.g. "© Mapbox". 42 | * 43 | * @return the attribution 44 | */ 45 | @JsOverlay public final String getPane() { 46 | return this.pane; 47 | } 48 | 49 | /** 50 | * Function that will be used for creating layers for GeoJSON points (if not specified, simple markers will be created). 51 | */ 52 | @JsProperty 53 | public PointToLayerFunction pointToLayer; 54 | 55 | /** 56 | * Function that will be used to get style options for vector layers created for GeoJSON features. 57 | * 58 | */ 59 | @JsProperty 60 | public StyleFunction style; 61 | 62 | /** 63 | * Function that will be called on each created feature layer. Useful for attaching events and popups to features. 64 | * 65 | */ 66 | @JsProperty 67 | public OnEachFeatureFunction onEachFeature; 68 | 69 | /** 70 | * Function that will be used to decide whether to show a feature or not. 71 | */ 72 | @JsProperty 73 | public FilterFunction filter; 74 | 75 | /** 76 | * Function that will be used for converting GeoJSON coordinates to LatLng points (if not specified, coords will be assumed to be WGS84 standard [longitude, latitude] values in degrees). 77 | */ 78 | @JsProperty 79 | public CoordsToLatLngFunction coordsToLatLng; 80 | 81 | @JsFunction 82 | public interface PointToLayerFunction { 83 | 84 | /** 85 | * Function that will be used for creating layers for GeoJSON points (if not specified, simple markers will be created). 86 | * 87 | * @param feature data 88 | * @param latLng the latlng 89 | */ 90 | Marker apply(JsObject feature, LatLng latLng); 91 | 92 | } 93 | 94 | @JsFunction 95 | public interface StyleFunction { 96 | 97 | /** 98 | * Function that will be used to get style options for vector layers created for GeoJSON features. 99 | * 100 | * @param featureData the feature data 101 | * @return the function 102 | */ 103 | JsObject apply(JsObject featureData); 104 | 105 | } 106 | 107 | @JsFunction 108 | public interface OnEachFeatureFunction { 109 | 110 | /** 111 | * Function that will be called on each created feature layer. Useful for attaching events and popups to features. 112 | * 113 | * @param featureData the feature data 114 | * @param layer the layer 115 | */ 116 | JsObject apply(JsObject featureData, Layer layer); 117 | 118 | } 119 | 120 | @JsFunction 121 | public interface FilterFunction { 122 | /** 123 | * Function that will be used to decide whether to show a feature or not. 124 | * 125 | * @param feature the feature data 126 | * @param layer the layer 127 | */ 128 | JsObject apply(JsObject feature, Layer layer); 129 | 130 | } 131 | 132 | @JsFunction 133 | public interface CoordsToLatLngFunction { 134 | 135 | /** 136 | * Function that will be used for converting GeoJSON coordinates to LatLng points (if not specified, coords will be assumed to be WGS84 standard [longitude, latitude] values in degrees). 137 | * 138 | * @param coords the coords 139 | * @param layer layer 140 | */ 141 | LatLng apply(JsObject coords, Layer layer); 142 | } 143 | 144 | } 145 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/options/GridLayerOptions.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet.options; 2 | 3 | import static jsinterop.annotations.JsPackage.GLOBAL; 4 | 5 | import com.gwidgets.api.leaflet.LatLngBounds; 6 | 7 | import jsinterop.annotations.JsOverlay; 8 | import jsinterop.annotations.JsType; 9 | 10 | /** 11 | *

GridLayerOptions class.

12 | * 13 | * @author zakaria 14 | * @version $Id: $Id 15 | */ 16 | @JsType(isNative=true, namespace=GLOBAL, name="Object") 17 | public class GridLayerOptions { 18 | 19 | 20 | private double tileSize; 21 | 22 | private double opacity; 23 | 24 | private boolean updateWhenIdle; 25 | 26 | private boolean updateWhenZooming; 27 | 28 | private double updateInterval; 29 | 30 | private String attribution; 31 | 32 | private double zIndex; 33 | 34 | private LatLngBounds bounds; 35 | 36 | private double minZoom; 37 | 38 | private double maxZoom; 39 | 40 | private boolean noWrap; 41 | 42 | private String pane; 43 | 44 | private String className; 45 | 46 | private double keepBuffer; 47 | 48 | private GridLayerOptions(){ 49 | 50 | } 51 | 52 | /** 53 | *

Getter for the field tileSize.

54 | * 55 | * @return a double 56 | */ 57 | @JsOverlay 58 | public final double getTileSize() { 59 | return this.tileSize; 60 | } 61 | 62 | /** 63 | *

Getter for the field opacity.

64 | * 65 | * @return a double 66 | */ 67 | @JsOverlay 68 | public final double getOpacity() { 69 | return this.opacity; 70 | } 71 | 72 | /** 73 | *

Getter for the field updateWhenIdle.

74 | * 75 | * @return a boolean 76 | */ 77 | @JsOverlay 78 | public final boolean getUpdateWhenIdle() { 79 | return this.updateWhenIdle; 80 | } 81 | 82 | /** 83 | *

Getter for the field updateWhenZooming.

84 | * 85 | * @return a boolean 86 | */ 87 | @JsOverlay 88 | public final boolean getUpdateWhenZooming() { 89 | return this.updateWhenZooming; 90 | } 91 | 92 | 93 | /** 94 | *

Getter for the field updateInterval.

95 | * 96 | * @return a double 97 | */ 98 | @JsOverlay 99 | public final double getUpdateInterval() { 100 | return this.updateInterval; 101 | } 102 | 103 | /** 104 | *

Getter for the field attribution.

105 | * 106 | * @return a {@link java.lang.String} object 107 | */ 108 | @JsOverlay 109 | public final String getAttribution() { 110 | return this.attribution; 111 | } 112 | 113 | /** 114 | *

Getter for the field zIndex.

115 | * 116 | * @return a double 117 | */ 118 | @JsOverlay 119 | public final double getzIndex() { 120 | return this.zIndex; 121 | } 122 | 123 | 124 | /** 125 | *

Getter for the field bounds.

126 | * 127 | * @return a {@link com.gwidgets.api.leaflet.LatLngBounds} object 128 | */ 129 | @JsOverlay 130 | public final LatLngBounds getBounds() { 131 | return this.bounds; 132 | } 133 | 134 | /** 135 | *

Getter for the field minZoom.

136 | * 137 | * @return a double 138 | */ 139 | @JsOverlay 140 | public final double getMinZoom() { 141 | return this.minZoom; 142 | } 143 | 144 | /** 145 | *

Getter for the field maxZoom.

146 | * 147 | * @return a double 148 | */ 149 | @JsOverlay 150 | public final double getMaxZoom() { 151 | return this.maxZoom; 152 | } 153 | 154 | /** 155 | *

Getter for the field noWrap.

156 | * 157 | * @return a boolean 158 | */ 159 | @JsOverlay 160 | public final boolean getNoWrap() { 161 | return this.noWrap; 162 | } 163 | 164 | /** 165 | *

Getter for the field pane.

166 | * 167 | * @return a {@link java.lang.String} object 168 | */ 169 | @JsOverlay 170 | public final String getPane() { 171 | return this.pane; 172 | } 173 | 174 | /** 175 | *

Getter for the field className.

176 | * 177 | * @return a {@link java.lang.String} object 178 | */ 179 | @JsOverlay 180 | public final String getClassName() { 181 | return this.className; 182 | } 183 | 184 | /** 185 | *

Getter for the field keepBuffer.

186 | * 187 | * @return a double 188 | */ 189 | @JsOverlay 190 | public final double getKeepBuffer() { 191 | return this.keepBuffer; 192 | } 193 | 194 | public static class Builder{ 195 | 196 | private Double tileSize; 197 | 198 | private Double opacity; 199 | 200 | private Boolean updateWhenIdle; 201 | 202 | private Boolean updateWhenZooming; 203 | 204 | private Double updateInterval; 205 | 206 | private String attribution; 207 | 208 | private Double zIndex; 209 | 210 | private LatLngBounds bounds; 211 | 212 | private Double minZoom; 213 | 214 | private Double maxZoom; 215 | 216 | private Boolean noWrap; 217 | 218 | private String pane; 219 | 220 | private String className; 221 | 222 | private Double keepBuffer; 223 | 224 | public Builder(){ 225 | 226 | 227 | } 228 | 229 | public Builder tileSize(Double tileSize){this.tileSize = tileSize; return this;} 230 | 231 | public Builder opacity(Double opacity){this.opacity = opacity; return this;} 232 | 233 | public Builder updateWhenIdle(Boolean updateWhenIdle){this.updateWhenIdle = updateWhenIdle; return this;} 234 | 235 | public Builder updateWhenZooming(Boolean updateWhenZooming){this.updateWhenZooming = updateWhenZooming; return this;} 236 | 237 | public Builder updateInterval(Double updateInterval){this.updateInterval = updateInterval; return this;} 238 | 239 | public Builder attribution(String attribution){this.attribution = attribution; return this;} 240 | 241 | public Builder zIndex(Double zIndex){this.zIndex = zIndex; return this;} 242 | 243 | public Builder bounds(LatLngBounds bounds){this.bounds = bounds; return this;} 244 | 245 | public Builder minZoom(Double minZoom){this.minZoom = minZoom; return this;} 246 | 247 | public Builder maxZoom(Double maxZoom){this.maxZoom = maxZoom; return this;} 248 | 249 | public Builder noWrap(Boolean noWrap){this.noWrap = noWrap; return this;} 250 | 251 | public Builder pane(String pane){this.pane = pane; return this;} 252 | 253 | public Builder className(String className){this.className = className; return this;} 254 | 255 | public Builder keepBuffer(Double keepBuffer){this.keepBuffer = keepBuffer; return this;} 256 | 257 | public GridLayerOptions build(){ 258 | GridLayerOptions options = new GridLayerOptions(); 259 | if(this.tileSize != null) 260 | options.tileSize = this.tileSize; 261 | if(this.opacity != null) 262 | options.opacity = this.opacity; 263 | if(this.updateWhenIdle != null) 264 | options.updateWhenIdle = this.updateWhenIdle; 265 | if(this.updateWhenZooming != null) 266 | options.updateWhenZooming = this.updateWhenZooming; 267 | if(this.updateInterval != null) 268 | options.updateInterval = this.updateInterval; 269 | if(this.attribution != null) 270 | options.attribution = this.attribution; 271 | if(this.zIndex != null) 272 | options.zIndex = this.zIndex; 273 | if(this.bounds != null) 274 | options.bounds = this.bounds; 275 | if(this.minZoom != null) 276 | options.minZoom = this.minZoom; 277 | if(this.maxZoom != null) 278 | options.maxZoom = this.maxZoom; 279 | if(this.noWrap != null) 280 | options.noWrap = this.noWrap; 281 | if(this.pane != null) 282 | options.pane = this.pane; 283 | if(this.className != null) 284 | options.className = this.className; 285 | if(this.keepBuffer != null) 286 | options.keepBuffer = this.keepBuffer; 287 | 288 | return options; 289 | } 290 | } 291 | } 292 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/options/ImageOverlayOptions.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 G-Widgets 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | package com.gwidgets.api.leaflet.options; 16 | 17 | import static jsinterop.annotations.JsPackage.GLOBAL; 18 | 19 | import jsinterop.annotations.JsOverlay; 20 | import jsinterop.annotations.JsProperty; 21 | import jsinterop.annotations.JsType; 22 | 23 | 24 | 25 | /** 26 | * The Class ImageOverlayOptions. 27 | * 28 | * @author Zakaria Amine 29 | */ 30 | @JsType(isNative=true, namespace=GLOBAL, name="Object") 31 | public class ImageOverlayOptions { 32 | 33 | private ImageOverlayOptions() { 34 | 35 | } 36 | 37 | @JsProperty 38 | private double opacity; 39 | 40 | @JsProperty 41 | private String attribution; 42 | 43 | @JsProperty 44 | private String alt; 45 | 46 | @JsProperty 47 | private boolean interactive; 48 | 49 | @JsProperty 50 | private boolean crossOrigin; 51 | 52 | @JsProperty 53 | private String pane; 54 | 55 | /** 56 | * Gets The opacity of the image overlay. 57 | * 58 | * @return the opacity 59 | */ 60 | @JsOverlay public final double getOpacity() { 61 | return this.opacity; 62 | } 63 | 64 | /** 65 | * Gets The attribution text of the image overlay. empty by default 66 | * 67 | * @return the attribution 68 | */ 69 | @JsOverlay public final String getAttribution() { 70 | return this.attribution; 71 | } 72 | 73 | @JsOverlay public final String getAlt() { 74 | return this.alt; 75 | } 76 | 77 | @JsOverlay public final boolean getInteractive() { 78 | return this.interactive; 79 | } 80 | 81 | @JsOverlay public final boolean getCrossOrigin() { 82 | return this.crossOrigin; 83 | } 84 | 85 | @JsOverlay public final String getPane() { 86 | return this.pane; 87 | } 88 | 89 | /** 90 | * The Class Builder. 91 | */ 92 | public static class Builder { 93 | 94 | private Double opacity; 95 | 96 | private String attribution; 97 | 98 | private String alt; 99 | 100 | private Boolean interactive; 101 | 102 | private Boolean crossOrigin; 103 | 104 | private String pane; 105 | 106 | /** 107 | * Instantiates a new builder. 108 | */ 109 | public Builder() { 110 | 111 | } 112 | 113 | /** 114 | * The opacity of the image overlay. 115 | * 116 | * default 1.0 117 | * @param opacity the opacity 118 | * @return the builder 119 | */ 120 | public Builder opacity(Double opacity){ 121 | this.opacity = opacity; 122 | return this; 123 | } 124 | 125 | /** 126 | * The attribution text of the image overlay. 127 | * 128 | * default empty 129 | * @param attribution the attribution 130 | * @return the builder 131 | */ 132 | public Builder attribution(String attribution){ 133 | this.attribution = attribution; 134 | return this; 135 | } 136 | 137 | 138 | public Builder alt(String alt){this.alt = alt; return this;} 139 | 140 | public Builder interactive(Boolean interactive){this.interactive = interactive; return this;} 141 | 142 | public Builder crossOrigin(Boolean crossOrigin){this.crossOrigin = crossOrigin; return this;} 143 | 144 | public Builder pane(String pane){this.pane = pane; return this;} 145 | 146 | /** 147 | * Builds the ImageOverlayOptions instance 148 | * 149 | * @return the image overlay options 150 | */ 151 | public ImageOverlayOptions build(){ 152 | ImageOverlayOptions options = new ImageOverlayOptions(); 153 | if(this.opacity != null) 154 | options.opacity = this.opacity; 155 | if(this.attribution != null) 156 | options.attribution = this.attribution; 157 | if(this.alt != null) 158 | options.alt = this.alt; 159 | if(this.interactive != null) 160 | options.interactive = this.interactive; 161 | if(this.crossOrigin != null) 162 | options.crossOrigin = this.crossOrigin; 163 | if(this.pane != null) 164 | options.pane = this.pane; 165 | 166 | return options; 167 | } 168 | } 169 | } -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/options/LocateOptions.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 G-Widgets 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | package com.gwidgets.api.leaflet.options; 16 | 17 | import static jsinterop.annotations.JsPackage.GLOBAL; 18 | 19 | import jsinterop.annotations.JsOverlay; 20 | import jsinterop.annotations.JsProperty; 21 | import jsinterop.annotations.JsType; 22 | 23 | /** 24 | * The Class LocateOptions. 25 | * 26 | * @author Zakaria Amine 27 | */ 28 | @JsType(isNative = true, namespace = GLOBAL, name = "Object") 29 | public class LocateOptions { 30 | 31 | private LocateOptions() { 32 | 33 | } 34 | 35 | @JsProperty 36 | private boolean watch; 37 | 38 | @JsProperty 39 | private boolean setView; 40 | 41 | @JsProperty 42 | private double maxZoom; 43 | 44 | @JsProperty 45 | private double timeout; 46 | 47 | @JsProperty 48 | private double maximumAge; 49 | 50 | @JsProperty 51 | private boolean enableHighAccuracy; 52 | 53 | /** 54 | * Gets whether continuous watching of location changes (instead of 55 | * detecting it once) using W3C watchPosition method is set. 56 | * default false 57 | * 58 | * @return the watch 59 | */ 60 | @JsOverlay 61 | public final boolean getWatch() { 62 | return this.watch; 63 | } 64 | 65 | /** 66 | * Gets whether If true, automatically sets the map view to the user 67 | * location with respect to detection accuracy, or to world view if 68 | * geolocation failed. 69 | * default false 70 | * 71 | * @return the sets the view 72 | */ 73 | @JsOverlay 74 | public final boolean getSetView() { 75 | return this.setView; 76 | } 77 | 78 | /** 79 | * Gets the maximum zoom for automatic view setting when using `setView` 80 | * option. 81 | * default infinity 82 | * 83 | * @return the max zoom locate 84 | */ 85 | @JsOverlay 86 | public final double getMaxZoom() { 87 | return this.maxZoom; 88 | } 89 | 90 | /** 91 | * Gets the number of milliseconds to wait for a response from geolocation 92 | * before firing a locationerror event. 93 | * default 10000 94 | * 95 | * @return the timeout 96 | */ 97 | @JsOverlay 98 | public final double getTimeout() { 99 | return this.timeout; 100 | } 101 | 102 | /** 103 | * Gets the maximum age of detected location. If less than this amount of 104 | * milliseconds passed since last geolocation response, locate will return a 105 | * cached location. 106 | * default 0 107 | * 108 | * @return the maximum age 109 | */ 110 | @JsOverlay 111 | public final double getMaximumAge() { 112 | return this.maximumAge; 113 | } 114 | 115 | /** 116 | * Gets whether high accuracy is enabled, see description in 117 | * the 118 | * W3C spec . 119 | * default false 120 | * 121 | * @return the enable high accuracy 122 | */ 123 | @JsOverlay 124 | public final boolean getEnableHighAccuracy() { 125 | return this.enableHighAccuracy; 126 | } 127 | 128 | /** 129 | * The Class Builder. 130 | */ 131 | public static class Builder { 132 | 133 | private Boolean watch; 134 | 135 | private Boolean setView; 136 | 137 | private Double maxZoom; 138 | 139 | private Double timeout; 140 | 141 | private Double maximumAge; 142 | 143 | private Boolean enableHighAccuracy; 144 | 145 | /** 146 | * Instantiates a new builder. 147 | */ 148 | public Builder() { 149 | 150 | } 151 | 152 | /** 153 | * If true, starts continuous watching of location changes (instead of 154 | * detecting it once) using W3C watchPosition method. You can later stop 155 | * watching using map.stopLocate() method. 156 | * default false 157 | * 158 | * @param watch 159 | * the watch 160 | * @return the builder 161 | */ 162 | public Builder watch(Boolean watch) { 163 | this.watch = watch; 164 | return this; 165 | } 166 | 167 | /** 168 | * If true, automatically sets the map view to the user location with 169 | * respect to detection accuracy, or to world view if geolocation 170 | * failed. 171 | * default false 172 | * 173 | * @param setView 174 | * the set view 175 | * @return the builder 176 | */ 177 | public Builder setView(Boolean setView) { 178 | this.setView = setView; 179 | return this; 180 | } 181 | 182 | /** 183 | * The maximum zoom for automatic view setting when using `setView` 184 | * option. 185 | * default infinity 186 | * 187 | * @param maxZoom 188 | * the max zoom locate 189 | * @return the builder 190 | */ 191 | public Builder maxZoom(double maxZoom) { 192 | this.maxZoom = maxZoom; 193 | return this; 194 | } 195 | 196 | /** 197 | * Number of milliseconds to wait for a response from geolocation before 198 | * firing a locationerror event.Timeout. 199 | * default 10000 200 | * 201 | * @param timeout 202 | * the timeout 203 | * @return the builder 204 | */ 205 | public Builder timeout(double timeout) { 206 | this.timeout = timeout; 207 | return this; 208 | } 209 | 210 | /** 211 | * Maximum age of detected location. If less than this amount of 212 | * milliseconds passed since last geolocation response, locate will 213 | * return a cached location. 214 | * default 0 215 | * 216 | * @param maximumAge 217 | * the maximum age 218 | * @return the builder 219 | */ 220 | public Builder maximumAge(double maximumAge) { 221 | this.maximumAge = maximumAge; 222 | return this; 223 | } 224 | 225 | /** 226 | * Gets whether high accuracy is enabled, see description in the W3C 228 | * spec . 229 | * default false 230 | * 231 | * @param enableHighAccuracy 232 | * the enable high accuracy 233 | * @return the builder 234 | */ 235 | public Builder enableHighAccuracy(Boolean enableHighAccuracy) { 236 | this.enableHighAccuracy = enableHighAccuracy; 237 | return this; 238 | } 239 | 240 | /** 241 | * Builds the LocateOptions new instance 242 | * 243 | * @return the locate options 244 | */ 245 | public LocateOptions build() { 246 | LocateOptions options = new LocateOptions(); 247 | if(this.watch != null) 248 | options.watch = this.watch; 249 | if(this.setView != null) 250 | options.setView = this.setView; 251 | if(this.maxZoom != null) 252 | options.maxZoom = this.maxZoom; 253 | if(this.timeout != null) 254 | options.timeout = this.timeout; 255 | if(this.maximumAge != null) 256 | options.maximumAge = this.maximumAge; 257 | if(this.enableHighAccuracy != null) 258 | options.enableHighAccuracy = this.enableHighAccuracy; 259 | 260 | return options; 261 | } 262 | } 263 | } -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/options/PanOptions.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 G-Widgets 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | package com.gwidgets.api.leaflet.options; 16 | 17 | import static jsinterop.annotations.JsPackage.GLOBAL; 18 | 19 | import jsinterop.annotations.JsOverlay; 20 | import jsinterop.annotations.JsProperty; 21 | import jsinterop.annotations.JsType; 22 | 23 | /** 24 | * The Class PanOptions. 25 | * 26 | * @author Zakaria Amine 27 | */ 28 | @JsType(isNative=true, namespace=GLOBAL, name="Object") 29 | public class PanOptions { 30 | 31 | 32 | private PanOptions() { 33 | 34 | } 35 | 36 | 37 | @JsProperty 38 | private double duration; 39 | 40 | @JsProperty 41 | private double easeLinearity; 42 | 43 | @JsProperty 44 | private boolean noMoveStart; 45 | 46 | 47 | 48 | /** 49 | * Gets the duration of animated panning. 50 | * 51 | * default 0.25 52 | * @return the duration 53 | */ 54 | @JsOverlay public final double getDuration() { 55 | return this.duration; 56 | } 57 | 58 | 59 | 60 | 61 | /** 62 | * Gets The curvature factor of panning animation easing (third parameter of the Cubic Bezier curve). 1.0 means linear animation, the less the more bowed the curve. 63 | * 64 | * default 0.25 65 | * @return the ease linearity 66 | */ 67 | @JsOverlay public final double getEaseLinearity() { 68 | return this.easeLinearity; 69 | } 70 | 71 | 72 | 73 | 74 | /** 75 | * Gets whether If true, panning won't fire movestart event on start (used internally for panning inertia). 76 | * 77 | * default false 78 | * @return the no move start 79 | */ 80 | @JsOverlay public final boolean getNoMoveStart() { 81 | return this.noMoveStart; 82 | } 83 | 84 | 85 | 86 | 87 | /** 88 | * The Class Builder. 89 | */ 90 | public static class Builder { 91 | private Double duration; 92 | 93 | private Double easeLinearity; 94 | 95 | private Boolean noMoveStart; 96 | 97 | /** 98 | * Instantiates a new builder. 99 | */ 100 | public Builder() { 101 | 102 | } 103 | 104 | 105 | /** 106 | * Duration of animated panning. 107 | * 108 | * default 0.25 109 | * @param duration the duration 110 | * @return the builder 111 | */ 112 | public Builder duration(Double duration){this.duration = duration; return this;} 113 | 114 | /** 115 | * The curvature factor of panning animation easing (third parameter of the Cubic Bezier curve). 1.0 means linear animation, the less the more bowed the curve. 116 | * 117 | * default 0.25 118 | * @param easeLinearity the ease linearity 119 | * @return the builder 120 | */ 121 | public Builder easeLinearity(Double easeLinearity){this.easeLinearity = easeLinearity; return this;} 122 | 123 | /** 124 | * If true, panning won't fire movestart event on start (used internally for panning inertia). 125 | * 126 | * default false 127 | * @param noMoveStart the no move start 128 | * @return the builder 129 | */ 130 | public Builder noMoveStart(Boolean noMoveStart){this.noMoveStart = noMoveStart; return this;} 131 | 132 | 133 | /** 134 | * Builds the PanOptions new instance 135 | * 136 | * @return the pan options 137 | */ 138 | public PanOptions build(){ 139 | PanOptions options = new PanOptions(); 140 | if(this.duration != null) 141 | options.duration = this.duration; 142 | if(this.easeLinearity != null) 143 | options.easeLinearity = this.easeLinearity; 144 | if(this.noMoveStart != null) 145 | options.noMoveStart = this.noMoveStart; 146 | 147 | return options; 148 | } 149 | } 150 | } -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/options/RendererOptions.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet.options; 2 | 3 | import static jsinterop.annotations.JsPackage.GLOBAL; 4 | 5 | import jsinterop.annotations.JsOverlay; 6 | import jsinterop.annotations.JsProperty; 7 | import jsinterop.annotations.JsType; 8 | 9 | /** 10 | *

RendererOptions class.

11 | * 12 | * @author zakaria 13 | * @version $Id: $Id 14 | */ 15 | @JsType(isNative=true, namespace=GLOBAL, name="Object") 16 | public class RendererOptions { 17 | 18 | @JsProperty 19 | private double padding; 20 | 21 | @JsProperty 22 | private String pane; 23 | 24 | @JsProperty 25 | private String attribution; 26 | /********************************************** 27 | *********************************************/ 28 | 29 | private RendererOptions() { 30 | 31 | } 32 | 33 | /** 34 | *

Getter for the field padding.

35 | * 36 | * @return a double 37 | */ 38 | @JsOverlay 39 | public final double getPadding() { 40 | return this.padding; 41 | } 42 | 43 | /** 44 | *

Getter for the field pane.

45 | * 46 | * @return a {@link java.lang.String} object 47 | */ 48 | @JsOverlay 49 | public final String getPane() { 50 | return this.pane; 51 | } 52 | 53 | /** 54 | *

Getter for the field attribution.

55 | * 56 | * @return a {@link java.lang.String} object 57 | */ 58 | @JsOverlay 59 | public final String getAttribution() { 60 | return this.attribution; 61 | } 62 | 63 | 64 | public static class Builder{ 65 | 66 | 67 | private Double padding; 68 | 69 | private String pane; 70 | 71 | private String attribution; 72 | 73 | 74 | public Builder(){ 75 | 76 | 77 | } 78 | 79 | public Builder padding(Double padding){ 80 | this.padding = padding; 81 | return this; 82 | } 83 | 84 | public Builder pane(String pane){ 85 | this.pane = pane; 86 | return this; 87 | } 88 | 89 | public Builder attribution(String attribution){this.attribution = attribution; return this;} 90 | 91 | public RendererOptions build(){ 92 | RendererOptions rendererOptions = new RendererOptions(); 93 | if(this.padding != null) 94 | rendererOptions.padding = this.padding; 95 | if(this.pane != null) 96 | rendererOptions.pane = this.pane; 97 | if(this.attribution != null) 98 | rendererOptions.attribution = this.attribution; 99 | 100 | return rendererOptions; 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/options/TooltipOptions.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 G-Widgets 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | package com.gwidgets.api.leaflet.options; 16 | 17 | import static jsinterop.annotations.JsPackage.GLOBAL; 18 | import com.gwidgets.api.leaflet.Point; 19 | 20 | import jsinterop.annotations.JsOverlay; 21 | import jsinterop.annotations.JsProperty; 22 | import jsinterop.annotations.JsType; 23 | 24 | /** 25 | * The Class TooltipOptions. 26 | * 27 | * @author Zakaria Amine 28 | * @version $Id: $Id 29 | */ 30 | @JsType(isNative=true, namespace=GLOBAL, name="Object") 31 | public class TooltipOptions { 32 | 33 | @JsProperty 34 | private String pane; 35 | 36 | @JsProperty 37 | private Point offset; 38 | 39 | @JsProperty 40 | private boolean permanent; 41 | 42 | @JsProperty 43 | private String direction; 44 | 45 | @JsProperty 46 | private boolean sticky; 47 | 48 | @JsProperty 49 | private boolean interactive; 50 | 51 | @JsProperty 52 | private double opacity; 53 | 54 | /***************************************** 55 | ********************************************/ 56 | @JsProperty 57 | private String className; 58 | /********************************************** 59 | *********************************************/ 60 | 61 | /***************************************** 62 | ********************************************/ 63 | @JsProperty 64 | private String attribution; 65 | /********************************************** 66 | *********************************************/ 67 | 68 | 69 | private TooltipOptions(){ 70 | 71 | 72 | } 73 | 74 | 75 | 76 | /** 77 | * Returns the popup bound to this layer. 78 | * 79 | * @return a {@link java.lang.String} object 80 | */ 81 | @JsOverlay 82 | public final String getPane() { 83 | return this.pane; 84 | } 85 | 86 | 87 | 88 | /** 89 | * Optional offset of the tooltip position. 90 | * 91 | * @return a {@link com.gwidgets.api.leaflet.Point} object 92 | */ 93 | @JsOverlay 94 | public final Point getOffset() { 95 | return this.offset; 96 | } 97 | 98 | /** 99 | * Whether to open the tooltip permanently or only on mouseover. 100 | * 101 | * @return a boolean 102 | */ 103 | @JsOverlay 104 | public final boolean getPermanent() { 105 | return this.permanent; 106 | } 107 | 108 | 109 | /** 110 | * Direction where to open the tooltip. Possible values are: right, left, top, bottom, center, auto. auto will dynamicaly switch between right and left according to the tooltip position on the map. 111 | * 112 | * @return a {@link java.lang.String} object 113 | */ 114 | @JsOverlay 115 | public final String getDirection() { 116 | return this.direction; 117 | } 118 | 119 | 120 | 121 | 122 | /** 123 | * If true, the tooltip will follow the mouse instead of being fixed at the feature center. 124 | * 125 | * @return a boolean 126 | */ 127 | @JsOverlay 128 | public final boolean getSticky() { 129 | return this.sticky; 130 | } 131 | 132 | 133 | 134 | /** 135 | * If true, the tooltip will listen to the feature events. 136 | * 137 | * @return a boolean 138 | */ 139 | @JsOverlay 140 | public final boolean getInteractive() { 141 | return this.interactive; 142 | } 143 | 144 | 145 | 146 | /** 147 | * Tooltip container opacity. 148 | * 149 | * @return a double 150 | */ 151 | @JsOverlay 152 | public final double getOpacity() { 153 | return this.opacity; 154 | } 155 | 156 | 157 | 158 | 159 | 160 | /** 161 | *

Getter for the field className.

162 | * 163 | * @return a {@link java.lang.String} object 164 | */ 165 | @JsOverlay 166 | public final String getClassName() { 167 | return this.className; 168 | } 169 | 170 | 171 | /** 172 | *

Getter for the field attribution.

173 | * 174 | * @return a {@link java.lang.String} object 175 | */ 176 | @JsOverlay 177 | public final String getAttribution() { 178 | return this.attribution; 179 | } 180 | 181 | 182 | 183 | 184 | 185 | public static class Builder{ 186 | 187 | private String pane; 188 | 189 | private Point offset; 190 | 191 | private Boolean permanent; 192 | 193 | private String direction; 194 | 195 | private Boolean sticky; 196 | 197 | private Boolean interactive; 198 | 199 | private Double opacity; 200 | 201 | private String className; 202 | 203 | private String attribution; 204 | 205 | 206 | public Builder(){ 207 | 208 | 209 | } 210 | 211 | /** Returns the popup bound to this layer. 212 | * @return Builder 213 | */ 214 | public Builder pane(String pane){this.pane = pane; return this;} 215 | 216 | /** Optional offset of the tooltip position. 217 | * @return Builder 218 | */ 219 | public Builder offset(Point offset){this.offset = offset; return this;} 220 | 221 | 222 | /** Whether to open the tooltip permanently or only on mouseover. 223 | * @return Builder 224 | */ 225 | public Builder permanent(Boolean permanent){this.permanent = permanent; return this;} 226 | 227 | 228 | /** Direction where to open the tooltip. Possible values are: right, left, top, bottom, center, auto. auto will dynamicaly switch between right and left according to the tooltip position on the map. 229 | * @return Builder 230 | */ 231 | public Builder direction(String direction){this.direction = direction; return this;} 232 | 233 | 234 | /** If true, the tooltip will follow the mouse instead of being fixed at the feature center. 235 | * @return Builder 236 | */ 237 | public Builder sticky(Boolean sticky){this.sticky = sticky; return this;} 238 | 239 | 240 | /** If true, the tooltip will listen to the feature events. 241 | * @return Builder 242 | */ 243 | public Builder interactive(Boolean interactive){this.interactive = interactive; return this;} 244 | 245 | 246 | /** Tooltip container opacity. 247 | * @return Builder 248 | */ 249 | public Builder opacity(Double opacity){this.opacity = opacity; return this;} 250 | 251 | public Builder className(String className){this.className = className; return this;} 252 | 253 | public Builder attribution(String attribution){this.attribution = attribution; return this;} 254 | 255 | 256 | public TooltipOptions build(){ 257 | TooltipOptions toolTipOptions = new TooltipOptions(); 258 | if(this.pane != null) 259 | toolTipOptions.pane = this.pane; 260 | if(this.offset != null) 261 | toolTipOptions.offset = this.offset; 262 | if(this.direction != null) 263 | toolTipOptions.direction = this.direction; 264 | if(this.permanent != null) 265 | toolTipOptions.permanent = this.permanent; 266 | if(this.sticky != null) 267 | toolTipOptions.sticky = this.sticky; 268 | if(this.interactive != null) 269 | toolTipOptions.interactive = this.interactive; 270 | if(this.opacity != null) 271 | toolTipOptions.opacity = this.opacity; 272 | if(this.attribution != null) 273 | toolTipOptions.attribution = this.attribution; 274 | if(this.className != null) 275 | toolTipOptions.className = this.className; 276 | 277 | return toolTipOptions; 278 | } 279 | } 280 | } 281 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/options/ZoomOptions.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 G-Widgets 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | package com.gwidgets.api.leaflet.options; 16 | 17 | import static jsinterop.annotations.JsPackage.GLOBAL; 18 | 19 | import jsinterop.annotations.JsOverlay; 20 | import jsinterop.annotations.JsProperty; 21 | import jsinterop.annotations.JsType; 22 | 23 | 24 | /** 25 | * The Class ZoomOptions. 26 | * 27 | * @author Zakaria Amine 28 | */ 29 | @JsType(isNative=true, namespace=GLOBAL, name="Object") 30 | public class ZoomOptions { 31 | 32 | 33 | private ZoomOptions() { 34 | 35 | } 36 | 37 | @JsProperty 38 | private boolean animate; 39 | 40 | 41 | /** 42 | * Gets whether zoom animation will happen if the zoom origin is inside the current view. If true, the map will attempt animating zoom disregarding where zoom origin is. Setting false will make it always reset the view completely without animation. 43 | * 44 | * default true 45 | * @return the animate 46 | */ 47 | @JsOverlay public final boolean getAnimate() { 48 | return this.animate; 49 | } 50 | 51 | 52 | /** 53 | * The Class Builder. 54 | */ 55 | public static class Builder { 56 | 57 | 58 | 59 | private Boolean animate; 60 | 61 | /** 62 | * Instantiates a new builder. 63 | */ 64 | public Builder() { 65 | 66 | } 67 | 68 | /** 69 | * zoom animation will happen if the zoom origin is inside the current view. If true, the map will attempt animating zoom disregarding where zoom origin is. Setting false will make it always reset the view completely without animation. 70 | * 71 | * default true 72 | * 73 | * @param animate the animate 74 | * @return the builder 75 | */ 76 | public Builder animate(Boolean animate){ 77 | 78 | this.animate = animate; 79 | 80 | return this; 81 | } 82 | 83 | /** 84 | * Builds the ZoomOptions new instance 85 | * 86 | * @return the zoom options 87 | */ 88 | public ZoomOptions build(){ 89 | ZoomOptions options = new ZoomOptions(); 90 | if(this.animate != null) 91 | options.animate = this.animate; 92 | 93 | return options; 94 | } 95 | 96 | } 97 | 98 | } -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/options/ZoomPanOptions.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2016 G-Widgets 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | package com.gwidgets.api.leaflet.options; 16 | 17 | import static jsinterop.annotations.JsPackage.GLOBAL; 18 | 19 | import jsinterop.annotations.JsOverlay; 20 | import jsinterop.annotations.JsProperty; 21 | import jsinterop.annotations.JsType; 22 | 23 | /** 24 | * The Class ZoomPanOptions. 25 | * 26 | * @author Zakaria Amine 27 | */ 28 | @JsType(isNative = true, namespace = GLOBAL, name = "Object") 29 | public class ZoomPanOptions { 30 | 31 | private ZoomPanOptions() { 32 | 33 | } 34 | 35 | @JsProperty 36 | private boolean reset; 37 | 38 | @JsProperty 39 | private PanOptions pan; 40 | 41 | @JsProperty 42 | private ZoomOptions zoom; 43 | 44 | @JsProperty 45 | private boolean animate; 46 | 47 | /** 48 | * Gets whether the map view will be completely reset (without any 49 | * animations). 50 | * default false 51 | * 52 | * @return the reset 53 | */ 54 | @JsOverlay 55 | public final boolean getReset() { 56 | return this.reset; 57 | } 58 | 59 | /** 60 | * Gets the options for the panning (without the zoom change) if it occurs. 61 | * 62 | * @return the pan 63 | */ 64 | @JsOverlay 65 | public final PanOptions getPan() { 66 | return this.pan; 67 | } 68 | 69 | /** 70 | * Gets the options for the zoom change if it occurs. 71 | * 72 | * @return the zoom 73 | */ 74 | @JsOverlay 75 | public final ZoomOptions getZoom() { 76 | return this.zoom; 77 | } 78 | 79 | /** 80 | * An equivalent of passing animate to both zoom and pan options (see below) 81 | * 82 | * default true 83 | * 84 | * @return the animate 85 | */ 86 | @JsOverlay 87 | public final boolean getAnimate() { 88 | return this.animate; 89 | } 90 | 91 | /** 92 | * The Class Builder. 93 | */ 94 | public static class Builder { 95 | 96 | /** The reset. */ 97 | private Boolean reset = false; 98 | 99 | /** The pan. */ 100 | private PanOptions pan; 101 | 102 | /** The zoom. */ 103 | private ZoomOptions zoom; 104 | 105 | /** The animate. */ 106 | private Boolean animate = true; 107 | 108 | /** 109 | * Instantiates a new builder. 110 | */ 111 | public Builder() { 112 | 113 | } 114 | 115 | /** 116 | * Reset. 117 | * 118 | * @param reset 119 | * the reset 120 | * @return the builder 121 | */ 122 | public Builder reset(Boolean reset) { 123 | this.reset = reset; 124 | return this; 125 | } 126 | 127 | /** 128 | * Pan. 129 | * 130 | * @param pan 131 | * the pan 132 | * @return the builder 133 | */ 134 | public Builder pan(PanOptions pan) { 135 | this.pan = pan; 136 | return this; 137 | } 138 | 139 | /** 140 | * Zoom. 141 | * 142 | * @param zoom 143 | * the zoom 144 | * @return the builder 145 | */ 146 | public Builder zoom(ZoomOptions zoom) { 147 | this.zoom = zoom; 148 | return this; 149 | } 150 | 151 | /** 152 | * Animate. 153 | * 154 | * @param animate 155 | * the animate 156 | * @return the builder 157 | */ 158 | public Builder animate(Boolean animate) { 159 | this.animate = animate; 160 | return this; 161 | } 162 | 163 | /** 164 | * Builds the. 165 | * 166 | * @return the zoom pan options 167 | */ 168 | public ZoomPanOptions build() { 169 | ZoomPanOptions options = new ZoomPanOptions(); 170 | if(this.animate != null) 171 | options.animate = this.animate; 172 | if(this.pan != null) 173 | options.pan = this.pan; 174 | if(this.zoom != null) 175 | options.zoom = this.zoom; 176 | if(this.reset != null) 177 | options.reset = this.reset; 178 | 179 | return options; 180 | } 181 | } 182 | } -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/utils/JsFn.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet.utils; 2 | 3 | import jsinterop.annotations.JsFunction; 4 | 5 | /** 6 | *

JsFn interface.

7 | * 8 | * @author zakaria 9 | * @version $Id: $Id 10 | */ 11 | @JsFunction 12 | public interface JsFn { 13 | 14 | /** 15 | *

apply.

16 | * 17 | * @param arg1 a {@link java.lang.Object} object 18 | * @return a {@link java.lang.Object} object 19 | */ 20 | Object apply(Object ... arg1); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/leaflet/utils/LeafletResources.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.api.leaflet.utils; 2 | 3 | import com.google.gwt.core.client.GWT; 4 | 5 | import elemental2.dom.DomGlobal; 6 | import elemental2.dom.Element; 7 | import elemental2.dom.HTMLLinkElement; 8 | import elemental2.dom.HTMLScriptElement; 9 | 10 | 11 | /** 12 | *

LeafletResources class.

13 | * 14 | * @author zakaria 15 | * @version $Id: $Id 16 | */ 17 | public class LeafletResources { 18 | /** 19 | *

whenReady.

20 | * 21 | * @param debug a boolean 22 | * @param function a {@link elemental2.dom.Element.OnloadFn} object 23 | */ 24 | public static void whenReady(boolean debug, Element.OnloadFn function){ 25 | HTMLScriptElement leafletScript = (HTMLScriptElement) DomGlobal.document.createElement("script"); 26 | if (debug) { 27 | leafletScript.src = GWT.getModuleName() + "/leaflet/leaflet-src.js"; 28 | } else { 29 | leafletScript.src = GWT.getModuleName() + "/leaflet/leaflet.js"; 30 | } 31 | leafletScript.type="text/javascript"; 32 | 33 | HTMLLinkElement leafletStyle = (HTMLLinkElement) DomGlobal.document.createElement("link"); 34 | leafletStyle.href=GWT.getModuleName()+"/leaflet/leaflet.css"; 35 | leafletStyle.rel="stylesheet"; 36 | 37 | 38 | DomGlobal.document.head.appendChild(leafletScript); 39 | DomGlobal.document.head.appendChild(leafletStyle); 40 | 41 | leafletScript.onload = function; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/public/leaflet/images/layers-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gwidgets/gwty-leaflet/b6372af7aab15fa07f0c18c184c782a8a1e94144/src/main/java/com/gwidgets/api/public/leaflet/images/layers-2x.png -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/public/leaflet/images/layers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gwidgets/gwty-leaflet/b6372af7aab15fa07f0c18c184c782a8a1e94144/src/main/java/com/gwidgets/api/public/leaflet/images/layers.png -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/public/leaflet/images/marker-icon-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gwidgets/gwty-leaflet/b6372af7aab15fa07f0c18c184c782a8a1e94144/src/main/java/com/gwidgets/api/public/leaflet/images/marker-icon-2x.png -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/public/leaflet/images/marker-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gwidgets/gwty-leaflet/b6372af7aab15fa07f0c18c184c782a8a1e94144/src/main/java/com/gwidgets/api/public/leaflet/images/marker-icon.png -------------------------------------------------------------------------------- /src/main/java/com/gwidgets/api/public/leaflet/images/marker-shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gwidgets/gwty-leaflet/b6372af7aab15fa07f0c18c184c782a8a1e94144/src/main/java/com/gwidgets/api/public/leaflet/images/marker-shadow.png -------------------------------------------------------------------------------- /src/test/java/com/gwidgets/leaflet/GwtyLeafletTest.gwt.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/test/java/com/gwidgets/leaflet/test/CRSTest.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.leaflet.test; 2 | 3 | import com.gwidgets.api.leaflet.CRS; 4 | import com.gwidgets.api.leaflet.L; 5 | import com.gwidgets.api.leaflet.LatLng; 6 | import com.gwidgets.api.leaflet.Point; 7 | 8 | 9 | public class CRSTest extends GwtyLeafletTestCase { 10 | 11 | 12 | public void testMapLoadEvent() { 13 | InjectedLeafletResources.whenReady((e) -> { 14 | CRS myCRS = L.CRS.EPSG3857; 15 | 16 | Point p = myCRS.project(L.latLng(52.12, 42.15)); 17 | 18 | LatLng unprojected = myCRS.unproject(p); 19 | 20 | assertEquals(unprojected.lat.toString().substring(0, 5), "52.12"); 21 | assertEquals(unprojected.lng.toString().substring(0, 5), "42.15"); 22 | 23 | double scaled = myCRS.scale(25); 24 | double zoomed = myCRS.zoom(scaled); 25 | 26 | 27 | assertEquals(String.valueOf(zoomed), "25"); 28 | 29 | return null; 30 | } 31 | ); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/com/gwidgets/leaflet/test/EventTest.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.leaflet.test; 2 | 3 | import com.gwidgets.api.leaflet.Canvas; 4 | import com.gwidgets.api.leaflet.Circle; 5 | import com.gwidgets.api.leaflet.CircleMarker; 6 | import com.gwidgets.api.leaflet.FeatureGroup; 7 | import com.gwidgets.api.leaflet.GeoJSON; 8 | import com.gwidgets.api.leaflet.GridLayer; 9 | import com.gwidgets.api.leaflet.ImageOverlay; 10 | import com.gwidgets.api.leaflet.L; 11 | import com.gwidgets.api.leaflet.LatLng; 12 | import com.gwidgets.api.leaflet.LayerGroup; 13 | import com.gwidgets.api.leaflet.Map; 14 | import com.gwidgets.api.leaflet.Marker; 15 | import com.gwidgets.api.leaflet.Polygon; 16 | import com.gwidgets.api.leaflet.Polyline; 17 | import com.gwidgets.api.leaflet.Popup; 18 | import com.gwidgets.api.leaflet.Rectangle; 19 | import com.gwidgets.api.leaflet.SVG; 20 | import com.gwidgets.api.leaflet.TileLayer; 21 | import com.gwidgets.api.leaflet.WMS; 22 | import com.gwidgets.api.leaflet.events.EventTypes; 23 | import com.gwidgets.api.leaflet.options.MapOptions; 24 | 25 | import elemental2.dom.DomGlobal; 26 | import elemental2.dom.HTMLElement; 27 | 28 | public class EventTest extends GwtyLeafletTestCase { 29 | 30 | public void testMapLoadEvent() { 31 | InjectedLeafletResources.whenReady((e) -> { 32 | 33 | 34 | 35 | HTMLElement div = (HTMLElement) DomGlobal.document.createElement("div"); 36 | div.id = "test9"; 37 | DomGlobal.document.body.appendChild(div); 38 | 39 | MapOptions options = new MapOptions.Builder(L.latLng(52.51, 13.40), 12.0, 7.0).maxZoom(20.0).build(); 40 | Map map = L.map("test9", options); 41 | 42 | map.on(EventTypes.MapEvents.LOAD, (event) -> { 43 | 44 | 45 | }); 46 | 47 | assertTrue(map.listens(EventTypes.MapEvents.LOAD)); 48 | 49 | return null; 50 | 51 | }); 52 | } 53 | 54 | public void testMarkerClickEvent() { 55 | InjectedLeafletResources.whenReady((e) -> { 56 | 57 | Marker marker = L.marker(L.latLng(52.51, 13.40), null); 58 | 59 | marker.on(EventTypes.MarkerEvents.CLICK, (event) -> { 60 | 61 | 62 | }); 63 | 64 | assertTrue(marker.listens(EventTypes.MarkerEvents.CLICK)); 65 | 66 | return null; 67 | 68 | }); 69 | } 70 | 71 | public void testPopupOpenEvent() { 72 | InjectedLeafletResources.whenReady((e) -> { 73 | 74 | Popup popup = L.popup(null, null); 75 | 76 | popup.on(EventTypes.PopupEvents.POPUPOPEN, (event) -> { 77 | 78 | }); 79 | 80 | assertTrue(popup.listens(EventTypes.PopupEvents.POPUPOPEN)); 81 | 82 | return null; 83 | 84 | }); 85 | } 86 | 87 | public void testTileLayerAddEvent() { 88 | InjectedLeafletResources.whenReady((e) -> { 89 | 90 | TileLayer tLayer = L.tileLayer("", null); 91 | 92 | tLayer.on(EventTypes.TileLayerEvents.ADD, (event) -> { 93 | 94 | }); 95 | 96 | assertTrue(tLayer.listens(EventTypes.TileLayerEvents.ADD)); 97 | 98 | return null; 99 | }); 100 | } 101 | 102 | public void testTileLayerWMSTileLoadEvent() { 103 | InjectedLeafletResources.whenReady((e) -> { 104 | 105 | WMS wms = L.tileLayer.wms("", null); 106 | 107 | wms.on(EventTypes.TileLayerWMSEvents.TILELOAD, (event) -> { 108 | 109 | }); 110 | 111 | assertTrue(wms.listens(EventTypes.TileLayerWMSEvents.TILELOAD)); 112 | 113 | return null; 114 | }); 115 | } 116 | 117 | public void testImageOverlayMouseOutEvent() { 118 | InjectedLeafletResources.whenReady((e) -> { 119 | 120 | ImageOverlay imgOverlay = L.imageOverlay("", null, null); 121 | 122 | imgOverlay.on(EventTypes.ImageOverlayEvents.MOUSEOUT, (event) -> { 123 | 124 | }); 125 | 126 | assertTrue(imgOverlay.listens(EventTypes.ImageOverlayEvents.MOUSEOUT)); 127 | 128 | return null; 129 | }); 130 | } 131 | 132 | 133 | public void testPolylineRemoveEvent() { 134 | InjectedLeafletResources.whenReady((e) -> { 135 | 136 | LatLng[] row = {L.latLng(52.51, 13.40)}; 137 | 138 | LatLng[][] latlngs = {row}; 139 | 140 | Polyline polyline = L.polyline(latlngs, null); 141 | 142 | polyline.on(EventTypes.PolylineEvents.REMOVE, (event) -> { 143 | 144 | }); 145 | 146 | assertTrue(polyline.listens(EventTypes.PolylineEvents.REMOVE)); 147 | 148 | return null; 149 | }); 150 | } 151 | 152 | public void testPolygonRemoveEvent() { 153 | InjectedLeafletResources.whenReady((e) -> { 154 | 155 | LatLng[] row = {L.latLng(52.51, 13.40)}; 156 | 157 | LatLng[][] latlngs = {row}; 158 | 159 | Polygon polygon = L.polygon(latlngs, null); 160 | 161 | polygon.on(EventTypes.PolygonEvents.REMOVE, (event) -> { 162 | 163 | }); 164 | 165 | assertTrue(polygon.listens(EventTypes.PolygonEvents.REMOVE)); 166 | 167 | return null; 168 | }); 169 | } 170 | 171 | public void testRectangleMouseDownEvent() { 172 | InjectedLeafletResources.whenReady((e) -> { 173 | 174 | 175 | 176 | Rectangle rect = L.rectangle(L.latLngBounds(L.latLng(12, 14), L.latLng(25, 42)), null); 177 | 178 | rect.on(EventTypes.RectangleEvents.MOUSEDOWN, (event) -> { 179 | 180 | }); 181 | 182 | assertTrue(rect.listens(EventTypes.RectangleEvents.MOUSEDOWN)); 183 | 184 | return null; 185 | }); 186 | } 187 | 188 | public void testCircleContextMenuEvent() { 189 | InjectedLeafletResources.whenReady((e) -> { 190 | 191 | Circle circ = L.circle(L.latLng(12, 14), null); 192 | 193 | circ.on(EventTypes.CircleEvents.CONTEXTMENU, (event) -> { 194 | 195 | }); 196 | 197 | assertTrue(circ.listens(EventTypes.CircleEvents.CONTEXTMENU)); 198 | 199 | return null; 200 | }); 201 | } 202 | 203 | public void testCircleMarkerMouseOutEvent() { 204 | InjectedLeafletResources.whenReady((e) -> { 205 | 206 | CircleMarker circ = L.circleMarker(L.latLng(12, 14), null); 207 | 208 | circ.on(EventTypes.CircleMakerEvents.MOUSEOUT, (event) -> { 209 | 210 | }); 211 | 212 | assertTrue(circ.listens(EventTypes.CircleMakerEvents.MOUSEOUT)); 213 | 214 | return null; 215 | }); 216 | } 217 | 218 | public void testSVGUpdateEvent() { 219 | InjectedLeafletResources.whenReady((e) -> { 220 | 221 | SVG svg = L.svg(null); 222 | 223 | svg.on(EventTypes.SVGEvents.UPDATE, (event) -> { 224 | 225 | }); 226 | 227 | assertTrue(svg.listens(EventTypes.SVGEvents.UPDATE)); 228 | 229 | return null; 230 | }); 231 | } 232 | 233 | public void testCanvasAddEvent() { 234 | InjectedLeafletResources.whenReady((e) -> { 235 | 236 | Canvas canv = L.canvas(null); 237 | 238 | canv.on(EventTypes.CanvasEvents.ADD, (event) -> { 239 | 240 | }); 241 | 242 | assertTrue(canv.listens(EventTypes.CanvasEvents.ADD)); 243 | 244 | return null; 245 | }); 246 | } 247 | 248 | public void testLayerGroupAddEvent() { 249 | InjectedLeafletResources.whenReady((e) -> { 250 | 251 | LayerGroup lay = L.layerGroup(null); 252 | 253 | lay.on(EventTypes.LayerGroupEvents.ADD, (event) -> { 254 | 255 | }); 256 | 257 | assertTrue(lay.listens(EventTypes.LayerGroupEvents.ADD)); 258 | 259 | return null; 260 | }); 261 | } 262 | 263 | public void testFeatureGroupLayerAddEvent() { 264 | InjectedLeafletResources.whenReady((e) -> { 265 | 266 | FeatureGroup fGroup = L.featureGroup(null); 267 | 268 | fGroup.on(EventTypes.FeatureGroupEvents.ADD, (event) -> { 269 | 270 | }); 271 | 272 | assertTrue(fGroup.listens(EventTypes.FeatureGroupEvents.ADD)); 273 | 274 | return null; 275 | }); 276 | } 277 | 278 | public void testGeoJsonLayerRemoveEvent() { 279 | InjectedLeafletResources.whenReady((e) -> { 280 | 281 | GeoJSON geoJson = L.geoJSON(null, null); 282 | 283 | geoJson.on(EventTypes.GeoJsonEvents.LAYERREMOVE, (event) -> { 284 | 285 | }); 286 | 287 | assertTrue(geoJson.listens(EventTypes.GeoJsonEvents.LAYERREMOVE)); 288 | 289 | return null; 290 | }); 291 | } 292 | 293 | public void testGridLayerTileUnloadEvent() { 294 | InjectedLeafletResources.whenReady((e) -> { 295 | 296 | GridLayer gridLayer = L.gridLayer(null); 297 | 298 | gridLayer.on(EventTypes.GridLayerEvents.TILEUNLOAD, (event) -> { 299 | 300 | }); 301 | 302 | assertTrue(gridLayer.listens(EventTypes.GridLayerEvents.TILEUNLOAD)); 303 | 304 | return null; 305 | }); 306 | } 307 | 308 | // public void testIconTooltipOpenEvent() { 309 | // InjectedLeafletResources.whenReady(new Function() { 310 | // public JavaScriptObject call(JavaScriptObject event) { 311 | // 312 | // Icon icon = L.icon(null); 313 | // 314 | // icon.on(EventTypes.IconEvents.TOOLTIPOPEN, (e) -> { 315 | // 316 | // return null; 317 | // }); 318 | // 319 | // assertTrue(icon.listens(EventTypes.IconEvents.TOOLTIPOPEN)); 320 | // 321 | // 322 | // return null; 323 | // } 324 | // }); 325 | // } 326 | 327 | // public void testDivIconPopupCloseEvent() { 328 | // InjectedLeafletResources.whenReady(new Function() { 329 | // public JavaScriptObject call(JavaScriptObject event) { 330 | // 331 | // DivIcon divIcon = L.divIcon(null); 332 | // 333 | // divIcon.on(EventTypes.DivIconEvents.POPUPCLOSE, (e) -> { 334 | // 335 | // return null; 336 | // }); 337 | // 338 | // assertTrue(divIcon.listens(EventTypes.DivIconEvents.POPUPCLOSE)); 339 | // 340 | // return null; 341 | // } 342 | // }); 343 | // } 344 | 345 | 346 | 347 | } 348 | -------------------------------------------------------------------------------- /src/test/java/com/gwidgets/leaflet/test/GwtyLeafletTestCase.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.leaflet.test; 2 | import com.google.gwt.junit.client.GWTTestCase; 3 | 4 | public class GwtyLeafletTestCase extends GWTTestCase { 5 | 6 | @Override 7 | public String getModuleName() { 8 | // TODO Auto-generated method stub 9 | return "com.gwidgets.leaflet.GwtyLeafletTest"; 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/test/java/com/gwidgets/leaflet/test/GwtyLeafletTestSuite.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.leaflet.test; 2 | 3 | import com.google.gwt.junit.tools.GWTTestSuite; 4 | 5 | import junit.framework.TestSuite; 6 | 7 | 8 | public class GwtyLeafletTestSuite extends GWTTestSuite { 9 | 10 | public static TestSuite suite() { 11 | TestSuite suite = new TestSuite("gwty-leaflet tests"); 12 | suite.addTestSuite(MapTest.class); 13 | suite.addTestSuite(MarkerTest.class); 14 | suite.addTestSuite(PathTest.class); 15 | suite.addTestSuite(VersionTest.class); 16 | suite.addTestSuite(TransformationTest.class); 17 | suite.addTestSuite(EventTest.class); 18 | suite.addTestSuite(CRSTest.class); 19 | suite.addTestSuite(ProjectionTest.class); 20 | 21 | return suite; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/com/gwidgets/leaflet/test/InjectedLeafletResources.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.leaflet.test; 2 | 3 | 4 | import elemental2.dom.DomGlobal; 5 | import elemental2.dom.Element; 6 | import elemental2.dom.HTMLScriptElement; 7 | 8 | public class InjectedLeafletResources { 9 | public static void whenReady(Element.OnloadFn function){ 10 | HTMLScriptElement leafletScript = (HTMLScriptElement) DomGlobal.document.createElement("script"); 11 | leafletScript.src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0/leaflet.js"; 12 | leafletScript.type="text/javascript"; 13 | DomGlobal.document.head.appendChild(leafletScript); 14 | leafletScript.onload = function; 15 | } 16 | } -------------------------------------------------------------------------------- /src/test/java/com/gwidgets/leaflet/test/MapTest.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.leaflet.test; 2 | 3 | import com.gwidgets.api.leaflet.L; 4 | import com.gwidgets.api.leaflet.Map; 5 | import com.gwidgets.api.leaflet.options.MapOptions; 6 | 7 | import elemental2.dom.DomGlobal; 8 | import elemental2.dom.HTMLElement; 9 | 10 | public class MapTest extends GwtyLeafletTestCase { 11 | 12 | 13 | 14 | public void testMapCreateWithId(){ 15 | 16 | InjectedLeafletResources.whenReady((e) -> { 17 | HTMLElement div = (HTMLElement) DomGlobal.document.createElement("div"); 18 | div.id = "test"; 19 | DomGlobal.document.body.appendChild(div); 20 | 21 | Map map = L.map("test", null); 22 | assertNotNull(map); 23 | return null; 24 | }); 25 | } 26 | 27 | 28 | 29 | public void testMapCreateWithHTMLElement(){ 30 | InjectedLeafletResources.whenReady((e) -> { 31 | HTMLElement mapContainer = (HTMLElement) DomGlobal.document.createElement("div"); 32 | Map map = L.map(mapContainer, null); 33 | assertNotNull(map); 34 | return null; 35 | }); 36 | } 37 | 38 | public void testMapRemove(){ 39 | InjectedLeafletResources.whenReady((e) -> { 40 | HTMLElement div = (HTMLElement) DomGlobal.document.createElement("div"); 41 | div.id = "test5"; 42 | DomGlobal.document.body.appendChild(div); 43 | MapOptions options = new MapOptions.Builder(L.latLng(52.51, 13.40), 12.0, 7.0).maxZoom(20.0).build(); 44 | Map map = L.map("test5", options); 45 | 46 | assertNotNull(map); 47 | map.remove(); 48 | 49 | 50 | return null; 51 | }); 52 | } 53 | 54 | 55 | public void testMapView(){ 56 | InjectedLeafletResources.whenReady((e) -> { 57 | HTMLElement div = (HTMLElement) DomGlobal.document.createElement("div"); 58 | div.id = "test2"; 59 | DomGlobal.document.body.appendChild(div); 60 | 61 | Map map = L.map("test2", null); 62 | map.setView(L.latLng(52.51, 13.40), 12.0, null); 63 | assertNotNull(map); 64 | assertEquals(map.getCenter().lat, 52.51); 65 | assertEquals(map.getCenter().lng, 13.40); 66 | 67 | return null; 68 | }); 69 | } 70 | 71 | public void testMapZoom(){ 72 | InjectedLeafletResources.whenReady((e) -> { 73 | HTMLElement div = (HTMLElement) DomGlobal.document.createElement("div"); 74 | div.id = "test3"; 75 | DomGlobal.document.body.appendChild(div); 76 | MapOptions options = new MapOptions.Builder(L.latLng(52.51, 13.40), 12.0, 7.0).dragging(true).maxZoom(20.0).build(); 77 | Map map = L.map("test3", options); 78 | 79 | assertNotNull(map); 80 | assertEquals(String.valueOf(map.getZoom()), "12"); 81 | assertEquals(String.valueOf(map.getMinZoom()), "7"); 82 | assertEquals(String.valueOf(map.getMaxZoom()), "20"); 83 | 84 | //Zoom In method has weird behavior *** Fails 85 | map.zoomOut(5.0, null); 86 | assertEquals("7", map.getZoom().toString()); 87 | 88 | return null; 89 | }); 90 | } 91 | 92 | public void testMapPan(){ 93 | InjectedLeafletResources.whenReady((e) -> { 94 | HTMLElement div = (HTMLElement) DomGlobal.document.createElement("div"); 95 | div.id = "test4"; 96 | DomGlobal.document.body.appendChild(div); 97 | MapOptions options = new MapOptions.Builder(L.latLng(52.51, 13.40), 12.0, 7.0).maxZoom(20.0).build(); 98 | Map map = L.map("test4", options); 99 | 100 | assertNotNull(map); 101 | map.panTo(L.latLng(51.51, 13.80), null); 102 | assertEquals(map.getCenter().lat, 51.51); 103 | assertEquals(map.getCenter().lng, 13.80); 104 | 105 | return null; 106 | }); 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /src/test/java/com/gwidgets/leaflet/test/MarkerTest.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.leaflet.test; 2 | 3 | import com.gwidgets.api.leaflet.L; 4 | import com.gwidgets.api.leaflet.Map; 5 | import com.gwidgets.api.leaflet.Marker; 6 | import com.gwidgets.api.leaflet.options.MarkerOptions; 7 | 8 | import elemental2.dom.DomGlobal; 9 | import elemental2.dom.HTMLElement; 10 | 11 | public class MarkerTest extends GwtyLeafletTestCase{ 12 | 13 | 14 | public void testMarkeradd(){ 15 | InjectedLeafletResources.whenReady((e) -> { 16 | HTMLElement div = (HTMLElement) DomGlobal.document.createElement("div"); 17 | div.id = "test6"; 18 | DomGlobal.document.body.appendChild(div); 19 | 20 | Map map = L.map("test6", null); 21 | MarkerOptions mkOptions = new MarkerOptions.Builder().build(); 22 | Marker marker = L.marker(L.latLng(52.51, 13.40), mkOptions); 23 | marker.addTo(map); 24 | 25 | assertNotNull(map); 26 | assertNotNull(marker); 27 | 28 | assertEquals(marker.getLatLng().lat, 52.51); 29 | assertEquals(marker.getLatLng().lng, 13.40); 30 | 31 | return null; 32 | }); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/gwidgets/leaflet/test/PathTest.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.leaflet.test; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import com.gwidgets.api.leaflet.Circle; 7 | import com.gwidgets.api.leaflet.L; 8 | import com.gwidgets.api.leaflet.LatLng; 9 | import com.gwidgets.api.leaflet.Polygon; 10 | import com.gwidgets.api.leaflet.Polyline; 11 | import com.gwidgets.api.leaflet.Rectangle; 12 | import com.gwidgets.api.leaflet.options.CircleOptions; 13 | 14 | public class PathTest extends GwtyLeafletTestCase { 15 | 16 | 17 | public void testPolyline(){ 18 | InjectedLeafletResources.whenReady((e) -> { 19 | 20 | List coordinates = new ArrayList(); 21 | 22 | coordinates.add(L.latLng(52.51, 13.37)); 23 | coordinates.add(L.latLng(52.5095, 13.34)); 24 | 25 | 26 | LatLng[] coordinatesArray = (LatLng[]) coordinates.toArray(); 27 | LatLng[][] polylineCoordinates = {coordinatesArray}; 28 | Polyline pol = L.polyline(polylineCoordinates, null); 29 | 30 | 31 | assertEquals((pol.getLatLngs())[0][0].lat, 52.51); 32 | assertEquals((pol.getLatLngs())[0][0].lng, 13.37); 33 | 34 | 35 | return null; 36 | }); 37 | } 38 | 39 | public void testRectangle(){ 40 | InjectedLeafletResources.whenReady((e) -> { 41 | Rectangle rect = L.rectangle(L.latLngBounds(L.latLng(52.5139, 13.34), L.latLng(54.51, -3.045)), null); 42 | 43 | assertEquals((rect.getLatLngs())[0][0].lat, 52.5139); 44 | assertEquals((rect.getLatLngs())[0][1].lng, -3.045); 45 | 46 | return null; 47 | }); 48 | } 49 | 50 | 51 | public void testCircle(){ 52 | InjectedLeafletResources.whenReady((e) -> { 53 | 54 | CircleOptions circleOptions = new CircleOptions.Builder() 55 | .fillColor("#b35d20") 56 | .color("#f54e02") 57 | .radius(500.0) 58 | .build(); 59 | 60 | Circle circ = L.circle(L.latLng(52.51, 13.37), circleOptions); 61 | 62 | 63 | assertEquals(String.valueOf(circ.getRadius()), "500"); 64 | assertEquals(circ.getLatLng().lat, 52.51); 65 | assertEquals(circ.getLatLng().lng, 13.37); 66 | 67 | 68 | return null; 69 | }); 70 | } 71 | 72 | 73 | public void testPolygon(){ 74 | InjectedLeafletResources.whenReady((e) -> { 75 | 76 | List coordinates = new ArrayList(); 77 | 78 | coordinates.add(L.latLng(52.51, 13.37)); 79 | coordinates.add(L.latLng(52.5095, 13.34)); 80 | 81 | LatLng[] coordinatesArray = (LatLng[]) coordinates.toArray(); 82 | LatLng[][] polygonCoordinates = {coordinatesArray}; 83 | Polygon polg = L.polygon(polygonCoordinates, null); 84 | 85 | 86 | assertEquals((polg.getLatLngs())[0][0].lat, 52.51); 87 | assertEquals((polg.getLatLngs())[0][0].lng, 13.37); 88 | 89 | assertEquals((polg.getLatLngs())[0][1].lat, 52.5095); 90 | assertEquals((polg.getLatLngs())[0][1].lng, 13.34); 91 | 92 | 93 | return null; 94 | }); 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /src/test/java/com/gwidgets/leaflet/test/ProjectionTest.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.leaflet.test; 2 | 3 | import com.gwidgets.api.leaflet.L; 4 | import com.gwidgets.api.leaflet.LatLng; 5 | import com.gwidgets.api.leaflet.Point; 6 | import com.gwidgets.api.leaflet.Projection; 7 | 8 | public class ProjectionTest extends GwtyLeafletTestCase { 9 | 10 | 11 | public void testProjection(){ 12 | InjectedLeafletResources.whenReady((e) -> { 13 | 14 | Projection projection = L.Projection.LonLat; 15 | 16 | Point p = projection.project(L.latLng(41, 72)); 17 | 18 | 19 | LatLng unprojected = projection.unproject(p); 20 | 21 | assertEquals(String.valueOf(unprojected.lat), "41"); 22 | assertEquals(String.valueOf(unprojected.lng), "72"); 23 | 24 | 25 | return null; 26 | }); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/com/gwidgets/leaflet/test/TransformationTest.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.leaflet.test; 2 | 3 | import com.gwidgets.api.leaflet.L; 4 | import com.gwidgets.api.leaflet.L.Transformation; 5 | import com.gwidgets.api.leaflet.Point; 6 | 7 | public class TransformationTest extends GwtyLeafletTestCase { 8 | 9 | 10 | /******* test fails for equal method *********/ 11 | 12 | public void testTransformation(){ 13 | InjectedLeafletResources.whenReady((e) -> { 14 | 15 | Transformation trans = new L.Transformation(1, 3, 5, 7); 16 | assertNotNull(trans); 17 | Point testpoint = L.point(15, 7, false); 18 | Point transformed = trans.transform(testpoint, 1); 19 | Point untransformed = trans.untransform(transformed, 1); 20 | 21 | assertEquals(testpoint.toString(), untransformed.toString()); 22 | assertEquals(String.valueOf(testpoint.x), String.valueOf(untransformed.x)); 23 | assertEquals(String.valueOf(testpoint.y), String.valueOf(untransformed.y)); 24 | // assertTrue(untransformed.equals(testpoint)); 25 | 26 | 27 | return null; 28 | }); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/com/gwidgets/leaflet/test/VersionTest.java: -------------------------------------------------------------------------------- 1 | package com.gwidgets.leaflet.test; 2 | 3 | import com.gwidgets.api.leaflet.L; 4 | 5 | public class VersionTest extends GwtyLeafletTestCase { 6 | 7 | public void testLeafletVersion(){ 8 | InjectedLeafletResources.whenReady((e) -> { 9 | 10 | assertEquals(L.version, "1.0.0"); 11 | 12 | return null; 13 | }); 14 | } 15 | 16 | } 17 | --------------------------------------------------------------------------------