All Projects → gwidgets → gwty-leaflet

gwidgets / gwty-leaflet

Licence: Apache-2.0 License
A GWT JsInterop wrapper for Leaflet.

Programming Languages

java
68154 projects - #9 most used programming language
javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to gwty-leaflet

gwt-boot-awesome-lili
Collection of JavaScript Libraries with JsInterop Interfaces and Others - GWT Awesome Library List (Gwit a LiLi)
Stars: ✭ 29 (+0%)
Mutual labels:  gwt, jsinterop
domino-jackson
Jackson with Annotation processing
Stars: ✭ 46 (+58.62%)
Mutual labels:  gwt, jsinterop
vue2-leaflet-rotatedmarker
rotated marker plugin extension for vue2-leaflet package
Stars: ✭ 17 (-41.38%)
Mutual labels:  leaflet
dash leaflet
Leaflet component for dash. Illustration of error encountered during python build.
Stars: ✭ 21 (-27.59%)
Mutual labels:  leaflet
phila-vue-mapping
a library of vue components used by mapping applications
Stars: ✭ 48 (+65.52%)
Mutual labels:  leaflet
mars2d
【Mars2D平台 】主仓库,包含所有开源仓库清单导航
Stars: ✭ 182 (+527.59%)
Mutual labels:  leaflet
leaflet heatmap
简单的可视化湖州通话数据 假设数据量很大,没法用浏览器直接绘制热力图,把绘制热力图这一步骤放到线下计算分析。使用Apache Spark并行计算数据之后,再使用Apache Spark绘制热力图,然后用leafletjs加载OpenStreetMap图层和热力图图层,以达到良好的交互效果。现在使用Apache Spark实现绘制,可能是Apache Spark不擅长这方面的计算或者是我没有设计好算法,并行计算的速度比不上单机计算。Apache Spark绘制热力图和计算代码在这 https://github.com/yuanzhaokang/ParallelizeHeatmap.git .
Stars: ✭ 13 (-55.17%)
Mutual labels:  leaflet
console
HAL management console
Stars: ✭ 41 (+41.38%)
Mutual labels:  gwt
gatsby-starter-leaflet
🍃 A Gatsby starter with Leafet to quickly build React apps with a map!
Stars: ✭ 108 (+272.41%)
Mutual labels:  leaflet
react4j
An opinionated react java binding
Stars: ✭ 33 (+13.79%)
Mutual labels:  gwt
leaflet.tilelayer.gloperations
Custom Leaflet TileLayer using WebGL to do operations on and colorize floating-point pixels
Stars: ✭ 15 (-48.28%)
Mutual labels:  leaflet
o.map
Open Street Map app - KaiOS
Stars: ✭ 51 (+75.86%)
Mutual labels:  leaflet
helloworld-web
Hello World web application in 39 different ways in Java
Stars: ✭ 18 (-37.93%)
Mutual labels:  gwt
roataway-web
Roataway web site
Stars: ✭ 15 (-48.28%)
Mutual labels:  leaflet
mapus
A map tool with real-time collaboration 🗺️
Stars: ✭ 2,687 (+9165.52%)
Mutual labels:  leaflet
Leaflet.MarkerCluster.List
a subplugin for the Leaflet.MarkerCluster to display clustered child elements in the list
Stars: ✭ 14 (-51.72%)
Mutual labels:  leaflet
gwt-material-table
A complex table component designed for the material design specifications
Stars: ✭ 28 (-3.45%)
Mutual labels:  gwt
streamlit-light-leaflet
Streamlit quick & dirty Leaflet component that sends back coordinates on map click
Stars: ✭ 22 (-24.14%)
Mutual labels:  leaflet
positive-office-map
Positive Technologies Office Map
Stars: ✭ 26 (-10.34%)
Mutual labels:  leaflet
django-leaflet-admin-list
The Django Leaflet Admin List package provides an admin list view featured by the map and bounding box filter for the geo-based data of the GeoDjango.
Stars: ✭ 28 (-3.45%)
Mutual labels:  leaflet

Build Status

Maven Central

Overview

gwty-leaflet is wrapper for the famous maps javascript library Leaflet. gwty-leaflet is based on JsInterop and allows using Leaflet from your GWT application exactly the same way as from a javascript script with a slight advantage: static typing. It was partially generated automatically from Leaflet docs.

Dependency

                     <dependency>
                        <groupId>com.gwidgets</groupId>
                        <artifactId>gwty-leaflet</artifactId>
                        <version>{version}</version>
                     </dependency>

