mapjfx version 1.17.0 reporting the map’s extent and using OpenLayers 4.6.5

I just released mapjfx version 1.17.0 it should be found shortly at maven central, the artifact coordinates are:

  <dependency>
    <groupId>com.sothawo</groupId>
    <artifactId>mapjfx</artifactId>
    <version>1.17.0</version>
  </dependency>

The source is available at GitHub.

mapjfx now ow uses OpenLayers 4.6.5.

As a new feature, the MapView object now emits events whenever the extent of the map changes. This happens when the center of the map is changed, the zoom value is changed or when the map’s window size is changed. The event can be processed like this:

// add an event handler for extent changes and display them in the status label
mapView.addEventHandler(MapViewEvent.MAP_BOUNDING_EXTENT, event -> {
  event.consume();
  labelExtent.setText(event.getExtent().toString());
});

3 thoughts on “mapjfx version 1.17.0 reporting the map’s extent and using OpenLayers 4.6.5

  1. P.J.,

    Is there any way to receive mouse motion events from the map view? Basically, I would like to see the same behavior as the MAP_CLICKED event, except have this event fired when I move the mouse in the map view window.

    Thanks for your advice,

    Gregg

  2. P.J.,

    I’m wondering if it is possible to have two MapView windows open in the same application with caching enabled? When I tried to do this, my first map view window worked fine. The second one generated an exception:

    WARNING: cannot setup URLStreamFactoryHandler, it is already set in this application. factory already defined
    Exception in thread “JavaFX Application Thread” java.lang.IllegalStateException: cannot setup URLStreamFactoryHandler, it is already set in this application. factory already defined
    at com.sothawo.mapjfx.offline.OfflineCache.setupURLStreamHandlerFactory(OfflineCache.java:187)
    at com.sothawo.mapjfx.offline.OfflineCache.setActive(OfflineCache.java:162)

    I think this is because the call to URL.setURLStreamHandlerFactory() (OfflineCache, line 177) can only be called once / application. My first MapView makes this call. The second MapView is not initialized yet, so tries to also make the same call but fails.

    Maybe this could be resolved if OfflineCache and urlStreamHandlerFactoryIsInitialized were static variables? Then multiple MapViews would use the same OfflineCache – not sure if this would cause other problems or not.

    Thanks for taking a look…

    Best wishes,

    Gregg.

Leave a Reply

Your email address will not be published.