gwidgets / gwty-leaflet Goto Github PK
View Code? Open in Web Editor NEWA GWT JsInterop wrapper for Leaflet.
License: Apache License 2.0
A GWT JsInterop wrapper for Leaflet.
License: Apache License 2.0
I have the following code.
public class MapWidget {
Map itsMap;
public MapWidget(HTMLPanel inHTMLPanel) {
LatLng center = L.latLng(0, 0);
HTMLElement mapElement = new HTMLElement();
mapElement.innerHTML = inHTMLPanel.getElement().getInnerHTML();
itsMap = L.map(mapElement, new MapOptions.Builder(center, 1, 1).build());
}
public HTMLElement getElement(){
return itsMap.getContainer();
}
}
I get the following error in my console.
MapWidget.java:21 Uncaught TypeError: Cannot read property 'gwidgets' of undefined
The line the it complains about is
HTMLElement mapElement = new HTMLElement();
I believe it has to use a builder to create that but looking at what is available from L class there doesn't seem to be one.
I was following what was done in the following issue #2
Any help would be greatly appreciated.
Hi,
With the latest snapshot when i try to bootstrap the map i see only gray background. Then I noticed in the leaflet quick start tutorials I need to initialize tile layer which than gives javascript error saying id is not defined.
Is there any startup project that can show an actual map without gray area, for the latest leaflet version?
Thanks.
String tileUrl = "https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=XXX"; LatLng center = L.latLng(41.130076, 29.256913); Map map = L.map("map", new MapOptions.Builder(center,13,5).build()); L.tileLayer(tileUrl, new TileLayerOptions.Builder().build()).addTo(map);
Would it be ok to add to this project some interop files for some well known Leaflet plugin such as Leaflet.ClusterMarker and Leaflet.Draw ? Or should it be put in new separate libraries ?
I compiled gwty-leaflet to a jar file using maven and then added that jar to the build path of a simple test project that I created (with Eclipse). The project is using GWT 2.8.0.beta1 and is the standard GWT "greet". The project works fine until I add an inherits for GwtyLeaflet.
After adding an element to the app's gwt.xml file the following error is displayed at compile time...
Do you have any suggestion as to what the problem could be? The jar is on the build path, as is gwt-material-1.5.3.jar, gwt-material-addins-1.5.2.jar and gwt-material-themes-1.5.2.jar.
Finding entry point classes
Tracing compile failure path for type 'com.gwidgets.api.client.GwtyLeaflet'
Checked 0 dependencies for errors.
[ERROR] Hint: Check that the type name 'com.gwidgets.api.client.GwtyLeaflet' is really what you meant
[ERROR] Hint: Check that your classpath includes all required source roots
Hi,
in my geoJson string I have some MultilineString geometry. But when I am generating JsObject:
(JsObject) Global.JSON.parse(jsonString);
Something is wrong. Am I missing something? When I have Multipolygon It is ok...
Thanks
Hi, I noticed in GridLayer, that createTile does not yet exist. Are there any updates on this? I am new to jsinterop, would this work?
@JsFunction
public interface FunctionCreateTile {
HTMLElement createTile(coords);
}
@JsMethod
public native L createTile(FunctionCreateTile fn);
I'm wondering how to use a custom TileLayerOptions with :
public static native TileLayer tileLayer(String urlTemplate,
TileLayerOptions options);
To call this method, you have to pass an instance of TileLayerOptions. But in the leaflet docs, there is no actual object that corresponds to TileLayerOptions, it's rather an object literal.
So how do you pass for example a TileLayerWMSOption to this method ? Or any other options map for another provider.
ps : I don't know why all the JsType constructors are mostly private, but because of that, we can't extend L to add other static method, or extend TileLayerOption.
Thanks
Hi, I was trying to get absolute or relative pixel position from latlng coordinate using map.latLngToContainerPoint() method. But it turns out this method returns position with respect to whole large map. How am I supposed to get screen position from this?
Thanks!
There are two APIs L.map to initialize map. One takes String id and other takes HTMLElement.
How can I use HTMLPanel widget here. I think if you can provide HTMLElement class extending JavaScriptObject then HTMLPanel::getElement can be used here.
Point is missing the z property - used in TileEvent.getCoords() - "Point object with tile's x, y, and z (zoom level) coordinates"
@JsProperty
public double z;
How come there is still some JSNI usage in gwty-leaflet/src/main/java/com/gwidgets/api/leaflet/events/Event.java
?
Does this mean there is still work to be done to fully migrate to jsinterop ?
When you try to use TileLayerOptions as argument 'options' of L.tileLayer method (otherwise of null)
LeafletResources.whenReady( e -> {
MapOptions options = new MapOptions.Builder(L.latLng(52.51, 13.40), 5.0, 5.0).dragging(false).build();
final Map map = L.map("map", options);
TileLayerOptions tloptions = new TileLayerOptions.Builder().attribution("test").build();
L.tileLayer("http://{s}.tile.osm.org/{z}/{x}/{y}.png", tloptions).addTo(map);
return null;
});
this provide next JavaScript error:
Uncaught TypeError: Cannot read property 'appendChild' of undefined
at e._initContainer (leaflet.js:6)
at e.onAdd (leaflet.js:6)
at e._layerAdd (leaflet.js:6)
at e.whenReady (leaflet.js:6)
at e.addLayer (leaflet.js:6)
at e.addTo (leaflet.js:6)
at ENd_g$ (Main.java:31)
at Function.LNd_g$ (Main.java:17)
at HTMLScriptElement.lambda_0_g$ (Runtime.java:166)
The 'null' argument work correctly
L.tileLayer("http://{s}.tile.osm.org/{z}/{x}/{y}.png", null).addTo(map);
gwty-leaflet: 0.5 and 1.0-SNAPSHOT, GWT 2.8.0 and 2.8.1
Can I recommend using GWT.getModuleBaseForStaticFiles() instead of GWT.getModuleName() in LeafletResources? In my case, my page was not the root.. eg /some/path which resulted in LeafletResources looking for /some/path/gwt_module_name/leaflet/leaflet.js.
Using GWT.getModuleBaseForStaticFiles(), LeafletResources instead looks for /gwt_module_name/leaflet/leaflet.js as expected
I wanted to use your library in my project where I use GWT and SmartGWT. But when I add map creation in my code I get compile errors as below. Could you tell what the problem is?
[INFO] [ERROR] Errors in 'com/gwidgets/api/leaflet/L.java'
[INFO] [ERROR] Line 76: Native methods require a JavaScript implementation enclosed with /*-{ and }-*/
[INFO] [ERROR] Line 85: Native methods require a JavaScript implementation enclosed with /*-{ and }-*/
[.........]
[INFO] [ERROR] Errors in 'com/gwidgets/api/leaflet/LatLng.java'
[INFO] [ERROR] Line 65: Native methods require a JavaScript implementation enclosed with /*-{ and }-*/
[........]
etc.
Members in MapOptions have package level visibility. It should be public.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.