-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allows to change geometry value of an annotation (v11.5.1-alpha04)
- Loading branch information
1 parent
79b7551
commit 53f7cd6
Showing
10 changed files
with
132 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
taskkill -F -im java.exe | ||
taskkill -F -im dotnet.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
src/qs/MapboxMauiQs/Examples/Lab/71.MovingCar/MovingCarExample.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
namespace MapboxMauiQs; | ||
|
||
public class MovingCarExample : ContentPage, IExamplePage, IQueryAttributable | ||
{ | ||
MapboxView map; | ||
IExampleInfo info; | ||
IPosition lastPosition; | ||
|
||
public MovingCarExample() | ||
{ | ||
iOSPage.SetUseSafeArea(this, false); | ||
Content = new Grid | ||
{ | ||
Children = { | ||
(map = new MapboxView()), | ||
new HorizontalStackLayout | ||
{ | ||
VerticalOptions = LayoutOptions.End, | ||
HorizontalOptions = LayoutOptions.Center, | ||
Margin = new Thickness(16), | ||
Spacing = 16, | ||
Children = | ||
{ | ||
new Button | ||
{ | ||
Text = "Move", | ||
Command = new Command(Move), | ||
}, | ||
new Button | ||
{ | ||
Text = "Center", | ||
Command = new Command(Centralize), | ||
}, | ||
}, | ||
}, | ||
} | ||
}; | ||
|
||
map.MapReady += Map_MapReady; | ||
map.MapLoaded += Map_MapLoaded; | ||
} | ||
|
||
private void Centralize(object obj) | ||
{ | ||
if (carAnnotation is null) return; | ||
|
||
map.CameraController.EaseTo(new CameraOptions() | ||
{ | ||
Center = carAnnotation.GeometryValue.Coordinates, | ||
}); | ||
} | ||
|
||
private void Move(object obj) | ||
{ | ||
if (carAnnotation is null) return; | ||
|
||
var currentPosition = carAnnotation.GeometryValue; | ||
carAnnotation.GeometryValue = new GeoJSON.Text.Geometry.Point( | ||
new MapPosition( | ||
currentPosition.Latitude() + 0.001, | ||
currentPosition.Longitude() + 0.0001 | ||
) | ||
); | ||
pointAnnotationManager.UpdateAnnotations(carAnnotation); | ||
} | ||
|
||
public void ApplyQueryAttributes(IDictionary<string, object> query) | ||
{ | ||
info = query["example"] as IExampleInfo; | ||
|
||
Title = info?.Title; | ||
} | ||
|
||
private void Map_MapReady(object sender, EventArgs e) | ||
{ | ||
var centerLocation = lastPosition = new MapPosition(21.0278, 105.8342); | ||
var cameraOptions = new CameraOptions | ||
{ | ||
Center = centerLocation, | ||
Zoom = 14, | ||
}; | ||
|
||
map.CameraOptions = cameraOptions; | ||
map.MapboxStyle = MapboxStyle.MAPBOX_STREETS; | ||
} | ||
|
||
IPointAnnotationManager pointAnnotationManager; | ||
PointAnnotation carAnnotation; | ||
private void Map_MapLoaded(object sender, EventArgs e) | ||
{ | ||
map.Images = [ | ||
new ResolvedImage("CAR", "ic_car_top"), | ||
]; | ||
|
||
pointAnnotationManager = map.AnnotationController.CreatePointAnnotationManager("CARS", LayerPosition.Unknown()); | ||
|
||
carAnnotation = new PointAnnotation(new GeoJSON.Text.Geometry.Point(lastPosition)) | ||
{ | ||
IconImage = "CAR", | ||
}; | ||
pointAnnotationManager.AddAnnotations(carAnnotation); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/qs/MapboxMauiQs/Examples/Lab/71.MovingCar/MovingCarExampleInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace MapboxMauiQs; | ||
|
||
class MovingCarExampleInfo : IExampleInfo | ||
{ | ||
public string Group => "Lab"; | ||
public string Title => "Display a car moving on map"; | ||
public string Subtitle => "Demo how to show a car moving on the map"; | ||
public string PageRoute => typeof(MovingCarExample).FullName; | ||
public int Index => 71; | ||
} |