If you are using a snaphost version, then you need to include the snapshot repository:

<repositories>
		<repository>
			<id>snapshots</id>
			<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
			<releases>
				<enabled>false</enabled>
			</releases>
			<snapshots>
				<enabled>true</enabled>
			</snapshots>
		</repository>
	</repositories>

Also, do not forget to include gwty-leaflet in your .gwt.xml module definition file:

 <inherits name='com.gwidgets.api.GwtyLeaflet' />
                  

Versions

  • 1.1.1 (exceptional): intoduces a small fix for LayerGroup eachLayer method.
  • 1.1 (exceptional): fixes a number of shortcomings and issues related mainly related to GeoJSON (checkout release page for more details)
  • 1.0: latest stable version, compatible with leaflet 1.0 and 1.0.1, uses Elemental 2
  • 0.5: compatible with leaflet 1.0
  • 0.4: compatible with leaflet 0.7

Leaflet javascript files:

As in any JsInterop wrapper, you need to refer to the Javascript files from your .html app file. You can either download the Js files from Leaflet website, or refer to them directly using their cdn (there are performance implications off course!).

<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>

Starting from the version 0.5, a new feature has been added to allow adding leaflet resource files dynamically from the code instead of including them manually in the .html:

LeafletResources.whenReady(false, 
        e -> 
                 {
      MapOptions options = new MapOptions.Builder(L.latLng(52.51, 13.40), 12.0, 12.0).dragging(false).build();
    final Map map = L.map("map", options);
    GWT.log(options.getZoom()+"");
    L.tileLayer(MAP_URL, null).addTo(map);
     return null;
    });

If the debug flag is set to false, Leaflet minified .js file will be injected, if set to true the unminified version will injected(leaflet-src.js).

This will automatically inject the leaflet .js and .css, and execute the code inside when they are loaded.

Initializing objects

All objects initializations are done through the L class. gwty-leaflet provides all factory methods of Leaflet. For example:

//equivalent to new Map(...)
Map map = L.map("map", new MapOptions.Builder().build());

//equivalent to new Circle(...)
Circle circle = L.circle(L.latLng(51.508, 11), 200, options);

For more information about Leaflet objects creational patterns, you can refer to Leaflet's official documentation.

Options

As specified by Leaflet documentation, the creation of some objects requires a set of options. gwty-leaflet provides all the options with their respective default values as Objects annotated with @JsType. As of version 0.4, options builders were introduced to help in the creation of option Objects and enforce fields validations. Several options have required fields, and using builders help the developer distinguish between required and optional fields.

Before version 0.4:

              PathOptions options = new PathOptions();
                options.fillColor = "#fff";
                options.opacity = 1;

                //...

                L.circle(L.latLng(51.508, 11), 200, options).addTo(map);

After version 0.4:

              PathOptions options = new PathOptions.Builder()
                                     .fillColor("#fff")
                                     .opacity(1)
                                      .build();

                //...

                L.circle(L.latLng(51.508, 11), 200, options).addTo(map);

For more informations about the available options for each objects, and their utility. You can refer to the original leaflet documentation.

Example

To create a map in a div with an id="map", we can do something like:

                
                L.map("map", new MapOptions.Builder().build()).setView(L.latLng(51.505, -0.09), 12.0, new ZoomPanOptions.Builder().build());

Events

Events are available only in some objects. Events can be handled throught the following methods: clearAllEventListeners(), on(String type, Function fn), once(String type, Function fn), off(String type, Function fn), fire(String type).

For defining actions, events needs to be supplied with an abstract callback function that needs to be implemented by the developer. The below example will dipslay a pop up on each map click:

map.on(EventTypes.MapEvents.CLICK, new EventCallback<MouseEvent>() {
			@Override
			public void call(MouseEvent event) {
                                
                                map.openPopup("hello", msEvent.getLatlng(), new PopupOptions.Builder().build());
                                return null;
                        }
                        
                });

Event Objects are:

  • DragEndEvent
  • ErrorEvent
  • GeoJSONEvent
  • KeyboardEvent
  • LayersControlEvent
  • LayerEvent
  • LocationEvent
  • MouseEvent
  • PopupEvent
  • ResizeEvent
  • TileErrorEvent
  • TileEvent
  • TooltipEvent

Events are executed following the order of registration.

Events are explained in details in Leaflet's documentation.

Events types constants

