mapjfx

mapjfx is a project that offers a JavaFX8 component displaying a map. The component is based on the JavaFX WebView and on the OpenLayers library. All interaction of the program with the map is done by using Java calls and JavaFX properties; the user does not need to do any Javascript or HTML coding.

The project uses Java version Java SE8, as JavaFX 8 is contained in this version without the need to install or configure anything special and as SE8 at the time of writing is the actual version.

The sourcecode for the project is available on GitHub, comments and collaboration welcome.

The actual version 1.13.1 is released to maven central, see the blog posts, the demo showing the possibilities and code samples is found here.

mapjfx at this time has the following features:

  • display of a map with given center
  • resize the map together with the JavaFX component
  • provides map center info as JavaFX property
  • provides map zoom info as JavaFX property
  • optional animate center and zoom changes
  • SceneBuilder compatibility
  • display of a map so that a set of points is visible
  • change between different map sources
  • showing markers at different coordinates of the map
  • use custom icons for markers
  • sow/hide/move the markers
  • provide feedback to the Java app for user interaction like clicking in the map
  • display of lines/tracks
  • Map types
    • Open StreetMap
    • Bing Maps Road (with API Key)
    • Bing Maps Aerial (with API Key)
    • custom WMS servers
  • map labels
  • ability to cache map data for offline use
  • custom events for clicking and right-clicking in map, clicking on markers and labels
  • events for rightclick, doubleclick, mousedown and mouseup on labels and markers
  • when cmd-dragging (Mac OSX) or ctrl-dragging (Windows) a rectangle is spanned in the map which on release triggers an event that contains the selected extent.
  • when using the offline cache, it is possible to define regex patterns for urls not to be cached.

3D support

As per Michael Anderl’s suggestion from November 2015 I evaluated the integration of Cesium to support 3D rendering. This looked gorgeous in Chrome with a terrain map, but alas I cannot integrate it into mapjfx because the WebView Component from JavaFX does not support WebGL. Checking Bugtrackers and forums on OpenJFX it seems that there is no planned support yet.

One solution could be to change the rendering engine to JxBrowser, but as mapjfx should run on the standard JDK without any modifications, this seems not to be a solution.

Tested systems

Version 1.13.1 of the application is tested with the following configurations:

  • Oracle JDK 1.8.0_131 on Mac OSX 10.12.5
  • Oracle JDK 1.8.0_131 on MS Windows 10, build 1607

Version 1.13.0 of the application is tested with the following configurations:

  • Oracle JDK 1.8.0_131 on Mac OSX 10.12.3
  • Oracle JDK 1.8.0_131 on MS Windows 10, build 1607

Version 1.11.0 of the application is tested with the following configurations:

  • Oracle JDK 1.8.0_121 on Mac OSX 10.12.3
  • Oracle JDK 1.8.0_121 on MS Windows 10, build 1607

Version 1.10.1 of the application is tested with the following configurations:

  • Oracle JDK 1.8.0_121 on Mac OSX 10.12.3
  • Oracle JDK 1.8.0_121 on MS Windows 10, build 1607

Version 1.10.0 of the application is tested with the following configurations:

  • Oracle JDK 1.8.0_121 on Mac OSX 10.12.3
  • Oracle JDK 1.8.0_121 on MS Windows 10, build 1607

Version 1.9.0 of the application is tested with the following configurations:

  • Oracle JDK 1.8.0_121 on Mac OSX 10.12.3
  • Oracle JDK 1.8.0_121 on MS Windows 10, build 1607

Version 1.8.2 of the application is tested with the following configurations:

  • Oracle JDK 1.8.0_112 on Mac OSX 10.11.6
  • Oracle JDK 1.8.0_112 on MS Windows 10, build 1607

Version 1.8.0 of the application is tested with the following configurations:

  • Oracle JDK 1.8.0_102 on Mac OSX 10.11.6
  • Oracle JDK 1.8.0_102 on MS Windows 10, build 1511

Version 1.7.3 of the application is tested with the following configurations:

  • Oracle JDK 1.8.0_92 on Mac OSX 10.11.5
  • Oracle JDK 1.8.0_92 on MS Windows 10

