Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-pick upstream#778 #75

Merged
merged 4 commits into from
May 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 34 additions & 16 deletions example/lib/place_fill.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ class PlaceFillBodyState extends State<PlaceFillBody> {
static final LatLng center = const LatLng(-33.86711, 151.1947171);
final String _fillPatternImage = "assets/fill/cat_silhouette_pattern.png";

final List<List<LatLng>> _defaultGeometry = [
[
LatLng(-33.719, 151.150),
LatLng(-33.858, 151.150),
LatLng(-33.866, 151.401),
LatLng(-33.747, 151.328),
LatLng(-33.719, 151.150),
],
[
LatLng(-33.762, 151.250),
LatLng(-33.827, 151.250),
LatLng(-33.833, 151.347),
LatLng(-33.762, 151.250),
]
];

MaplibreMapController? controller;
int _fillCount = 0;
Fill? _selectedFill;
Expand Down Expand Up @@ -71,21 +87,10 @@ class PlaceFillBodyState extends State<PlaceFillBody> {

void _add() {
controller!.addFill(
FillOptions(geometry: [
[
LatLng(-33.719, 151.150),
LatLng(-33.858, 151.150),
LatLng(-33.866, 151.401),
LatLng(-33.747, 151.328),
LatLng(-33.719, 151.150),
],
[
LatLng(-33.762, 151.250),
LatLng(-33.827, 151.250),
LatLng(-33.833, 151.347),
LatLng(-33.762, 151.250),
]
], fillColor: "#FF0000", fillOutlineColor: "#FF0000"),
FillOptions(
geometry: _defaultGeometry,
fillColor: "#FF0000",
fillOutlineColor: "#FF0000"),
);
setState(() {
_fillCount += 1;
Expand All @@ -101,7 +106,20 @@ class PlaceFillBodyState extends State<PlaceFillBody> {
}

void _changePosition() {
//TODO: Implement change position.
List<List<LatLng>>? geometry = _selectedFill!.options.geometry;

if (geometry == null) {
geometry = _defaultGeometry;
}

_updateSelectedFill(FillOptions(
geometry: geometry
.map((list) => list
.map(
// Move to right with 0.1 degree on longitude
(latLng) => LatLng(latLng.latitude, latLng.longitude + 0.1))
.toList())
.toList()));
}

void _changeDraggable() {
Expand Down