There is a long list of available events for some objects, and the developer may not know what events are available for the object they are using. The EventType class contains a list of subclasses which contains the available events types constants. The event type can be accessed in static a way like: EventTypes.{object name}Events.{event type name}. For example, to register the loading event on a TileLayer :

tile.on(EventTypes.TileLayer.LOADING, new EventCallback<TileEvent>() {
			@Override
			public void call(TileEvent event) {
                        //do something
                        }
                        
                });

Here is a list of the events that can be registred for objects that can handle events:

Object Available Events
DivOverlayEvents add, remove, popupopen, popupclose, tooltipopen, tooltipclose
RendererEvents update, add, remove, popupopen, popupclose, tooltipopen, tooltipclose
InteractiveLayerEvents click, dblclick, mousedown, mouseover, mouseout, contextmenu, add, remove, popupopen, popupclose, tooltipopen, tooltipclose
LayerEvents add, remove, popupopen, popupclose, tooltipopen, tooltipclose
PosAnimationEvents start, step, end
DivIconEvents add, remove, popupopen, popupclose, tooltipopen, tooltipclose
IconEvents add, remove, popupopen, popupclose, tooltipopen, tooltipclose
GridLayerEvents loading, tileunload, tileloadstart, tileerror, tileload, load, add, remove, popupopen, popupclose, tooltipopen, tooltipclose
GeoJsonEvents layeradd, layerremove, add, remove, popupopen, popupclose, tooltipopen, tooltipclose
FeatureGroupEvents layeradd, layerremove, add, remove, popupopen, popupclose, tooltipopen, tooltipclose
LayerGroupEvents add, remove, popupopen, popupclose, tooltipopen, tooltipclose
CanvasEvents update, add, remove, popupopen, popupclose, tooltipopen, tooltipclose
SVGEvents update, add, remove, popupopen, popupclose, tooltipopen, tooltipclose
CircleMakerEvents click, dblclick, mousedown, mouseover, mouseout, contextmenu, add, remove, popupopen, popupclose, tooltipopen, tooltipclose
CircleEvents click, dblclick, mousedown, mouseover, mouseout, contextmenu, add, remove, popupopen, popupclose, tooltipopen, tooltipclose
RectangleEvents click, dblclick, mousedown, mouseover, mouseout, contextmenu, add, remove, popupopen, popupclose, tooltipopen, tooltipclose
PolygonEvents click, dblclick, mousedown, mouseover, mouseout, contextmenu, add, remove, popupopen, popupclose, tooltipopen, tooltipclose
PolylineEvents click, dblclick, mousedown, mouseover, mouseout, contextmenu, add, remove, popupopen, popupclose, tooltipopen, tooltipclose
PathEvents click, dblclick, mousedown, mouseover, mouseout, contextmenu, add, remove, popupopen, popupclose, tooltipopen, tooltipclose
ImageOverlayEvents click, dblclick, mousedown, mouseover, mouseout, contextmenu, add, remove, popupopen, popupclose, tooltipopen, tooltipclose
TileLayerWMSEvents loading, tileunload, tileloadstart, tileerror, tileload, load, add, remove, popupopen, popupclose, tooltipopen, tooltipclose
TileLayerEvents loading, tileunload, tileloadstart, tileerror, tileload, load, add, remove, popupopen, popupclose, tooltipopen, tooltipclose
TooltipEvents add, remove, popupopen, popupclose, tooltipopen, tooltipclose
PopupEvents add, remove, popupopen, popupclose, tooltipopen, tooltipclose
MarkerEvents move, dragstart, movestart, drag, dragend, moveend, click, dblclick, mousedown, mouseover, mouseout, contextmenu, add, remove, popupopen, popupclose, tooltipopen, tooltipclose
MapEvents baselayerchange, overlayadd, overlayremove, layeradd, layerremove, zoomlevelschange, resize, unload, viewreset, load, zoomstart, movestart, zoom, move, zoomend, moveend, popupopen, popupclose, autopanstart, tooltipopen, tooltipclose, click, dblclick, mousedown, mouseup, mouseover, mouseout, mousemove, contextmenu, keypress, preclick, zoomanim, locationerror, locationfound

Javadoc :

Elemental 2:

The 1.0 version makes use of Elemental 2, instead of local javascript wrapped Elements(under .elemental package). The .elemental package has been removed as it is not needed anymore.

GWT version:

the 0.5 version is compiled using GWT 2.8.0. the 1.0 version is compiled using GWT 2.8.2.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].