Version 1.7.1 of the application is tested with the following configurations:

  • Oracle JDK 1.8.0_77 on Mac OSX 10.11.4
  • Oracle JDK 1.8.0_77 on MS Windows 10

Version 1.7.0 of the application is tested with the following configurations:

  • Oracle JDK 1.8.0_77 on Mac OSX 10.11.4
  • Oracle JDK 1.8.0_77 on MS Windows 10

Version 1.6.2 of the application is tested with the following configurations:

  • Oracle JDK 1.8.0_74 on Mac OSX 10.11.3
  • Oracle JDK 1.8.0_74 on MS Windows 10

Version 1.6.1 of the application is tested with the following configurations:

  • Oracle JDK 1.8.0_74 on Mac OSX 10.11.2
  • Oracle JDK 1.8.0_74 on MS Windows 10

Version 1.6.0 of the application is tested with the following configurations:

  • Oracle JDK 1.8.0_66 on Mac OSX 10.11.2
  • Oracle JDK 1.8.0_65 on MS Windows 10.1
  • Oracle JDK 1.8.0_65 on MS Windows 8.1

Version 1.5.1 of the application is tested with the following configurations:

  • Oracle JDK 1.8.0_65 on Mac OSX 10.11.1
  • Oracle JDK 1.8.0_65 on MS Windows 10.1
  • Oracle JDK 1.8.0_65 on MS Windows 8.1

Version 1.5.0 of the application is tested with the following configurations:

  • Oracle JDK 1.8.0_65 on Mac OSX 10.11.1
  • Oracle JDK 1.8.0_65 on MS Windows 10.1
  • Oracle JDK 1.8.0_65 on MS Windows 8.1

Version 1.4.9 of the application is tested with the following configurations:

  • Oracle JDK 1.8.0_65 on Mac OSX 10.11.1
  • Oracle JDK 1.8.0_65 on MS Windows 10.1
  • Oracle JDK 1.8.0_65 on MS Windows 8.1

