Skip to content

Commit

Permalink
Merge branch 'master' into wasm-example
Browse files Browse the repository at this point in the history
  • Loading branch information
JaffaKetchup authored Sep 12, 2024
2 parents 5b51677 + 93e51e7 commit 5fb0e62
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 30 deletions.
87 changes: 81 additions & 6 deletions example/lib/pages/wms_tile_layer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class WMSLayerPage extends StatelessWidget {
children: [
TileLayer(
wmsOptions: WMSTileLayerOptions(
baseUrl: 'https://{s}.s2maps-tiles.eu/wms/?',
baseUrl: 'https://tiles.maps.eox.at/wms?',
layers: const ['s2cloudless-2021_3857'],
),
subdomains: const ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'],
Expand All @@ -32,15 +32,90 @@ class WMSLayerPage extends StatelessWidget {
popupInitialDisplayDuration: const Duration(seconds: 5),
attributions: [
TextSourceAttribution(
'Sentinel-2 cloudless - https://s2maps.eu by EOX IT Services GmbH',
onTap: () => launchUrl(Uri.parse('https://s2maps.eu')),
'Sentinel-2 provided by the European Commission (free, full '
'and open access) [Sentinel-2 cloudless 2016, 2018, 2019, '
'2020, 2021, 2022 & 2023]',
onTap: () => launchUrl(Uri.parse(
'https://sentinel.esa.int/documents/247904/690755/Sentinel_Data_Legal_Notice',
)),
prependCopyright: false,
),
TextSourceAttribution(
'OpenStreetMap © OpenStreetMap contributors [Terrain Light, '
'Terrain, OpenStreetMap, Overlay]',
onTap: () => launchUrl(Uri.parse(
'http://www.openstreetmap.org/copyright',
)),
prependCopyright: false,
),
TextSourceAttribution(
'NaturalEarth public domain [Terrain Light, Terrain, Overlay]',
onTap: () => launchUrl(Uri.parse(
'http://www.naturalearthdata.com/about/terms-of-use/',
)),
prependCopyright: false,
),
const TextSourceAttribution(
'EUDEM © Produced using Copernicus data and information funded '
'by the European Union [Terrain]',
prependCopyright: false,
),
TextSourceAttribution(
'ASTER GDEM is a product of METI and NASA [Terrain Light]',
onTap: () => launchUrl(Uri.parse(
'https://lpdaac.usgs.gov/products/aster_policies',
)),
prependCopyright: false,
),
TextSourceAttribution(
'SRTM © NASA [Terrain]',
onTap: () => launchUrl(Uri.parse('http://www.nasa.gov/')),
prependCopyright: false,
),
TextSourceAttribution(
'GTOPO30 Data available from the U.S. Geological Survey '
'[Terrain Light, Terrain]',
onTap: () => launchUrl(Uri.parse(
'https://lta.cr.usgs.gov/GTOPO30',
)),
prependCopyright: false,
),
const TextSourceAttribution(
'Modified Copernicus Sentinel data 2021',
'CleanTOPO2 public domain [Terrain]',
prependCopyright: false,
),
TextSourceAttribution(
'GEBCO © GEBCO [Terrain Light]',
onTap: () => launchUrl(Uri.parse('http://www.gebco.net/')),
prependCopyright: false,
),
TextSourceAttribution(
'GlobCover © ESA [Terrain]',
onTap: () => launchUrl(Uri.parse(
'http://due.esrin.esa.int/page_globcover.php',
)),
prependCopyright: false,
),
const TextSourceAttribution(
"Blue Marble © NASA's Earth Observatory [Blue Marble]",
prependCopyright: false,
),
const TextSourceAttribution(
"Black Marble © NASA's Earth Observatory [Black Marble]",
prependCopyright: false,
),
TextSourceAttribution(
'Rendering: © EOX [Terrain Light, Terrain, OpenStreetMap, '
'Overlay]',
onTap: () => launchUrl(Uri.parse('http://eox.at/')),
prependCopyright: false,
),
TextSourceAttribution(
'Rendering: EOX::Maps',
onTap: () => launchUrl(Uri.parse('https://maps.eox.at/')),
'Rendering: © MapServer [OpenStreetMap, Overlay]',
onTap: () => launchUrl(Uri.parse(
'https://github.com/mapserver/basemaps',
)),
prependCopyright: false,
),
],
),
Expand Down
4 changes: 2 additions & 2 deletions example/web/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"short_name": "flutter_map",
"start_url": ".",
"display": "standalone",
"background_color": "#0175C2",
"theme_color": "#0175C2",
"background_color": "#8EEA88",
"theme_color": "#8EEA88",
"description": "A versatile mapping package for Flutter, based off leaflet.js, that's simple and easy to learn, yet completely customizable and configurable.",
"orientation": "portrait-primary",
"prefer_related_applications": false,
Expand Down
42 changes: 20 additions & 22 deletions lib/src/layer/polygon_layer/painter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,32 +64,30 @@ base class _PolygonPainter<R extends Object>
origin: hitTestCameraOrigin,
points: projectedPolygon.points,
);

if (projectedCoords.first != projectedCoords.last) {
projectedCoords.add(projectedCoords.first);
}
final isInPolygon = isPointInPolygon(point, projectedCoords);

final hasHoles = projectedPolygon.holePoints.isNotEmpty;
final isInHole = hasHoles &&
() {
for (final points in projectedPolygon.holePoints) {
final projectedHoleCoords = getOffsetsXY(
camera: camera,
origin: hitTestCameraOrigin,
points: points,
);

if (projectedHoleCoords.first != projectedHoleCoords.last) {
projectedHoleCoords.add(projectedHoleCoords.first);
}

if (isPointInPolygon(point, projectedHoleCoords)) {
return true;
}
}
return false;
}();
final isValidPolygon = projectedCoords.length >= 3;
final isInPolygon =
isValidPolygon && isPointInPolygon(point, projectedCoords);

final isInHole = projectedPolygon.holePoints.any(
(points) {
final projectedHoleCoords = getOffsetsXY(
camera: camera,
origin: hitTestCameraOrigin,
points: points,
);
if (projectedHoleCoords.first != projectedHoleCoords.last) {
projectedHoleCoords.add(projectedHoleCoords.first);
}

final isValidHolePolygon = projectedHoleCoords.length >= 3;
return isValidHolePolygon &&
isPointInPolygon(point, projectedHoleCoords);
},
);

// Second check handles case where polygon outline intersects a hole,
// ensuring that the hit matches with the visual representation
Expand Down

0 comments on commit 5fb0e62

Please sign in to comment.