Skip to content

Commit

Permalink
Merge pull request liodali#238 from liodali/0.32.1
Browse files Browse the repository at this point in the history
0.32.1
  • Loading branch information
liodali authored Mar 13, 2022
2 parents 1cc591f + 8b4d8f9 commit bb4dd7a
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 91 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.32.1: fix bugs
* fix order of drawing marker and polyline in drawRoadManually
* fix show the right custom icon marker
## 0.32.0:
* add `iconWidget` in `MarkerIcon` to show dynamic widget
* support show interestPoint for drawing road manually
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# flutter_osm_plugin
![pub](https://img.shields.io/badge/pub-v0.32.0-orange)
![pub](https://img.shields.io/badge/pub-v0.32.1-orange)


## Platform Support
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1034,66 +1034,6 @@ class FlutterOsmView(
}


private fun drawRoadManually(call: MethodCall, result: MethodChannel.Result) {
val args: HashMap<String, Any> = call.arguments as HashMap<String, Any>

val encodedWayPoints = (args["road"] as String)
val colorRoad = (args["roadColor"] as List<Int>)
val color = Color.rgb(colorRoad.first(), colorRoad.last(), colorRoad[1])
val widthRoad = (args["roadWidth"] as Double)
val zoomToRegion = args["zoomInto"] as Boolean
val clearPreviousRoad = args["clearPreviousRoad"] as Boolean
val interestPointsEncoded = args["interestPoints"] as String?
val iconInterestPoints = args["iconInterestPoints"] as ByteArray?
checkRoadFolderAboveUserOverlay()
if (clearPreviousRoad) {
folderRoad.items.clear()
}
var bitmapIconInterestPoints :Bitmap? = null
if (iconInterestPoints != null){
bitmapIconInterestPoints = getBitmap(bytes = iconInterestPoints!!)
}



val route = PolylineEncoder.decode(encodedWayPoints, 10, false)
val listInterestPoints = when (interestPointsEncoded != null) {
true -> PolylineEncoder.decode(interestPointsEncoded, 10, false)
false -> emptyList<GeoPoint>()
}

val polyLine = Polyline(map!!)
polyLine.setPoints(route)
polyLine.outlinePaint.color = color
polyLine.outlinePaint.strokeWidth = widthRoad.toFloat()
createRoad(
polyLine = polyLine,
colorRoad = color,
roadWidth = widthRoad.toFloat(),
showPoiMarker = listInterestPoints.isNotEmpty(),
listInterestPoints = listInterestPoints,
bitmapIcon = bitmapIconInterestPoints
)
folderRoad.items.add(polyLine)

mapSnapShot().cacheRoad(
RoadSnapShot(
roadPoints = route,
roadColor = color,
roadWith = widthRoad.toFloat(),
showIcons = false,
)
)
if (zoomToRegion) {
map!!.zoomToBoundingBox(
BoundingBox.fromGeoPoints(polyLine.actualPoints),
true,
64,
)
}
map!!.invalidate()
result.success(null)
}

private fun trackUserLocation(result: MethodChannel.Result) {
try {
Expand Down Expand Up @@ -1588,6 +1528,65 @@ class FlutterOsmView(
}
}

private fun drawRoadManually(call: MethodCall, result: MethodChannel.Result) {
val args: HashMap<String, Any> = call.arguments as HashMap<String, Any>

val encodedWayPoints = (args["road"] as String)
val colorRoad = (args["roadColor"] as List<Int>)
val color = Color.rgb(colorRoad.first(), colorRoad.last(), colorRoad[1])
val widthRoad = (args["roadWidth"] as Double)
val zoomToRegion = args["zoomInto"] as Boolean
val clearPreviousRoad = args["clearPreviousRoad"] as Boolean
val interestPointsEncoded = args["interestPoints"] as String?
val iconInterestPoints = args["iconInterestPoints"] as ByteArray?
checkRoadFolderAboveUserOverlay()
if (clearPreviousRoad) {
folderRoad.items.clear()
}
var bitmapIconInterestPoints: Bitmap? = null
if (iconInterestPoints != null) {
bitmapIconInterestPoints = getBitmap(bytes = iconInterestPoints!!)
}


val route = PolylineEncoder.decode(encodedWayPoints, 10, false)
val listInterestPoints = when (interestPointsEncoded != null) {
true -> PolylineEncoder.decode(interestPointsEncoded, 10, false)
false -> emptyList<GeoPoint>()
}

val polyLine = Polyline(map!!)
polyLine.setPoints(route)
polyLine.outlinePaint.color = color
polyLine.outlinePaint.strokeWidth = widthRoad.toFloat()
createRoad(
polyLine = polyLine,
colorRoad = color,
roadWidth = widthRoad.toFloat(),
showPoiMarker = listInterestPoints.isNotEmpty(),
listInterestPoints = listInterestPoints,
bitmapIcon = bitmapIconInterestPoints
)

mapSnapShot().cacheRoad(
RoadSnapShot(
roadPoints = route,
roadColor = color,
roadWith = widthRoad.toFloat(),
showIcons = false,
)
)
if (zoomToRegion) {
map!!.zoomToBoundingBox(
BoundingBox.fromGeoPoints(polyLine.actualPoints),
true,
64,
)
}
map!!.invalidate()
result.success(null)
}

private fun createRoad(
polyLine: Polyline,
colorRoad: Int?,
Expand All @@ -1604,11 +1603,21 @@ class FlutterOsmView(
polyLine.outlinePaint.color = colorRoad ?: Color.GREEN

val iconsRoads = customRoadMarkerIcon
if (iconsRoads.isEmpty() && bitmapIcon != null) {
iconsRoads[Constants.STARTPOSITIONROAD] = bitmapIcon
iconsRoads[Constants.MIDDLEPOSITIONROAD] = bitmapIcon
iconsRoads[Constants.ENDPOSITIONROAD] = bitmapIcon

when {
(iconsRoads.isEmpty() && bitmapIcon != null) -> {
iconsRoads[Constants.STARTPOSITIONROAD] = bitmapIcon
iconsRoads[Constants.MIDDLEPOSITIONROAD] = bitmapIcon
iconsRoads[Constants.ENDPOSITIONROAD] = bitmapIcon
}
iconsRoads.isNotEmpty() && bitmapIcon != null -> {
iconsRoads[Constants.MIDDLEPOSITIONROAD] = bitmapIcon
if (!iconsRoads.containsKey(Constants.STARTPOSITIONROAD)) {
iconsRoads[Constants.STARTPOSITIONROAD] = bitmapIcon
}
if (!iconsRoads.containsKey(Constants.ENDPOSITIONROAD)) {
iconsRoads[Constants.ENDPOSITIONROAD] = bitmapIcon
}
}
}
val flutterRoad = FlutterRoad(
context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ open class FlutterRoad(
if (value != null) {
field = value
items.add(value)

if (showInterestPoints) {
initStartEndPoints(
value.actualPoints.first(),
value.actualPoints.last(),
interestPoint
)
}

}
}
var markersIcons: HashMap<String, Bitmap> = HashMap()
Expand All @@ -54,9 +54,6 @@ open class FlutterRoad(
this.mapIconsBitmaps = markersIcons
this.iconPosition(Constants.PositionMarker.END)
}

items.add(start)
items.add(end)
if(interestPoint.isNotEmpty()){
if (interestPoint.first() == startRoad) {
listInterest.removeFirst()
Expand All @@ -77,7 +74,8 @@ open class FlutterRoad(
items.addAll(middlePoints.toList())

}

items.add(start)
items.add(end)
}


Expand Down
25 changes: 13 additions & 12 deletions example/lib/src/home/home_example.dart

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ packages:
path: "../flutter_osm_interface"
relative: true
source: path
version: "0.1.18"
version: "0.1.19"
flutter_osm_plugin:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "0.31.0"
version: "0.32.0"
flutter_plugin_android_lifecycle:
dependency: transitive
description:
Expand Down
9 changes: 8 additions & 1 deletion flutter_osm_interface/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.11"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
meta:
dependency: transitive
description:
Expand Down Expand Up @@ -176,7 +183,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.3"
version: "0.4.8"
typed_data:
dependency: transitive
description:
Expand Down
3 changes: 0 additions & 3 deletions lib/src/widgets/mobile_osm_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ class MobileOsmFlutterState extends State<MobileOsmFlutter>
var mobileKey = GlobalKey();
GlobalKey androidKey = GlobalKey();

//permission status
PermissionStatus? _permission;

GlobalKey get defaultMarkerKey => widget.globalKeys[0];

GlobalKey get advancedPickerMarker => widget.globalKeys[1];
Expand Down
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ packages:
path: flutter_osm_interface
relative: true
source: path
version: "0.1.18"
version: "0.1.19"
flutter_plugin_android_lifecycle:
dependency: "direct main"
description:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_osm_plugin
description: OpenStreetMap Plugin Native for flutter apps (Andoird/iOS supported,web is under-dev)
version: 0.32.0
version: 0.32.1


homepage: https://github.com/liodali/osm_flutter
Expand Down

0 comments on commit bb4dd7a

Please sign in to comment.