67 thoughts on “mapjfx

  1. Pingback: published sources for mapjfx | sothawo

  2. Pingback: mapjfx now includes optional animation | sothawo

  3. Pingback: sothawo

  4. Pingback: mapjfx-1.0.2 released | sothawo

  5. Pingback: mapjfx-1.1.0 released | sothawo

  6. Pingback: mapjfx-1.1.1 released | sothawo

  7. Pingback: mapjfx-1.2.1 released with mapjfx-demo-1.2.1 | sothawo

  8. Pingback: mapjfx 1.3.0 and mapjfx-demo-1.3.0 released | sothawo

  9. Pingback: create a data URI from an URL | sothawo

  10. Pingback: mapjfx 1.3.1 and mapjfx-demo-1.3.1 released | sothawo

  11. Pingback: tracks / coordinate lines coming to mapjfx | sothawo

  12. Pingback: mapjfx-1.4.0 and mapjfx-demo-1.4.0 with coordinate-lines/tracks | sothawo

  13. Pingback: trakxmap version 0.2.0 | sothawo

  14. Pingback: mapjfx reached version 1.4.3 | sothawo

    • Hi Jared,

      basically it should be possible to use all the map data that can be used with OpenLayers as I do nothing more than display a small web page and integrate the open layers api.

      The mapjfx API will need a little modification for sources that need data like an API key or a different map source url.

      I didn’t try out other map data up to now, I did not have the need.

      Peter

  15. Pingback: mapjfx upgraded to version 1.4.4 | sothawo

  16. Pingback: mapjfx version 1.4.5 released | sothawo

  17. Pingback: mapjfx version 1.4.7 released | sothawo

  18. Pingback: mapjfx version 1.4.8 released | sothawo

  19. Pingback: mapjfx 1.4.9 with OpenLayers 3.10.1 | sothawo

    • Hi Michael,

      this sure looks interesting. I will give it a try, but can’t make a promise as to when. Hopefully this or next week. Anyway I’ll create an issue for this in GitHub.

      Peter

    • I just tried it, alas we’re out of luck. Cesium uses WebGL, and the JavaFX WebView version of webkit does not support WebGL, althoug Webkit itself does. So nothing I can do here, sorry; I defnitely would have liked to do so.

  20. Pingback: mapjfx 1.5.0 adds support for Bing Maps | sothawo

  21. Pingback: mapjfx 1.5.1 with OpenLayers 3.11.2 | sothawo

  22. Pingback: mapjfx 1.6.0 supports the display of labels | sothawo

  23. Pingback: mapjfx 1.6.2 and mapjfx-demo 1.6.2 now using OpenLayers 3.14.2 | sothawo

  24. Pingback: mapjfx 1.7.0 with the ability for caching map data | sothawo

  25. Pingback: mapjfx 1.7.1 with some minor improvements in offline caching | sothawo

  26. Pingback: mapjfx 1.7.3 with OpenLayers 3.17.1 and removed MapQuest supprt | sothawo

  27. Pingback: mapjfx 1.8.0 adds custom events for marker and label clicks | sothawo

  28. Pingback: mapjfx 1.8.2 using OpenLayers 3.19.1 | sothawo

  29. Hi, I recently downloaded your Github project and found it an excellent job. Currently, I work on my grade thesis and I need to render a map using WMS and JavaFX, so I thought about using MapJFX. However, the project currently only allows to consume OSM and Bing maps. Could you advise me on how to modify the project to use the WMS of my company? Thanks in advance and congratulations for your work.

    • Hi,

      you would basically need to add the code for the WMS map in the JSMapView.prototype.setMapType function. OpenLayers supports tiles server (http://openlayers.org/en/latest/examples/wms-tiled.html?q=wms) and image server (http://openlayers.org/en/latest/examples/wms-image.html). The needed parameters like server url and other stuff you would need to pass into the Java MapView object and from there into the Javascript layer like it is done with the BING API key.

      Do you you know a publically reacheable WMS server that works like the one of your company? That would give me the possibility to integrate WMS support into the library. (Actually I am not a GIS specialist, but just a programmer, so if you can give me an URL to work against, that would be a great help).

      Anyway, I’ll open an issue on the GitHub project for WMS integration, so I will try to get this working.

      greetings
      Peter

  30. It worked!!! Thank you very much, now I can use the WMS of my company. Unfortunately, this service is not public and you will not be able to access it outside the domain of my company. However, I leave you a link of a public WMS that you can use for your development:

    http://www.iderc.cu/geoserver/gwc/service/wms

    You can access a viewer that consumes this service at:

    http://www.iderc.cu/web/iderc/visor

    others here: http://wiki.openstreetmap.org/wiki/WMS#Public_WMS_Servers

    Thanks again and greetings!

    PS: I had to disable the local cache to get the tiles online, because if it does not find it in the local cache does not make the request. This can be configurable so that if the tile is not cached it searches online?

    I’m sorry for the delay

    • Hi,

      I noticed that with the two examples I used, I had to switch off offline caching as well; not sure why this is. But the offline cache intercepting I programmed is something deep in the bowels of networking, I will check this when I find more time. At the moment, alas, you will to have to use the lib without caching.

      I hope this will not introduce too slow loading times.

    • addition: normally, when the tile is not in the local cache, MapView will fetch it from the server. I do not know why this is not working in these cases.

      • Hello, thank you very much for the quick response. Do not worry, I can work perfectly without the cache, since that does not slow down my solution. Now I have another question:
        Currently, the mapview responds to events related to the primary click. I need to get the selected coordinate when I click on the mapview, just like the other click. How could I do that?
        Thanks in advance.

          • Sorry for my English, the problem is that I accidentally cut the sentence, and I could not turn back. I’m from a Spanish speaking country and I do not speak English very well, I’m sorry if sometimes I do not communicate correctly. Sincerely Leandry

  31. Hi and congratulations for your excellent work. I hope you can help me with a doubt. How can I capture the clicked coordinate when I make a secondary click on the MapView? Because I need to display a context menu with different options to perform spatial operations using that coordinate.
    I’ve looked for different solutions, but none worked for me. In addition, OpenLayers 3.x does not have an event for the secondary click on the map as OpenLayers 2.x.
    Might you help me?
    Thanks in advance.

    • Hello and thanks,

      You’re luck; Just today I wanted to start adding secondary clicks and mousedown and mouseup events to the MapView itself (I added it to the markers and labels lately). So just wait a little till the next version comes around.

      greetings
      Peter

  32. Hello again, another question here. I want to be able to select a rectangular area of the map and get its bounding box. Taking the mouse to a point on the map and then click and drag the mouse to draw a square or rectangle on the map. Something like the option “set custom dimensions” in the “share” menu of the OSM site http://www.openstreetmap.org. The idea is to select the area and download the tiles belonging to it using WMS as a source, through a program that I am developing in Java.
    Any idea how to do this?

    • Hi Michel,

      this is not possible at the moment, as the press and hold while moving is interpreted as panning the map by OpenLayers. If I would implement this as rectangular selection, I would loose the panning.

      I think I could program this, but I would need some method to explicitly switch from one mode (panning) to a different one (area-selection).

      Would it be a possible solution for you to set the MapView to a ‘selection mode’ by your program and after selecting to reset it to ‘panning mode’? I could implement something like a MapViewDragMode to support that.

      • Hi, Peter,
        Yes, I could perfectly switch between these modes (pan / area selection) using a button on the interface. That’s not a problem for me. Currently I have to enter the coordinates of the selected area by hand and having this new functionality would save me a lot of time and errors. The ideal solution would be something like the functionality present in OSM that I mentioned before. But it does not matter, your variant is totally valid and easier to reach.

        Thanks for the quick response and regards. We are in contact

        • Hi Michel,

          I just released the next version; I did not use a toggle, as OpenLayers supports a dragBox interaction by using cmd/ctrl (Mac OSX/Windows)-drag, I just use this and pass it on to the Java layer.

          Hope it fits your needs

          • Thank you very much Peter. Now I’m busy with a lot of work. As soon as I have a little time I will update my project with the latest version of the mapjfx library. After I play a little with the area selection I’ll tell you how it was 🙂

            Regards.

            Michel

  33. Pingback: mapjfx 1.12.0 has a custom event for selecting a map area | sothawo

  34. Returning to a project that I used your libraries on last year with much success. It looks like I have an issue with downloading map data but really have no way to debug why it would not work. I have disabled caching for the time being. Any suggestion on where to start digging?

    • Hi Adam,

      glad that you could use the lib.

      What map do you use? I know that there are problems with caching when using Bing or WMS, I have up to now had no time for deeper investigation. I have opened an issue for that (https://github.com/sothawo/mapjfx/issues/19), could you add information what type of map you are using to that issue? Thanks a lot.

      Peter

      • I’m not using WMS or Bing, just OSM. I haven’t changed anything (except to disable caching right now) with the code. My project is based on 1.7.0, but I checked the mapjfx-demo both 1.12.0 and 1.7.0 and neither seem to want to download maps tiles for me. Looking at the logs for the mapjfx-demo I see a bunch of “should open connection to https://c.tile.openstreetmap.org/12/2142/1407.png” and similar for different tiles but no tiles shown in the JavaFX window.

  35. Pingback: mapjfx 1.12.1 with fixes to the code for caching data | sothawo

  36. Pingback: sothawo

  37. Hello,
    I have a question:
    Is it possible to calculate distance between two points or get a area around a point?

  38. Pingback: mapjfx 1.13.0 adds the possibility to exclude URLs from being cached | sothawo

  39. Pingback: mapjfx 1.11.0 using OpenLayers 4.2.0 | sothawo

  40. Hello,

    Just downloaded the sources for the mapjfx demo, compiled in maven and ran the demo.

    The application runs but the map tiles do not appear. I have tried this at home and in my work place with the same results.

    I am also using the latest JDK i.e. u131, running on windows 10 64 bit.

    • Hi Sean,

      do you run the application from within an IDE or from the commandline? There was a comment thread on the page for mapjfx-demo (https://www.sothawo.com/projects/mapjfx-demo/#comment-361) where finally the solution was to run the app with the JRE and not the JDK, which I cannot reproduce because I always test it on OSX and Windows using the JDK (but on windows I just build the maven project and run the programs from the commandline).

      But please read the linked discussion, check the part about cache en/disabling. If this does not help, please write again, so we can find out what’s going wrong.

      greetings
      Peter

  41. Pingback: Misconceptions and Facts: Lies and Truth About the Business of Modeling

  42. Pingback: My Homepage

Leave a Reply

Your email address will not be published. Required fields are marked *