diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7b492f50..f63144f5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+### 1.0.0: Update iOS SDK, Stablize APIs
+* replace Tangram es with another ios sdk
+* add `startLocationUpdating`,`stopLocationUpdating` for external control of user location
+* fix some bugs
+* migrate to wasm for web
+* add
### 1.0.0-rc.6: update dependencies
### 1.0.0-rc.5: fix userlocation in android
* fix user location tracking in android side (bug:#507)
diff --git a/README.md b/README.md
index aeac038f..14595cd5 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
# flutter_osm_plugin
-![pub](https://img.shields.io/badge/pub-v1.0.0--rc.6-yellow)
+![pub](https://img.shields.io/badge/pub-v1.0.0-blue)
## Platform Support
@@ -50,7 +50,7 @@
Add the following to your `pubspec.yaml` file:
dependencies:
- flutter_osm_plugin: ^1.0.0-rc.6
+ flutter_osm_plugin: ^1.0.0
@@ -181,6 +181,15 @@ final controller = MapController.withUserPosition(
unFollowUser: false,
)
)
+
+// init the position using the user location and control map from outside
+final controller = MapController.withUserPosition(
+ trackUserLocation: UserTrackingOption(
+ enableTracking: true,
+ unFollowUser: false,
+ ),
+ useExternalTracking: true
+)
```
@@ -202,6 +211,7 @@ final controller = MapController.withUserPosition(
| `initPosition` | (GeoPoint) if it isn't null, the map will be pointed at this position |
| `areaLimit` | (Bounding) set area limit of the map (default BoundingBox.world()) |
| `customLayer` | (CustomTile) set customer layer using different osm server , this attribute used only with named constructor `customLayer` |
+| ` useExternalTracking` | (bool) if true,we will disable our logic to show userlocation marker or to move to the user position |
3.1) Custom Layers with `MapController`
@@ -322,24 +332,32 @@ without need to call `currentLocation`
```dart
await controller.enableTracking(enableStopFollow:false,);
```
+or
+
+> use this method below if you want to control the map(move to the user location and show the marker) while receiving the user location
+```dart
+ await controller.startLocationUpdating();
+```
9) Disable tracking user position
```dart
await controller.disabledTracking();
```
+or
-10) update the location
-
-> this method will create marker on that specific position
+> use this method below if you already used `startLocationUpdating`
```dart
- await controller.changeLocation(GeoPoint(latitude: 47.35387, longitude: 8.43609));
+ await controller.stopLocationUpdating();
```
+
+10) update the location
+
> Change the location without create marker
```dart
- await controller.goToLocation(GeoPoint(latitude: 47.35387, longitude: 8.43609));
+ await controller.moveToLocation(GeoPoint(latitude: 47.35387, longitude: 8.43609),animate:true);
```
diff --git a/example/lib/src/home/main_example.dart b/example/lib/src/home/main_example.dart
index 215f4777..aa46eefd 100644
--- a/example/lib/src/home/main_example.dart
+++ b/example/lib/src/home/main_example.dart
@@ -24,8 +24,9 @@ class Main extends StatefulWidget {
class _MainState extends State with OSMMixinObserver {
late MapController controller;
- ValueNotifier trackingNotifier = ValueNotifier(true);
+ ValueNotifier trackingNotifier = ValueNotifier(false);
ValueNotifier showFab = ValueNotifier(false);
+ ValueNotifier disableMapControlUserTracking = ValueNotifier(true);
ValueNotifier userLocationIcon = ValueNotifier(Icons.near_me);
ValueNotifier lastGeoPoint = ValueNotifier(null);
ValueNotifier userLocationNotifier = ValueNotifier(null);
@@ -35,15 +36,22 @@ class _MainState extends State with OSMMixinObserver {
void initState() {
super.initState();
controller = MapController(
- /*initPosition: GeoPoint(
+ initPosition: GeoPoint(
latitude: 47.4358055,
longitude: 8.4737324,
- ),*/
- initMapWithUserPosition: UserTrackingOption(
- enableTracking: trackingNotifier.value,
),
+ // initMapWithUserPosition: UserTrackingOption(
+ // enableTracking: trackingNotifier.value,
+ // ),
+ useExternalTracking: disableMapControlUserTracking.value,
);
controller.addObserver(this);
+ trackingNotifier.addListener(() async {
+ if (userLocationNotifier.value != null && !trackingNotifier.value) {
+ await controller.removeMarker(userLocationNotifier.value!);
+ userLocationNotifier.value = null;
+ }
+ });
}
@override
@@ -56,8 +64,6 @@ class _MainState extends State with OSMMixinObserver {
@override
void onSingleTap(GeoPoint position) {
super.onSingleTap(position);
- debugPrint(position.toString());
- debugPrint(lastGeoPoint.value.toString());
Future.microtask(() async {
if (lastGeoPoint.value != null) {
await controller.changeLocationMarker(
@@ -82,6 +88,7 @@ class _MainState extends State with OSMMixinObserver {
//angle: -pi / 4,
);
}
+ await controller.moveTo(position, animate: true);
lastGeoPoint.value = position;
});
}
@@ -104,9 +111,32 @@ class _MainState extends State with OSMMixinObserver {
}
@override
- void onLocationChanged(GeoPoint userLocation) {
+ void onLocationChanged(UserLocation userLocation) async {
super.onLocationChanged(userLocation);
- userLocationNotifier.value = userLocation;
+ if (disableMapControlUserTracking.value && trackingNotifier.value) {
+ await controller.moveTo(userLocation);
+ if (userLocationNotifier.value == null) {
+ await controller.addMarker(
+ userLocation,
+ markerIcon: MarkerIcon(
+ icon: Icon(Icons.navigation),
+ ),
+ angle: userLocation.angle,
+ );
+ } else {
+ await controller.changeLocationMarker(
+ oldLocation: userLocationNotifier.value!,
+ newLocation: userLocation,
+ angle: userLocation.angle,
+ );
+ }
+ userLocationNotifier.value = userLocation;
+ } else {
+ if (userLocationNotifier.value != null && !trackingNotifier.value) {
+ await controller.removeMarker(userLocationNotifier.value!);
+ userLocationNotifier.value = null;
+ }
+ }
}
@override
@@ -116,6 +146,7 @@ class _MainState extends State with OSMMixinObserver {
@override
Widget build(BuildContext context) {
+ final topPadding = MediaQuery.maybeOf(context)?.viewPadding.top;
return Stack(
children: [
Map(
@@ -141,9 +172,7 @@ class _MainState extends State with OSMMixinObserver {
children: [
if (!kIsWeb) ...[
Positioned(
- top:
- (MediaQuery.maybeOf(context)?.viewPadding.top ?? 26) +
- 48,
+ top: (topPadding ?? 26) + 48,
right: 15,
child: MapRotation(
controller: controller,
@@ -151,9 +180,7 @@ class _MainState extends State with OSMMixinObserver {
)
],
Positioned(
- top: kIsWeb
- ? 26
- : MediaQuery.maybeOf(context)?.viewPadding.top ?? 26.0,
+ top: kIsWeb ? 26 : topPadding ?? 26.0,
left: 12,
child: PointerInterceptor(
child: MainNavigation(),
@@ -165,6 +192,7 @@ class _MainState extends State with OSMMixinObserver {
child: ActivationUserLocation(
controller: controller,
trackingNotifier: trackingNotifier,
+ userLocation: userLocationNotifier,
userLocationIcon: userLocationIcon,
),
),
@@ -176,9 +204,7 @@ class _MainState extends State with OSMMixinObserver {
),
),
Positioned(
- top: kIsWeb
- ? 26
- : MediaQuery.maybeOf(context)?.viewPadding.top,
+ top: kIsWeb ? 26 : topPadding,
left: 64,
right: 72,
child: SearchInMap(
@@ -360,7 +386,7 @@ class Map extends StatelessWidget {
osmOption: OSMOption(
enableRotationByGesture: true,
zoomOption: ZoomOption(
- initZoom: 14,
+ initZoom: 16,
minZoomLevel: 3,
maxZoomLevel: 19,
stepZoom: 1.0,
@@ -395,18 +421,18 @@ class Map extends StatelessWidget {
// ),
),
directionArrowMarker: MarkerIcon(
- // icon: Icon(
- // Icons.navigation_rounded,
- // size: 48,
- // ),
- iconWidget: SizedBox(
- width: 32,
- height: 64,
- child: Image.asset(
- "asset/directionIcon.png",
- scale: .3,
- ),
+ icon: Icon(
+ Icons.navigation_rounded,
+ size: 48,
),
+ // iconWidget: SizedBox(
+ // width: 32,
+ // height: 64,
+ // child: Image.asset(
+ // "asset/directionIcon.png",
+ // scale: .3,
+ // ),
+ // ),
)
// directionArrowMarker: MarkerIcon(
// assetMarker: AssetMarker(
@@ -477,12 +503,14 @@ class ActivationUserLocation extends StatelessWidget {
final ValueNotifier trackingNotifier;
final MapController controller;
final ValueNotifier userLocationIcon;
+ final ValueNotifier userLocation;
const ActivationUserLocation({
super.key,
required this.trackingNotifier,
required this.controller,
required this.userLocationIcon,
+ required this.userLocation,
});
@override
Widget build(BuildContext context) {
@@ -490,28 +518,35 @@ class ActivationUserLocation extends StatelessWidget {
child: GestureDetector(
behavior: HitTestBehavior.deferToChild,
onLongPress: () async {
- await controller.disabledTracking();
+ //await controller.disabledTracking();
+ await controller.stopLocationUpdating();
trackingNotifier.value = false;
},
child: FloatingActionButton(
key: UniqueKey(),
onPressed: () async {
if (!trackingNotifier.value) {
- await controller.currentLocation();
+ /*await controller.currentLocation();
await controller.enableTracking(
enableStopFollow: true,
- disableUserMarkerRotation: true,
- anchor: Anchor.left,
- );
+ disableUserMarkerRotation: false,
+ anchor: Anchor.right,
+ useDirectionMarker: true,
+ );*/
+ await controller.startLocationUpdating();
trackingNotifier.value = true;
//await controller.zoom(5.0);
} else {
- await controller.enableTracking(
- enableStopFollow: false,
- disableUserMarkerRotation: true,
- anchor: Anchor.left,
- );
+ if (userLocation.value != null) {
+ await controller.moveTo(userLocation.value!);
+ }
+
+ /*await controller.enableTracking(
+ enableStopFollow: false,
+ disableUserMarkerRotation: true,
+ anchor: Anchor.center,
+ useDirectionMarker: true);*/
// if (userLocationNotifier.value != null) {
// await controller
// .goToLocation(userLocationNotifier.value!);
diff --git a/pubspec.yaml b/pubspec.yaml
index d72f527d..cb865021 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,6 +1,6 @@
name: flutter_osm_plugin
description: OpenStreetMap Plugin Native for flutter apps (Andoird/iOS/web)
-version: 1.0.0-rc.6
+version: 1.0.0
homepage: https://github.com/liodali/osm_flutter