Skip to content

Commit 2162d37

Browse files
authored
feat!: use EPSG:4326 as default coordinate system (#3451)
* feat!: use EPSG:4326 as default coordinate system Changes the default coordinate system / user projection of the Map component to `EPSG:4326`, a.k.a. GPS coordinates. That means that all coordinates passed to, or returned from the public API are assumed to be in this projection. Internally the component will automatically convert coordinates into the configured view projection. This is a breaking change, and all coordinates that were specified in the previous default (`EPSG:3857`) need to be changed to use `EPSG:4326`. A separate change will allow setting the user projection back to `EPSG:3857`.
1 parent 670741d commit 2162d37

26 files changed

Lines changed: 107 additions & 101 deletions

File tree

‎vaadin-map-flow-parent/vaadin-map-flow-integration-tests/src/main/java/com/vaadin/flow/component/map/DetachAttachPage.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ public DetachAttachPage() {
1111
Map map = new Map();
1212
add(map);
1313
// Modify viewport, so we can test some non-default values
14-
map.getView().setCenter(
15-
new Coordinate(2482424.644689998, 8500614.173537256));
14+
map.getView().setCenter(new Coordinate(22.3, 60.45));
1615
map.getView().setZoom(14);
1716

1817
Div newContainer = new Div();

‎vaadin-map-flow-parent/vaadin-map-flow-integration-tests/src/main/java/com/vaadin/flow/component/map/FeatureEventsPage.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public FeatureEventsPage() {
3535
map.addLayer(secondFeatureLayer);
3636

3737
MarkerFeature secondMarkerFeature = new MarkerFeature(
38-
new Coordinate(2000000, 0));
38+
new Coordinate(20, 0));
3939
secondMarkerFeature.setId("second-marker-feature");
4040
secondFeatureLayer.addFeature(secondMarkerFeature);
4141

@@ -44,7 +44,7 @@ public FeatureEventsPage() {
4444
int numOverlappingMarkers = 3;
4545
for (int i = 0; i < numOverlappingMarkers; i++) {
4646
MarkerFeature overlappingMarker = new MarkerFeature(
47-
new Coordinate(4000000, 0));
47+
new Coordinate(40, 0));
4848
overlappingMarker.setId("overlapping-marker-feature-" + (i + 1));
4949
firstFeatureLayer.addFeature(overlappingMarker);
5050
}

‎vaadin-map-flow-parent/vaadin-map-flow-integration-tests/src/main/java/com/vaadin/flow/component/map/MapEventsPage.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public MapEventsPage() {
3131
int numOverlappingMarkers = 3;
3232
for (int i = 0; i < numOverlappingMarkers; i++) {
3333
MarkerFeature overlappingMarker = new MarkerFeature(
34-
new Coordinate(2000000, 0));
34+
new Coordinate(20, 0));
3535
overlappingMarker.setId("overlapping-marker-feature-" + (i + 1));
3636
map.getFeatureLayer().addFeature(overlappingMarker);
3737
}

‎vaadin-map-flow-parent/vaadin-map-flow-integration-tests/src/main/java/com/vaadin/flow/component/map/MarkerFeaturePage.java‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ public MarkerFeaturePage() {
2222

2323
NativeButton addCustomMarkerFeature = new NativeButton(
2424
"Add custom marker feature", e -> {
25-
Coordinate coordinate = new Coordinate(1233058.1696443919,
26-
6351912.406929109);
25+
Coordinate coordinate = new Coordinate(11.07675, 49.45203);
2726
Icon icon = createCustomIcon();
2827
MarkerFeature feature = new MarkerFeature(coordinate, icon);
2928
map.getFeatureLayer().addFeature(feature);
@@ -35,8 +34,8 @@ public MarkerFeaturePage() {
3534
if (map.getFeatureLayer().getFeatures().size() > 0) {
3635
MarkerFeature feature = (MarkerFeature) map
3736
.getFeatureLayer().getFeatures().get(0);
38-
Coordinate coordinate = new Coordinate(
39-
1233058.1696443919, 6351912.406929109);
37+
Coordinate coordinate = new Coordinate(11.07675,
38+
49.45203);
4039
feature.setCoordinates(coordinate);
4140
}
4241
});

‎vaadin-map-flow-parent/vaadin-map-flow-integration-tests/src/main/java/com/vaadin/flow/component/map/PreserveOnRefreshPage.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ public PreserveOnRefreshPage() {
2020
// Add custom feature layer (makes 3 layers in total)
2121
map.addLayer(new FeatureLayer());
2222
// Modify viewport
23-
map.getView().setCenter(
24-
new Coordinate(2482424.644689998, 8500614.173537256));
23+
map.getView().setCenter(new Coordinate(22.3, 60.45));
2524
map.getView().setZoom(14);
2625
});
2726
customizeMap.setId("customize-map");

‎vaadin-map-flow-parent/vaadin-map-flow-integration-tests/src/main/java/com/vaadin/flow/component/map/ViewPage.java‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@ public ViewPage() {
1313

1414
NativeButton setCenterButton = new NativeButton("Set Center", e -> {
1515
// here we set center
16-
map.getView().setCenter(
17-
new Coordinate(2482424.644689998, 8500614.173537256));
16+
map.getView().setCenter(new Coordinate(22.3, 60.45));
1817
});
1918
setCenterButton.setId("set-center-button");
2019

2120
NativeButton setZoom = new NativeButton("Set Zoom", e -> {
22-
map.getView().setCenter(
23-
new Coordinate(2482424.644689998, 8500614.173537256));
21+
map.getView().setCenter(new Coordinate(22.3, 60.45));
2422
map.getView().setZoom(14);
2523
});
2624
setZoom.setId("set-zoom-button");

‎vaadin-map-flow-parent/vaadin-map-flow-integration-tests/src/main/java/com/vaadin/flow/component/map/demo/ImageWMSDemo.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public ImageWMSDemo() {
3737
map.addLayer(imageLayer);
3838

3939
// Move viewport to US
40-
map.getView().setCenter(new Coordinate(-10997148, 4569099));
40+
map.getView().setCenter(new Coordinate(-98.7890613, 37.9268619));
4141
map.getView().setZoom(4);
4242
}
4343
}

vaadin-map-flow-parent/vaadin-map-flow-integration-tests/src/main/java/com/vaadin/flow/component/map/MapView.java renamed to vaadin-map-flow-parent/vaadin-map-flow-integration-tests/src/main/java/com/vaadin/flow/component/map/demo/SamplerView.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
package com.vaadin.flow.component.map;
1+
package com.vaadin.flow.component.map.demo;
22

33
import com.vaadin.flow.component.html.Div;
44
import com.vaadin.flow.component.html.NativeButton;
55
import com.vaadin.flow.component.html.Span;
6+
import com.vaadin.flow.component.map.Map;
67
import com.vaadin.flow.component.map.configuration.Coordinate;
78
import com.vaadin.flow.component.map.configuration.feature.MarkerFeature;
89
import com.vaadin.flow.component.map.configuration.layer.FeatureLayer;
@@ -15,15 +16,15 @@
1516

1617
import java.util.concurrent.ThreadLocalRandom;
1718

18-
@Route("vaadin-map/map-view")
19-
public class MapView extends Div {
19+
@Route("vaadin-map/demo/sampler")
20+
public class SamplerView extends Div {
2021
Span numMarkers = new Span();
2122

22-
public MapView() {
23+
public SamplerView() {
2324
Map map = new Map();
2425

2526
MarkerFeature nurembergMarker = new MarkerFeature(
26-
new Coordinate(1233058.1696443919, 6351912.406929109));
27+
new Coordinate(11.07675, 49.45203));
2728
map.getFeatureLayer().addFeature(nurembergMarker);
2829

2930
map.addFeatureClickListener(e -> {
@@ -68,15 +69,14 @@ public MapView() {
6869
});
6970

7071
NativeButton showNuremberg = new NativeButton("Show Nuremberg", e -> {
71-
map.getView().setCenter(
72-
new Coordinate(1233058.1696443919, 6351912.406929109));
72+
map.getView().setCenter(new Coordinate(11.07675, 49.45203));
7373
map.getView().setZoom(10);
7474
});
7575

7676
NativeButton showSaintNazaire = new NativeButton("Show Saint Nazaire",
7777
e -> {
78-
map.getView().setCenter(new Coordinate(-244780.24508882355,
79-
5986452.183179816));
78+
map.getView()
79+
.setCenter(new Coordinate(-2.1988983, 47.2711907));
8080
map.getView().setZoom(15);
8181
});
8282

@@ -101,10 +101,10 @@ private void updateNumMarkers(VectorSource vectorSource) {
101101

102102
private void createRandomMarkers(FeatureLayer layer, int count) {
103103
for (int i = 0; i < count; i++) {
104-
double x = ThreadLocalRandom.current().nextDouble(-20026376.39, // NOSONAR
105-
20026376.39);
106-
double y = ThreadLocalRandom.current().nextDouble(-20048966.10, // NOSONAR
107-
20048966.10);
104+
double x = ThreadLocalRandom.current().nextDouble(-180, // NOSONAR
105+
180);
106+
double y = ThreadLocalRandom.current().nextDouble(-90, // NOSONAR
107+
90);
108108

109109
MarkerFeature markerFeature = new MarkerFeature(
110110
new Coordinate(x, y));

‎vaadin-map-flow-parent/vaadin-map-flow-integration-tests/src/main/java/com/vaadin/flow/component/map/demo/TileWMSDemo.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public TileWMSDemo() {
3737
map.addLayer(tileLayer);
3838

3939
// Move viewport to US
40-
map.getView().setCenter(new Coordinate(-10997148, 4569099));
40+
map.getView().setCenter(new Coordinate(-98.7890613, 37.9268619));
4141
map.getView().setZoom(4);
4242
}
4343
}

‎vaadin-map-flow-parent/vaadin-map-flow-integration-tests/src/main/java/com/vaadin/flow/component/map/demo/XYZSourceDemo.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ public XYZSourceDemo() {
2828
map.setBackgroundLayer(tileLayer);
2929

3030
// Move viewport to Cap Haitien
31-
map.getView().setCenter(
32-
new Coordinate(-8037267.235274345, 2244621.2004450094));
31+
map.getView().setCenter(new Coordinate(-72.2, 19.76));
3332
map.getView().setZoom(12);
3433
}
3534
}

0 commit comments

Comments
 (0)