B4J Library jOpenStreetMaps library

Discussion in 'B4J Libraries & Classes' started by Starchild, Feb 2, 2018.

  1. Starchild

    Starchild Active Member Licensed User

    Thanks to "WarWound" and his original library project "JfxtrasMapPane" in the post OSM Open Street Map for B4J back in 2014 which was based on the jfxtras 2.2 r5 source, I have been able to release this updated library.

    Bug fixes:
    ... Left mouse click now works. In fact all 3 mouse buttons are resolved.

    ... Polygons can now be added/removed from map (MapPolygon class)
    ... Map tile providers have been updated.
    ... proper attributions for map tile providers have been added to the maps.
    ... now supports a local map cache for faster redraws.
    ... added a default Map Icon class containing ready to use icons (pins, car, truck, etc)
    ... map markers and can have their size, rotation, shadow set at initialisation.

    Most Classes have been renamed and additional properties/functions added to classes.
    ... MapPane class is now OpenStreetMaps class.
    ... SimpleMapMarker class is now MapSpot class.
    ... MapLine is now MapPolyline.
    ... Initialisation functions for many classes have been changed and added.

    Generally this library is a lot more friendly, in fact similar in a lot of ways to jGooleMaps library.

    Just to note that the OpenStreetMap® is open data, licensed under the Open Data Commons Open Database License (ODbL) by the OpenStreetMap Foundation (OSMF).

    Mapnik map tiles are released under LGPL (GNU Lesser General Public Licence v2.1).

    The included map tile sets by © Stamen Design, are under a Creative Commons Attribution (CC BY 3.0) license.


    Here is the new library "jOpenStreetMaps" now v1-02

    I have also made available an example B4j project called "My OSM Demo".
    The demo has also been updated to demonstrate some of the new features.

    Attached Files:

    Last edited: Feb 6, 2018
    Mashiane, BPak, MichalK73 and 9 others like this.
  2. Informatix

    Informatix Expert Licensed User

    Apart from the fact that your demo requires libraries that are not really required, I have frequently this error while using it (silent error, without crash):
    java.lang.IllegalArgumentException: image == null!
  3. Informatix

    Informatix Expert Licensed User

  4. Starchild

    Starchild Active Member Licensed User

    I have updated the "My OSM Demo" project so that it no longer referances the unused libraries.

    Regarding the null image error, if it relates to the generation of a custom tile source then try declaring a
    cs.GetAttributionImage = YourLogoImage
    in the procedure

    If not, please post the error report so I can check in the library code.
  5. Starchild

    Starchild Active Member Licensed User

    I have updated the jOpenStreetMaps library to v1.01
    Also updated the "My OSM Demo" to help demonstrate some of the additions.

    v1.01 changes
    ... MapMarker.Initialize3() now supports loading an image using Dir and File strings (ie can now load from assets folder)
    ... added MapDraggable property to enable/disable internal mouse dragging of the map.
    ... revealed map OSM events; MousePressed, MouseReleased, MouseClicked, MouseMoved, MouseDragged.
    ... added MapSpot events, now has; MousePressed, MouseReleased, MouseClicked, MouseDragged.
    ... added MapMarker events, now has; MousePressed, MouseReleased, MouseClicked, MouseDragged.
    ... removed some unrequired legacy functions revealed by the original MapPane project.
    Informatix likes this.
  6. Informatix

    Informatix Expert Licensed User

    I still have the error below with the new demo and library (as the website still returns a 404 error, I'm not very surprised by the result):

    If I replace the line by this one, it works:

    Last edited: Feb 5, 2018
  7. Starchild

    Starchild Active Member Licensed User

    Interesting. I did not realise that "My Custom TS" was not presenting ANY map tiles for you as it worked fine for me without any errors. I think that maybe this tile server is blocked to your location.

    I decided to try to access the tile server with the firewall blocked and then I experienced the reported error.
    This bug has now been fixed, trapped and now presents an "X" blank tile if no valid map tile was received from the server.

    As others may also have the same problem accessing this tile server I am updating my demo project with your recommended custom tile source.

    Informatix likes this.
  8. Starchild

    Starchild Active Member Licensed User

    I have updated the jOpenStreetMaps library to v1.02

    v1.02 changes
    ... fixed the custom tile source issue reported above by "Informatix". Now displays "X" tile if no valid map tile is received from server.
    ... Added X() and Y() functions (read only) to the MapSpot. The current map X/Y position. Add them to EventData X/Y values.
    ... Added MoveTo(lat,lon) function to a MapSpot. This with the Pressed/Dragged/Released events allows the Spot to be dragged on the Map. Now useful as "Anchors" for editing Polylines and Polygons.
    ... removed the legacy SetLat() and SetLon() functions from the MapSpot class as they were incomplete functions, no redraw.

    Update the "My OSM Demo" B4j project to demonstrate dragging a Map Spot (Cairo spot is now draggable).
    Also, changed the custom tile server for a more available one.
    Last edited: Feb 6, 2018
    DonManfred, Informatix and rboeck like this.
  9. Philip Prins

    Philip Prins Active Member Licensed User


    Nice job,

    Is it possible to use a local map created with Mobile Atlas Creator or another program?

  10. DonManfred

    DonManfred Expert Licensed User

    Can you add a LocalTilesource and an Example of using Local Tiles?

    It would be great if we could read Tiles created like Mobile Atlas Creator does generate them.
    I do that with free python scripts to generate Tiles up to zoom level 21.

    May you want to share the Source maybe? I would be pleased to try to build some additions..
    Last edited: Dec 28, 2018
  11. Philip Prins

    Philip Prins Active Member Licensed User

    Hello Starchild

    The map is not working anymore , only certain parts

  12. Starchild

    Starchild Active Member Licensed User

    Access to the osm map tile server has been blocked. The map tiles that are still being displayed are the ones already stored in your local tile cache.

    It seems that OpenStreetMap is being hammered more and more (and even more)
    Refer to these announcements by OSM.

    I use jOpenStreetMaps Library to target my own map server.
    I used the following link to set it all up using an old quad-core PC I had.
    I only required Australia, so the hardware requirement wasn't so bad. (Although, for the world it becomes a serious machine)
    You can do the same.
    This one uses Linux Ubuntu, but there are other instructions for Windows Based Servers.

    There is a wealth of information on the web to help get a map tile server up and running.
    I loaded my map source data from https://download.geofabrik.de/

    Alternately, there are several paid map tile services that can be subscribed to.
    Some have a free developer subscription available.
    I think jOpenStreetMaps library would be able to target some of them (by configuring a CustomTileSource)
    Philip Prins likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice