Skip to content

Commit

Permalink
Merge pull request #517 from liodali/1.0.0-dev
Browse files Browse the repository at this point in the history
1.0.0
  • Loading branch information
liodali authored Apr 3, 2024
2 parents 69c9c71 + 713351e commit 5dad876
Show file tree
Hide file tree
Showing 69 changed files with 3,060 additions and 2,401 deletions.
42 changes: 40 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,45 @@
### 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
* replace gotoPosition by moveTo
### 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)
### 1.0.0-rc.4: fix userlocation in ios
* update ios sdk and fix bug related to userlocation
* fix draw border for road in ios side
### 1.0.0-rc.3: fix bugs
* fix bug related to user location in android #507
* update docs(thanx to @vargab95)
### 1.0.0-rc.2: update web dependency
* migrate to wasm
### 1.0.0-rc.1:
* fix bug #500
### 1.0.0-rc:
* add support draw shapes in iOS side
### 1.0.0-dev.4:
* improve picker_map_controller
* improve picker dialog and widget
### 1.0.0-dev.3:
* Dix bug in init map with zoomOption in iOS side
* Add `isEqual` method to `GeoPoint`
* Improve/fix bug in ios sdk
### 1.0.0-dev.2:
* fix bugs for angle/iconAnchor in web side
* fix bug for iconAnchor in iOS side
* fix customTile in ios when it's null
### 1.0.0-dev.1 :
* update readme
### 1.0.0-dev :
* switch iOS sdk
* remove advPicker API
* add toggleLayerVisibility
* fix bugs
### 0.70.4 : fix bugs
* fix bug related to user location in android ( #482, thnx for @vargab95)
* fix launchURl (thnx for @derklaro)
### 0.70.3 :
* fix launchURl (thnx for @derklaro)### 0.70.3 :
* fix bug #480
### 0.70.2 :
* fix bugs (thanks for @JobiJoba)
Expand Down
79 changes: 47 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
</p>

# flutter_osm_plugin
![pub](https://img.shields.io/badge/pub-v0.70.4-orange)

![pub](https://img.shields.io/badge/pub-v1.0.0-blue)


## Platform Support
| Android | iOS | Web |
|:---:|:---:|:---:|
| supported :heavy_check_mark: | supported :heavy_check_mark: (min iOS supported : 12) | supported :heavy_check_mark: |
| supported :heavy_check_mark: | supported :heavy_check_mark: (min iOS supported : 13) | supported :heavy_check_mark: |


<b>osm plugin for flutter apps </b>
Expand All @@ -21,7 +22,7 @@
* customize Icon Marker (Android/iOS/web)
* customize user Marker (Android/iOS/web)
* assisted selection position (Android/iOS)
* set BoundingBox (Android/Web)
* set BoundingBox (Android/iOS/Web)
* zoom into region (Android/iOS/web)
* draw Road (Android/iOS/web)
* recuperate information (instruction/duration/distance) of the current road (Android/iOS/web)
Expand All @@ -31,7 +32,7 @@
* ClickListener on Map (Android/iOS/web)
* calculate distance between 2 points
* address suggestion
* draw shapes (Android/web)
* draw shapes (Android/iOS/web)
* simple dialog location picker (Android/iOS)
* listen to region change (Android/iOS/Web)
* set custom tiles (Android/iOS/Web)
Expand All @@ -49,7 +50,7 @@
Add the following to your `pubspec.yaml` file:

dependencies:
flutter_osm_plugin: ^0.70.4
flutter_osm_plugin: ^1.0.0



Expand Down Expand Up @@ -180,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
)
```


Expand All @@ -201,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 |


<b> 3.1) Custom Layers with `MapController` </b>
Expand Down Expand Up @@ -321,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();
```
<b> 9) Disable tracking user position </b>

```dart
await controller.disabledTracking();
```
or

<b>10) update the location </b>

> 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();
```

<b>10) update the location </b>

> Change the location without create marker
```dart
await controller.goToLocation(GeoPoint(latitude: 47.35387, longitude: 8.43609));
await controller.moveTo(GeoPoint(latitude: 47.35387, longitude: 8.43609),animate:true);
```


Expand Down Expand Up @@ -434,18 +453,6 @@ await controller.setMarkerIcon(GeoPoint,MarkerIcon);
```
* PS : static position cannot be removed by this method

<b>15.4 Assisted selection </b> (for more details see example)

```dart
/// To Start assisted Selection
await controller.advancedPositionPicker();
/// To get location desired
GeoPoint p = await controller.getCurrentPositionAdvancedPositionPicker();
/// To get location desired and close picker
GeoPoint p = await controller.selectAdvancedPositionPicker();
/// To cancel assisted Selection
await controller.cancelAdvancedPositionPicker();
```

<b>16) Draw road,recuperate instructions ,distance in km and duration in sec</b>

