13 | * Implementations of this interface should provide methods to add GeoJSON
14 | * data from various sources, such as files, URLs, or raw content, as well
15 | * as the ability to remove GeoJSON objects from the map.
16 | *
17 | * @author Mehdi Akbarian Rastaghi (@makbn)
18 | */
19 | public interface LeafletGeoJsonLayerInt {
20 |
21 | /**
22 | * Adds a GeoJSON object from a file to the Leaflet map.
23 | *
24 | * @param file The {@link File} object representing the GeoJSON file to be
25 | * added.
26 | * @return The {@link JLGeoJsonObject} representing the added GeoJSON data.
27 | * @throws JLException If there is an error while adding the GeoJSON data.
28 | */
29 | JLGeoJsonObject addFromFile(@NonNull File file) throws JLException;
30 |
31 | /**
32 | * Adds a GeoJSON object from a URL to the Leaflet map.
33 | *
34 | * @param url The URL of the GeoJSON data to be added.
35 | * @return The {@link JLGeoJsonObject} representing the added GeoJSON data.
36 | * @throws JLException If there is an error while adding the GeoJSON data.
37 | */
38 | JLGeoJsonObject addFromUrl(@NonNull String url) throws JLException;
39 |
40 | /**
41 | * Adds a GeoJSON object from raw content to the Leaflet map.
42 | *
43 | * @param content The raw GeoJSON content to be added.
44 | * @return The {@link JLGeoJsonObject} representing the added GeoJSON data.
45 | * @throws JLException If there is an error while adding the GeoJSON data.
46 | */
47 | JLGeoJsonObject addFromContent(@NonNull String content) throws JLException;
48 |
49 | /**
50 | * Removes a GeoJSON object from the Leaflet map.
51 | *
52 | * @param object The {@link JLGeoJsonObject} to be removed from the map.
53 | * @return {@code true} if the removal was successful, {@code false}
54 | * if the object was not found or could not be removed.
55 | */
56 | boolean removeGeoJson(@NonNull JLGeoJsonObject object);
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/io/github/makbn/jlmap/layer/leaflet/LeafletUILayerInt.java:
--------------------------------------------------------------------------------
1 | package io.github.makbn.jlmap.layer.leaflet;
2 |
3 | import io.github.makbn.jlmap.model.JLLatLng;
4 | import io.github.makbn.jlmap.model.JLMarker;
5 | import io.github.makbn.jlmap.model.JLOptions;
6 | import io.github.makbn.jlmap.model.JLPopup;
7 |
8 | /**
9 | * The {@code LeafletUILayerInt} interface defines methods for adding and
10 | * managing user interface elements like markers and popups in a Leaflet map.
11 | * Leaflet is a popular JavaScript library for creating interactive maps,
12 | * and this interface provides a Java API for working with user interface
13 | * elements within Leaflet.
14 | *
15 | * @author Mehdi Akbarian Rastaghi (@makbn)
16 | */
17 | public interface LeafletUILayerInt {
18 |
19 | /**
20 | * Adds a marker to the Leaflet map at the specified geographical
21 | * coordinates.
22 | *
23 | * @param latLng The geographical coordinates (latitude and longitude)
24 | * where the marker should be placed.
25 | * @param text The text content associated with the marker.
26 | * @param draggable {@code true} if the marker should be draggable,
27 | * {@code false} otherwise.
28 | * @return The {@link JLMarker} representing the added marker on the map.
29 | */
30 | JLMarker addMarker(JLLatLng latLng, String text, boolean draggable);
31 |
32 | /**
33 | * Removes a marker from the Leaflet map based on its identifier.
34 | *
35 | * @param id The unique identifier of the marker to be removed.
36 | * @return {@code true} if the marker was successfully removed,
37 | * {@code false} if the marker with the specified identifier was not found.
38 | *
39 | */
40 | boolean removeMarker(int id);
41 |
42 | /**
43 | * Adds a popup to the Leaflet map at the specified geographical
44 | * coordinates with custom options.
45 | *
46 | * @param latLng The geographical coordinates (latitude and longitude)
47 | * where the popup should be displayed.
48 | * @param text The text content of the popup.
49 | * @param options Custom options for configuring the appearance and
50 | * behavior of the popup.
51 | * @return The {@link JLPopup} representing the added popup on the map.
52 | */
53 | JLPopup addPopup(JLLatLng latLng, String text, JLOptions options);
54 |
55 | /**
56 | * Adds a popup to the Leaflet map at the specified geographical
57 | * coordinates with default options.
58 | *
59 | * @param latLng The geographical coordinates (latitude and longitude)
60 | * where the popup should be displayed.
61 | * @param text The text content of the popup.
62 | * @return The {@link JLPopup} representing the added popup on the map.
63 | */
64 | JLPopup addPopup(JLLatLng latLng, String text);
65 |
66 | /**
67 | * Removes a popup from the Leaflet map based on its identifier.
68 | *
69 | * @param id The unique identifier of the popup to be removed.
70 | * @return {@code true} if the popup was successfully removed,
71 | * {@code false} if the popup with the specified identifier
72 | * was not found.
73 | */
74 | boolean removePopup(int id);
75 | }
76 |
77 |
--------------------------------------------------------------------------------
/src/main/java/io/github/makbn/jlmap/layer/leaflet/LeafletVectorLayerInt.java:
--------------------------------------------------------------------------------
1 | package io.github.makbn.jlmap.layer.leaflet;
2 |
3 | import io.github.makbn.jlmap.model.*;
4 |
5 | /**
6 | * The {@code LeafletVectorLayerInt} interface defines methods for adding and managing
7 | * vector-based elements such as polylines, polygons, circles, and circle markers in a
8 | * Leaflet map. Leaflet is a popular JavaScript library for creating interactive maps, and
9 | * this interface provides a Java API for working with vector-based layers within Leaflet.
10 | *
11 | * @author Mehdi Akbarian Rastaghi (@makbn)
12 | */
13 | public interface LeafletVectorLayerInt {
14 |
15 | /**
16 | * Adds a polyline to the Leaflet map with the provided array of vertices.
17 | *
18 | * @param vertices An array of geographical coordinates (latitude and longitude) that define
19 | * the vertices of the polyline.
20 | * @return The {@link JLPolyline} representing the added polyline on the map.
21 | */
22 | JLPolyline addPolyline(JLLatLng[] vertices);
23 |
24 | /**
25 | * Adds a polyline to the Leaflet map with the provided array of vertices and custom options.
26 | *
27 | * @param vertices An array of geographical coordinates (latitude and longitude) that define
28 | * the vertices of the polyline.
29 | * @param options Custom options for configuring the appearance and behavior of the polyline.
30 | * @return The {@link JLPolyline} representing the added polyline on the map.
31 | */
32 | JLPolyline addPolyline(JLLatLng[] vertices, JLOptions options);
33 |
34 | /**
35 | * Removes a polyline from the Leaflet map based on its identifier.
36 | *
37 | * @param id The unique identifier of the polyline to be removed.
38 | * @return {@code true} if the polyline was successfully removed, {@code false} if the
39 | * polyline with the specified identifier was not found.
40 | */
41 |
42 | boolean removePolyline(int id);
43 |
44 | /**
45 | * Adds a multi-polyline to the Leaflet map with the provided array of arrays of vertices.
46 | *
47 | * @param vertices An array of arrays of geographical coordinates (latitude and longitude) that
48 | * define the vertices of multiple polylines.
49 | * @return The {@link JLMultiPolyline} representing the added multi-polyline on the map.
50 | */
51 | JLMultiPolyline addMultiPolyline(JLLatLng[][] vertices);
52 |
53 | /**
54 | * Adds a multi-polyline to the Leaflet map with the provided array of arrays of vertices and custom options.
55 | *
56 | * @param vertices An array of arrays of geographical coordinates (latitude and longitude) that
57 | * define the vertices of multiple polylines.
58 | * @param options Custom options for configuring the appearance and behavior of the multi-polyline.
59 | * @return The {@link JLMultiPolyline} representing the added multi-polyline on the map.
60 | */
61 | JLMultiPolyline addMultiPolyline(JLLatLng[][] vertices, JLOptions options);
62 |
63 | /**
64 | * Removes a multi-polyline from the Leaflet map based on its identifier.
65 | *
66 | * @param id The unique identifier of the multi-polyline to be removed.
67 | * @return {@code true} if the multi-polyline was successfully removed, {@code false} if the
68 | * multi-polyline with the specified identifier was not found.
69 | */
70 | boolean removeMultiPolyline(int id);
71 |
72 | /**
73 | * Adds a polygon to the Leaflet map with the provided array of arrays of vertices and custom options.
74 | *
75 | * @param vertices An array of arrays of geographical coordinates (latitude and longitude) that
76 | * define the vertices of the polygon.
77 | * @param options Custom options for configuring the appearance and behavior of the polygon.
78 | * @return The {@link JLPolygon} representing the added polygon on the map.
79 | */
80 | JLPolygon addPolygon(JLLatLng[][][] vertices, JLOptions options);
81 |
82 | /**
83 | * Adds a polygon to the Leaflet map with the provided array of arrays of vertices.
84 | *
85 | * @param vertices An array of arrays of geographical coordinates (latitude and longitude) that
86 | * define the vertices of the polygon.
87 | * @return The {@link JLPolygon} representing the added polygon on the map.
88 | */
89 | JLPolygon addPolygon(JLLatLng[][][] vertices);
90 |
91 | /**
92 | * Removes a polygon from the Leaflet map based on its identifier.
93 | *
94 | * @param id The unique identifier of the polygon to be removed.
95 | * @return {@code true} if the polygon was successfully removed, {@code false} if the
96 | * polygon with the specified identifier was not found.
97 | */
98 | boolean removePolygon(int id);
99 |
100 | /**
101 | * Adds a circle to the Leaflet map with the provided center coordinates, radius, and custom options.
102 | *
103 | * @param center The geographical coordinates (latitude and longitude) of the circle's center.
104 | * @param radius The radius of the circle in meters.
105 | * @param options Custom options for configuring the appearance and behavior of the circle.
106 | * @return The {@link JLCircle} representing the added circle on the map.
107 | */
108 | JLCircle addCircle(JLLatLng center, int radius, JLOptions options);
109 |
110 | /**
111 | * Adds a circle to the Leaflet map with the provided center coordinates and radius.
112 | *
113 | * @param center The geographical coordinates (latitude and longitude) of the circle's center.
114 | * @return The {@link JLCircle} representing the added circle on the map.
115 | */
116 | JLCircle addCircle(JLLatLng center);
117 |
118 | /**
119 | * Removes a circle from the Leaflet map based on its identifier.
120 | *
121 | * @param id The unique identifier of the circle to be removed.
122 | * @return {@code true} if the circle was successfully removed, {@code false} if the
123 | * circle with the specified identifier was not found.
124 | */
125 | boolean removeCircle(int id);
126 |
127 | /**
128 | * Adds a circle marker to the Leaflet map with the provided center coordinates, radius, and custom options.
129 | *
130 | * @param center The geographical coordinates (latitude and longitude) of the circle marker's center.
131 | * @param radius The radius of the circle marker in pixels.
132 | * @param options Custom options for configuring the appearance and behavior of the circle marker.
133 | * @return The {@link JLCircleMarker} representing the added circle marker on the map.
134 | */
135 | JLCircleMarker addCircleMarker(JLLatLng center, int radius, JLOptions options);
136 |
137 | /**
138 | * Adds a circle marker to the Leaflet map with the provided center coordinates and radius.
139 | *
140 | * @param center The geographical coordinates (latitude and longitude) of the circle marker's center.
141 | * @return The {@link JLCircleMarker} representing the added circle marker on the map.
142 | */
143 | JLCircleMarker addCircleMarker(JLLatLng center);
144 |
145 | /**
146 | * Removes a circle marker from the Leaflet map based on its identifier.
147 | *
148 | * @param id The unique identifier of the circle marker to be removed.
149 | * @return {@code true} if the circle marker was successfully removed, {@code false} if the
150 | * circle marker with the specified identifier was not found.
151 | */
152 | boolean removeCircleMarker(int id);
153 | }
154 |
155 |
--------------------------------------------------------------------------------
/src/main/java/io/github/makbn/jlmap/listener/OnJLMapViewListener.java:
--------------------------------------------------------------------------------
1 | package io.github.makbn.jlmap.listener;
2 |
3 | import io.github.makbn.jlmap.JLMapView;
4 | import io.github.makbn.jlmap.listener.event.Event;
5 | import lombok.NonNull;
6 |
7 |
8 | public interface OnJLMapViewListener {
9 |
10 | /**
11 | * called after the map is fully loaded
12 | *
13 | * @param mapView loaded map
14 | */
15 | void mapLoadedSuccessfully(@NonNull JLMapView mapView);
16 |
17 | /**
18 | * called after the map got an exception on loading
19 | */
20 | void mapFailed();
21 |
22 | default void onAction(Event event) {
23 |
24 | }
25 |
26 |
27 | enum Action {
28 | /**
29 | * zoom level changes continuously
30 | */
31 | ZOOM,
32 | /**
33 | * zoom level stats to change
34 | */
35 | ZOOM_START,
36 | /**
37 | * zoom leve changes end
38 | */
39 | ZOOM_END,
40 |
41 | /**
42 | * map center changes continuously
43 | */
44 | MOVE,
45 | /**
46 | * user starts to move the map
47 | */
48 | MOVE_START,
49 | /**
50 | * user ends to move the map
51 | */
52 | MOVE_END,
53 | /**
54 | * user click on the map
55 | */
56 | CLICK
57 |
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/io/github/makbn/jlmap/listener/OnJLObjectActionListener.java:
--------------------------------------------------------------------------------
1 | package io.github.makbn.jlmap.listener;
2 |
3 | import io.github.makbn.jlmap.model.JLObject;
4 | import lombok.Getter;
5 |
6 |
7 | public abstract class OnJLObjectActionListener