Leaflet4j with Android Studio

1,077 views
Skip to first unread message

markus...@gmail.com

unread,
Nov 13, 2015, 6:02:54 PM11/13/15
to DukeScript
Hi,

I'm interested to integrate Leaflet4J (https://github.com/dukescript/leaflet4j) into a Android Studio Project.

This is what I get so far in my "MainActivity":

leaflet = (WebView)findViewById(R.id.leaflet);
leaflet.clearCache(true);
leaflet.getSettings().setJavaScriptEnabled(true);
leaflet.setInitialScale(200);
leaflet.loadUrl("file:///android_asset/leaflet.html");

// Create a map zoomed to Linz.
MapOptions mapOptions = new MapOptions()
.setCenter(new LatLng(48.336614, 14.319305))
.setZoom(15);
final Map map = new Map("map", mapOptions);


In the HTML there is a div container, which is called "map":
<div id="map"></div>

Well, I guess there is a huge misunderstanding from myside as the compiler shows:
java.lang.RuntimeException: Unable to start activity ComponentInfo{de.test.firstmap2/de.test.firstmap2.MainActivity}: java.lang.IllegalStateException: No presenter active. Use BrwsrCtx.execute!


Would be great, if you could point me into the right direction.
Many thanks in advance

Markus

Jaroslav Tulach

unread,
Nov 13, 2015, 6:17:06 PM11/13/15
to markus...@gmail.com, DukeScript
To use DukeScript you have to initialize the WebView with the right presenter. Why don't you start with the Maven archetype https://dukescript.com/update/2015/02/05/New-Version-of-Dukescript.html and only when it is working you try to copy the sources to a Gradle project?

-jt

14. 11. 2015 v 0:02, markus...@gmail.com:

--
You received this message because you are subscribed to the Google Groups "DukeScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dukescript+...@googlegroups.com.
Visit this group at http://groups.google.com/group/dukescript.
To view this discussion on the web visit https://groups.google.com/d/msgid/dukescript/c698f029-a4d7-4bef-8117-5b1e433478de%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

markus...@gmail.com

unread,
Nov 14, 2015, 12:09:52 PM11/14/15
to DukeScript, markus...@gmail.com
Hi,

thank you so much for your response. Well, I have tried some hours to just show a simple map in Android Studio. Nope, it seems too hard for me.... No success. I really have no idea how to recover.
It ended up in something like this:
.....Unable to open asset URL: file:///android_asset/lib/net.java.html.boot.fx-1.1.js


I guess it would be very helpful (and also for a lot of other developers) to have a simple gradle studio project which shows the integration. I guess this would boost the usage of Leaflet in Android a lot....
I haven't found anything like this...

Many thanks again....I love Leaflet a lot as I used it in many other (web-)projects , but I guess I have to look for the Google Maps Integration now...in Android Studio it seems to be very smooth... ;-(

Markus
Reply all
Reply to author
Forward
0 new messages