Expand Down Expand Up @@ -596,8 +603,10 @@ final configs = [
centerPoint: GeoPoint(latitude: 47.4333594, longitude: 8.4680184),
radius: 1200.0,
color: Colors.red,
borderColor:Colors.green,
strokeWidth: 0.3,
));
)
);
/// to remove Circle using Key
await controller.removeCircle("circle0");
Expand All @@ -612,7 +621,8 @@ final configs = [
key: "rect",
centerPoint: GeoPoint(latitude: 47.4333594, longitude: 8.4680184),
distance: 1200.0,
color: Colors.red,
color: Colors.red.withOpacity(0.4),
borderColor:Colors.green,
strokeWidth: 0.3,
));
/// to remove Rect using Key
Expand All @@ -639,12 +649,13 @@ final configs = [
| Methods | Description |
| ----------------------------- | ----------------------------------- |
| `mapIsReady` | (callback) Should be override this method, to get notified when map is ready to go or not, |
| `mapRestored` | (callback) Should be override this method, to get notified when map is restored you can also add you bakcup |
| `onSingleTap` | (callback) Notified when user make single click on marker |
| `onLongTap` | (callback) Called when map make long click on marker |
| `onRegionChanged` | (callback) Notified when map is change regsion (on moves) |
| `onRoadTap` | (callback) Notified when user click on the poyline (road) |
| `mapIsReady` | (callback) Should be override this method, to get notified when map is ready to go or not |
| `mapRestored` | (callback) Should be override this method, to get notified when map is restored you can also add you backup |
| `onSingleTap` | (callback) Called when the user makes single click on map |
| `onLongTap` | (callback) Called when the user makes long click on map |
| `onRegionChanged` | (callback) Notified when map is change region (on moves) |
| `onRoadTap` | (callback) Notified when user click on the polyline (road) |
| `onLocationChanged` | (callback) Notified when user location changed |


** example
Expand Down Expand Up @@ -685,14 +696,17 @@ class YourOwnStateWidget extends State<YourWidget> with OSMMixinObserver {
void onRegionChanged(Region region) {
super.onRegionChanged();
/// TODO
}
@override
void onRoadTap(RoadInfo road) {
super.onRoadTap();
/// TODO
}
@override
void onLocationChanged(GeoPoint userLocation) {
super.onLocationChanged();
/// TODO
}
}
```
Expand All @@ -707,6 +721,7 @@ class YourOwnStateWidget extends State<YourWidget> with OSMMixinObserver {
| `osmOption` | (OSMOption) used to configure OSM Map such as zoom,road,userLocationMarker |
| `onGeoPointClicked` | (callback) listener triggered when marker is clicked ,return current geoPoint of the marker |
| `onLocationChanged` | (callback) it is fired when you activate tracking and user position has been changed |
| `onMapMoved` | (callback) it is each the map moved user handler or navigate to another location using APIs |
| `onMapIsReady` | (callback) listener trigger to get map is initialized or not |

## `OSMOption`
Expand Down
10 changes: 5 additions & 5 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ group 'hamza.dali.flutter_osm_plugin'
version '1.0'

buildscript {
ext.kotlin_version = '1.8.22'
ext.kotlin_version = '1.9.22'
repositories {
google()
mavenCentral()
Expand All @@ -28,7 +28,7 @@ apply plugin: 'kotlin-android'
//apply plugin: 'kotlin-kapt'

android {
compileSdk 33
compileSdk 34
namespace "hamza.dali.flutter_osm_plugin"

sourceSets {
Expand Down Expand Up @@ -64,7 +64,7 @@ android {
}
dependencies {

def coroutines_version ="1.6.1"
def coroutines_version ="1.7.3"

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
Expand All @@ -87,9 +87,9 @@ dependencies {
//implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"

implementation 'org.osmdroid:osmdroid-android:6.1.17'
implementation 'org.osmdroid:osmdroid-android:6.1.18'
implementation 'com.github.MKergall:osmbonuspack:6.9.0'
implementation 'com.google.android.material:material:1.10.0'
implementation 'com.google.android.material:material:1.11.0'

coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,14 @@ import java.util.concurrent.atomic.AtomicInteger

class FlutterOsmPlugin :
FlutterPlugin, ActivityAware {
var factory: OsmFactory? = null
private var factory: OsmFactory? = null
companion object {
var mapSnapShots = ArrayMap<String, MapSnapShot>()
var lastKeysRestarted: ArrayMap<String, Boolean>? = ArrayMap()


var state = AtomicInteger(0)
var pluginBinding: ActivityPluginBinding? = null
var lifecycle: Lifecycle? = null
var register: PluginRegistry.Registrar? = null
//private var register: PluginRegistry.Registrar? = null
const val VIEW_TYPE = "plugins.dali.hamza/osmview"
const val CREATED = 1
const val STARTED = 2
Expand All @@ -40,7 +38,7 @@ class FlutterOsmPlugin :
const val STOPPED = 5
const val DESTROYED = 6

@JvmStatic
/*@JvmStatic
fun registerWith(register: PluginRegistry.Registrar) {
val registerActivity: Activity = register.activity() ?: return
this.register = register
Expand All @@ -57,7 +55,7 @@ class FlutterOsmPlugin :
},
),
)
}
}*/
}

override fun onAttachedToEngine(binding: FlutterPluginBinding) {
Expand All @@ -68,7 +66,7 @@ class FlutterOsmPlugin :
factory = OsmFactory(
binding.binaryMessenger,
object : ProviderLifecycle {
override fun getLifecyle(): Lifecycle? = lifecycle
override fun getOSMLifecycle(): Lifecycle? = lifecycle
},
)
binding.platformViewRegistry.registerViewFactory(
Expand Down Expand Up @@ -107,13 +105,13 @@ class FlutterOsmPlugin :
//lifecycle?.removeObserver(this)
lifecycle = null
pluginBinding = null

mapSnapShots.clear()
}

}

interface ProviderLifecycle {
fun getLifecyle(): Lifecycle?
fun getOSMLifecycle(): Lifecycle?
}

private class ProxyLifecycleProvider constructor(
Expand Down Expand Up @@ -172,6 +170,6 @@ private class ProxyLifecycleProvider constructor(
}


override fun getLifecyle(): Lifecycle = lifecycle
override fun getOSMLifecycle(): Lifecycle = lifecycle

}
Loading

0 comments on commit 5dad876

Please sign in to comment.