Skip to content

Commit 63ee5c0

Browse files
committed
Update README.md to improve map view setup and enhance code examples for clarity
Signed-off-by: makbn <[email protected]>
1 parent 472a55e commit 63ee5c0

File tree

1 file changed

+39
-62
lines changed

1 file changed

+39
-62
lines changed

README.md

Lines changed: 39 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,10 @@ public class VaadinMapExample extends VerticalLayout {
149149
setSizeFull();
150150

151151
// Create a map view
152-
JLMapView map = JLMapView.builder()
153-
.jlMapProvider(JLMapProvider.OSM_MAPNIK.build())
152+
mapView = JLMapView.builder()
153+
.jlMapProvider(JLMapProvider.MAP_TILER.parameter(new JLMapOption.Parameter("key", MAP_API_KEY)).build())
154154
.startCoordinate(new JLLatLng(48.864716, 2.349014)) // Paris
155-
.showZoomController(true)
155+
.showZoomController(false)
156156
.build();
157157

158158
add(map);
@@ -165,81 +165,58 @@ public class VaadinMapExample extends VerticalLayout {
165165

166166
### Map Control
167167

168-
```java
168+
```jshelllanguage
169169
// Change the current coordinate
170-
map.setView(JLLatLng.builder()
171-
.
172-
173-
lng(10)
174-
.
175-
176-
lat(10)
177-
.
178-
179-
build());
180-
181-
// Map zoom functionalities
182-
map.
183-
184-
getControlLayer().
185-
186-
setZoom(5);
187-
map.
188-
189-
getControlLayer().
190-
191-
zoomIn(2);
192-
map.
193-
194-
getControlLayer().
195-
196-
zoomOut(1);
170+
mapView.setView(JLLatLng.builder()
171+
.lng(48.864716)
172+
.lat(2.349014)
173+
.build());
174+
// Map zoom functionalities
175+
map.
176+
177+
getControlLayer().setZoom(5);
178+
map.getControlLayer().zoomIn(2);
179+
map.getControlLayer().zoomOut(1);
197180
```
198181

199182
### Adding Markers
200183

201-
```java
184+
```jshelllanguage
202185
// Add a marker to the UI layer
203-
JLMarker marker = map.getUiLayer()
204-
.addMarker(JLLatLng.builder()
205-
.lat(35.63)
206-
.lng(51.45)
207-
.build(), "Tehran", true);
186+
JLMarker marker = map.getUiLayer()
187+
.addMarker(JLLatLng.builder()
188+
.lat(35.63)
189+
.lng(51.45)
190+
.build(), "Tehran", true);
208191
209192
// Add event listeners
210-
marker.
193+
marker.setOnActionListener((jlMarker, event) -> {
194+
if (event instanceof ClickEvent) {
195+
log.info("Marker clicked");
196+
}
197+
});
211198
212-
setOnActionListener((jlMarker, event) ->{
213-
if(event instanceof ClickEvent){
214-
System.out.
215-
216-
println("Marker clicked: "+jlMarker);
217-
}
218-
});
219-
220-
marker.
221-
222-
remove(); // Remove the marker
199+
marker.remove(); // Remove the marker
223200
```
224201

225202
### Adding GeoJSON
226203

227-
```java
204+
```jshelllanguage
228205
import io.github.makbn.jlmap.model.JLGeoJsonOptions;
229206
230207
// Load GeoJSON with custom styling
231-
JLGeoJsonOptions options = JLGeoJsonOptions.builder()
232-
.styleFunction(features -> JLOptions.builder()
233-
.fill(true)
234-
.fillColor(JLColor.fromHex((String) features.get(0).get("fill")))
235-
.fillOpacity((Double) features.get(0).get("fill-opacity"))
236-
.stroke(true)
237-
.color(JLColor.fromHex((String) features.get(0).get("stroke")))
238-
.build())
239-
.build();
240-
241-
JLGeoJson styledGeoJson = map.getGeoJsonLayer()
242-
.addFromUrl("https://example.com/data.geojson", options);
208+
JLGeoJsonOptions options = JLGeoJsonOptions.builder()
209+
.styleFunction(features -> JLOptions.builder()
210+
.fill(true)
211+
.fillColor(JLColor.fromHex((String) features.get(0).get("fill")))
212+
.fillOpacity((Double) features.get(0).get("fill-opacity"))
213+
.stroke(true)
214+
.color(JLColor.fromHex((String) features.get(0).get("stroke")))
215+
.build())
216+
.build();
217+
218+
JLGeoJson styledGeoJson = map.getGeoJsonLayer()
219+
.addFromUrl("https://example.com/data.geojson", options);
243220
```
244221

245222
Read more about examples in

0 commit comments

Comments
 (0)