B4A Library [B4X] [B4A] [B4J] [b4xlib] LeafletView

Screenshot 2026-03-14 173909.png
demoapk.png

LeafletView is a cross-platform wrapper for Leaflet.js, providing a lightweight alternative to Google Maps. It uses OpenStreetMap by default, meaning no API keys are required for basic mapping.

This version is distributed as a .b4xlib, making it easy to include in any B4A or B4J project.

Key Features:​

  • Zero Configuration: No Google Play Services or API keys required.
  • Road Routing: Calculate and draw routes with distance and ETA data via Leaflet Routing Machine.
  • B4X Unified: Identical API for B4A and B4J.
  • Interactive: Built-in events for map interaction, marker clicks, and routing results.
  • Fully Customizable: Toggle zoom controls, attributions, and persistent distance labels via the Designer.

Events:​

  • MarkerClick (Data As Map) - Returns ID and ExtraData.
  • MarkerPopupClick (Data As Map) - Triggered when the popup action is clicked.
  • MapClick (Data As Map) - Returns Lat/Lon of the clicked point.
  • ZoomChanged (Data As Map) - Returns current zoom and center.
  • RoutingFound (Data As Map) - Returns distance (km) and car_eta.
  • RouteClick (Data As Map) - Triggered when tapping the route line.

How to install:​

  1. Download the attached LeafletView.b4xlib and place it in your Additional Libraries folder.
  2. In the B4X IDE, refresh the Libraries tab and check LeafletView.
  3. Add a CustomView in the Abstract Designer and set its Custom Class to LeafletView.
  4. Ensure your project has the JavaObject and JSON libraries selected.

Included in the Download:​

  • LeafletView.b4xlib: The compiled library.
  • Example Project: A demo showing markers, routing, and event handling.
Credits: - Leaflet.js

Support​

If this library is useful to you and you'd like to support my work, feel free to buy me a coffee!
PayPal: yusrahassamo@gmail.com
 

Attachments

  • AC_LeafletView.b4xlib
    4.1 KB · Views: 2
  • Example_AC_LeafletView.zip
    20 KB · Views: 2
Top