diff --git a/android/build.gradle b/android/build.gradle index 30a4b58..ab76d62 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,14 +2,14 @@ group 'com.apptreesoftware.mapview' version '1.0-SNAPSHOT' buildscript { - ext.kotlin_version = '1.2.50' + ext.kotlin_version = '1.2.51' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.1.2' + classpath 'com.android.tools.build:gradle:3.1.3' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -45,6 +45,7 @@ android { dependencies { implementation 'com.android.support:appcompat-v7:27.1.1' - implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.50' + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'com.google.android.gms:play-services-maps:15.0.1' + implementation 'com.google.maps.android:android-maps-utils:0.5' } diff --git a/android/src/main/kotlin/com/apptreesoftware/mapview/MapActivity.kt b/android/src/main/kotlin/com/apptreesoftware/mapview/MapActivity.kt index 2ab5694..8c59fd2 100644 --- a/android/src/main/kotlin/com/apptreesoftware/mapview/MapActivity.kt +++ b/android/src/main/kotlin/com/apptreesoftware/mapview/MapActivity.kt @@ -20,6 +20,7 @@ import com.google.android.gms.maps.model.* class MapActivity : AppCompatActivity(), OnMapReadyCallback { + var menu: Menu? = null var googleMap: GoogleMap? = null var markerIdLookup = HashMap() var polylineIdLookup = HashMap() @@ -122,13 +123,54 @@ class MapActivity : AppCompatActivity(), } override fun onCreateOptionsMenu(menu: Menu): Boolean { + this.menu = menu MapViewPlugin.toolbarActions.forEach { - val item = menu.add(0, it.identifier, 0, it.title) - item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM) + addMenuItem(it) } return super.onCreateOptionsMenu(menu) } + fun addMenuItem(toolbarAction: ToolbarAction) { + if (this.menu != null) { + val menuItem = menu?.findItem(toolbarAction.identifier) + if (menuItem == null) { + val item = menu?.add(0, toolbarAction.identifier, 0, toolbarAction.title) + if (toolbarAction.showIfRoom) { + item?.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM) + } else { + item?.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS) + } + } + } + } + + fun editMenuItem(toolbarAction: ToolbarAction) { + if (this.menu != null) { + val menuItem = menu?.findItem(toolbarAction.identifier) + if (menuItem != null) { + menuItem.title = toolbarAction.title + if (toolbarAction.showIfRoom) { + menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM) + } else { + menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS) + } + } + } + } + + fun removeMenuItem(id: Int) { + if (this.menu != null) { + menu?.removeItem(id) + } + } + + fun setMenuItemVisibility(id: Int, visible: Boolean) { + if (this.menu != null) { + val menuItem = menu?.findItem(id) + if (menuItem != null) + menuItem.setVisible(visible) + } + } override fun onOptionsItemSelected(item: MenuItem): Boolean { MapViewPlugin.handleToolbarAction(item.itemId) diff --git a/android/src/main/kotlin/com/apptreesoftware/mapview/MapPolygon.kt b/android/src/main/kotlin/com/apptreesoftware/mapview/MapPolygon.kt index 6b1f3ae..e5e8e79 100644 --- a/android/src/main/kotlin/com/apptreesoftware/mapview/MapPolygon.kt +++ b/android/src/main/kotlin/com/apptreesoftware/mapview/MapPolygon.kt @@ -2,7 +2,7 @@ package com.apptreesoftware.mapview import com.google.android.gms.maps.model.LatLng -open class MapPolygon(val identifier: String, val points: ArrayList, val holes: ArrayList, val strokeWidth: Float, +open class MapPolygon(val identifier: String, val points: List, val holes: ArrayList, val strokeWidth: Float, val fillColor: Int, val strokeColor: Int, val jointType: Int) { companion object { fun fromMap(map: Map): MapPolygon? { @@ -16,16 +16,9 @@ open class MapPolygon(val identifier: String, val points: ArrayList, val pointsList.add(LatLng(latitude, longitude)) } val holesParam = map["holes"] as ArrayList>> - for (hole in holesParam) { - val holePointsMap = hole["points"] as ArrayList> - val holePoints = arrayListOf() - holePointsMap.forEach { - val latitude: Double = it["latitude"] as Double - val longitude: Double = it["longitude"] as Double - holePoints.add(LatLng(latitude, longitude)) - } - if (holePoints.isNotEmpty()) - holesList.add(Hole(holePoints)) + for (holeMap in holesParam) { + val hole = Hole.fromMap(holeMap) + holesList.add(hole) } val fillColorMap = map["fillColor"] as Map val strokeColorMap = map["strokeColor"] as Map @@ -38,5 +31,18 @@ open class MapPolygon(val identifier: String, val points: ArrayList, val } } -class Hole(val points: ArrayList) +class Hole(val points: List) { + companion object { + fun fromMap(map: Map>): Hole { + val pointsList = arrayListOf(); + val pointsParam = map["points"] as List> + pointsParam.forEach { + val latitude: Double = it["latitude"] as Double + val longitude: Double = it["longitude"] as Double + pointsList.add(LatLng(latitude, longitude)) + } + return Hole(pointsList) + } + } +} diff --git a/android/src/main/kotlin/com/apptreesoftware/mapview/MapPolyline.kt b/android/src/main/kotlin/com/apptreesoftware/mapview/MapPolyline.kt index 0ae5bca..cd87b4b 100644 --- a/android/src/main/kotlin/com/apptreesoftware/mapview/MapPolyline.kt +++ b/android/src/main/kotlin/com/apptreesoftware/mapview/MapPolyline.kt @@ -1,18 +1,16 @@ package com.apptreesoftware.mapview import android.graphics.Color -import android.util.Log -import com.google.android.gms.maps.model.JointType import com.google.android.gms.maps.model.LatLng -open class MapPolyline(val identifier: String, val points: ArrayList, val width: Float, +open class MapPolyline(val identifier: String, val points: List, val width: Float, val color: Int, val jointType: Int) { companion object { fun fromMap(map: Map): MapPolyline? { val identifier = map["id"] as String val pointsList = arrayListOf(); - val pointsParam = map["points"] as ArrayList> - pointsParam.forEach { + val points = map["points"] as List> + points.forEach { val latitude: Double = it["latitude"] as Double val longitude: Double = it["longitude"] as Double pointsList.add(LatLng(latitude, longitude)) diff --git a/android/src/main/kotlin/com/apptreesoftware/mapview/MapViewPlugin.kt b/android/src/main/kotlin/com/apptreesoftware/mapview/MapViewPlugin.kt index 699ca65..999d334 100644 --- a/android/src/main/kotlin/com/apptreesoftware/mapview/MapViewPlugin.kt +++ b/android/src/main/kotlin/com/apptreesoftware/mapview/MapViewPlugin.kt @@ -11,6 +11,7 @@ import com.google.android.gms.maps.model.CameraPosition import com.google.android.gms.maps.model.IndoorBuilding import com.google.android.gms.maps.model.IndoorLevel import com.google.android.gms.maps.model.LatLng +import com.google.maps.android.PolyUtil import io.flutter.plugin.common.MethodCall import io.flutter.plugin.common.MethodChannel import io.flutter.plugin.common.MethodChannel.MethodCallHandler @@ -163,6 +164,20 @@ class MapViewPlugin(val activity: Activity) : MethodCallHandler { return assetManager.openFd(key) } + fun encodePath(points: List): String { + var result = "" + if (points.isNotEmpty()) + result = PolyUtil.encode(points) + return result + } + + fun decodePath(encodedPath: String): List { + var result = listOf() + if (encodedPath.isNotEmpty()) + result = PolyUtil.decode(encodedPath) + return result + } + fun indoorBuildingActivated(indoorBuilding: IndoorBuilding?) { if (indoorBuilding == null) { this.channel.invokeMethod("indoorBuildingActivated", null) @@ -173,7 +188,7 @@ class MapViewPlugin(val activity: Activity) : MethodCallHandler { "levels" to mappingIndoorLevels(indoorBuilding.levels))) } } - + fun indoorLevelActivated(level: IndoorLevel?) { if (level == null) { this.channel.invokeMethod("indoorLevelActivated", null) @@ -195,7 +210,7 @@ class MapViewPlugin(val activity: Activity) : MethodCallHandler { ) } } - + override fun onMethodCall(call: MethodCall, result: Result): Unit { when { call.method == "setApiKey" -> result.success(false) @@ -224,6 +239,31 @@ class MapViewPlugin(val activity: Activity) : MethodCallHandler { result.success(true) return } + call.method == "addToolbarAction" -> { + val map = call.arguments as Map + val toolbarAction = ToolbarAction(map) + mapActivity?.addMenuItem(toolbarAction) + result.success(true) + } + call.method == "editToolbarAction" -> { + val map = call.arguments as Map + val toolbarAction = ToolbarAction(map) + mapActivity?.editMenuItem(toolbarAction) + result.success(true) + } + call.method == "removeToolbarAction" -> { + val map = call.arguments as Map + val id = map["identifier"] as Int + mapActivity?.removeMenuItem(id) + result.success(true) + } + call.method == "setToolbarActionVisibility" -> { + val map = call.arguments as Map + val id = map["identifier"] as Int + val visible = map["visible"] as Boolean + mapActivity?.setMenuItemVisibility(id, visible) + result.success(true) + } call.method == "dismiss" -> { mapActivity?.finish() result.success(true) @@ -312,6 +352,20 @@ class MapViewPlugin(val activity: Activity) : MethodCallHandler { call.method == "removePolygon" -> { handleRemovePolygon(call.arguments as Map) } + call.method == "encodePath" -> { + val encodedPath = handleEncodePath(call.arguments as Map) + result.success(encodedPath) + } + call.method == "decodePath" -> { + val decodedPath = handleDecodePath(call.arguments as Map) + val list = arrayListOf>() + decodedPath?.forEach { + list.add(mapOf( + "latitude" to it.latitude, + "longitude" to it.longitude)) + } + result.success(list) + } else -> result.notImplemented() } } @@ -411,5 +465,21 @@ class MapViewPlugin(val activity: Activity) : MethodCallHandler { mapActivity?.removePolygon(it) } } + + fun handleEncodePath(map: Map): String? { + val pointsList = map["points"] as List> + val points = arrayListOf() + pointsList.forEach { + val lat = it["latitude"] as Double + val lng = it["longitude"] as Double + points.add(LatLng(lat, lng)) + } + return encodePath(points) + } + + fun handleDecodePath(map: Map): List? { + val encodedPath = map["encodedPath"] as String + return decodePath(encodedPath) + } } diff --git a/android/src/main/kotlin/com/apptreesoftware/mapview/ToolbarAction.kt b/android/src/main/kotlin/com/apptreesoftware/mapview/ToolbarAction.kt index 4f16361..8fd5fc8 100644 --- a/android/src/main/kotlin/com/apptreesoftware/mapview/ToolbarAction.kt +++ b/android/src/main/kotlin/com/apptreesoftware/mapview/ToolbarAction.kt @@ -1,7 +1,22 @@ package com.apptreesoftware.mapview -data class ToolbarAction(val title : String, val identifier: Int) { +class ToolbarAction(val title: String, val identifier: Int, val showIfRoom: Boolean) { constructor(map: Map) - : this(title = map["title"] as String, - identifier = map["identifier"] as Int) + : this(title = map["title"] as String, + identifier = map["identifier"] as Int, + showIfRoom = map["showIfRoom"] as Boolean) + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is ToolbarAction) return false + + if (identifier != other.identifier) return false + + return true + } + + override fun hashCode(): Int { + return identifier + } + } \ No newline at end of file diff --git a/example/ios/Flutter/flutter_assets/LICENSE b/example/ios/Flutter/flutter_assets/LICENSE index a505c47..984d457 100644 --- a/example/ios/Flutter/flutter_assets/LICENSE +++ b/example/ios/Flutter/flutter_assets/LICENSE @@ -1,114 +1,3 @@ -analyzer -args -csslib -logging - -Copyright 2013, the Dart project authors. All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of Google Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - --------------------------------------------------------------------------------- -async -collection -convert -crypto -mime -package_config -package_resolver -plugin -shelf_static -source_map_stack_trace -stream_channel -typed_data -utf -vm_service_client - -Copyright 2015, the Dart project authors. All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of Google Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - --------------------------------------------------------------------------------- -boolean_selector -front_end -kernel -meta -shelf_packages_handler -web_socket_channel - -Copyright 2016, the Dart project authors. All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of Google Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - --------------------------------------------------------------------------------- boringssl Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) @@ -3117,27 +3006,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -------------------------------------------------------------------------------- -charcode -glob -http -http_multi_server -http_parser -json_rpc_2 -matcher -path -pool -pub_semver -shelf -shelf_web_socket -source_maps -source_span -stack_trace -string_scanner -test -watcher -yaml +collection +typed_data +utf -Copyright 2014, the Dart project authors. All rights reserved. +Copyright 2015, the Dart project authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -6448,33 +6321,6 @@ BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. --------------------------------------------------------------------------------- -html - -Copyright (c) 2006-2012 The Authors - -Contributors: -James Graham - jg307@cam.ac.uk -Anne van Kesteren - annevankesteren@gmail.com -Lachlan Hunt - lachlan.hunt@lachy.id.au -Matt McDonald - kanashii@kanashii.ca -Sam Ruby - rubys@intertwingly.net -Ian Hickson (Google) - ian@hixie.ch -Thomas Broyer - t.broyer@ltgt.net -Jacques Distler - distler@golem.ph.utexas.edu -Henri Sivonen - hsivonen@iki.fi -Adam Barth - abarth@webkit.org -Eric Seidel - eric@webkit.org -The Mozilla Foundation (contributions from Henri Sivonen since 2008) -David Flanagan (Mozilla) - dflanagan@mozilla.com -Google Inc. (contributed the Dart port) - misc@dartlang.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -------------------------------------------------------------------------------- icu @@ -7158,66 +7004,6 @@ Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in these Data Files or Software without prior written authorization of the copyright holder. --------------------------------------------------------------------------------- -io -multi_server_socket -term_glyph - -Copyright 2017, the Dart project authors. All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of Google Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - --------------------------------------------------------------------------------- -js - -Copyright 2012, the Dart project authors. All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of Google Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -------------------------------------------------------------------------------- libjpeg-turbo @@ -8643,36 +8429,45 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- -node_preamble - -The MIT License (MIT) - -Copyright (c) 2015 Michael Bullington +matcher +path +stack_trace -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Copyright 2014, the Dart project authors. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -=== +-------------------------------------------------------------------------------- +meta -Copyright 2012, the Dart project authors. All rights reserved. +Copyright 2016, the Dart project authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above @@ -8682,6 +8477,7 @@ met: * Neither the name of Google Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR diff --git a/example/ios/Flutter/flutter_assets/isolate_snapshot_data b/example/ios/Flutter/flutter_assets/isolate_snapshot_data index 6d6eeb1..6c7e13c 100644 Binary files a/example/ios/Flutter/flutter_assets/isolate_snapshot_data and b/example/ios/Flutter/flutter_assets/isolate_snapshot_data differ diff --git a/example/ios/Flutter/flutter_assets/kernel_blob.bin b/example/ios/Flutter/flutter_assets/kernel_blob.bin index 32a8d0c..666dcd9 100644 Binary files a/example/ios/Flutter/flutter_assets/kernel_blob.bin and b/example/ios/Flutter/flutter_assets/kernel_blob.bin differ diff --git a/example/ios/Flutter/flutter_assets/platform.dill b/example/ios/Flutter/flutter_assets/platform.dill index e0a1f14..cc3c99f 100644 Binary files a/example/ios/Flutter/flutter_assets/platform.dill and b/example/ios/Flutter/flutter_assets/platform.dill differ diff --git a/example/ios/Flutter/flutter_assets/vm_snapshot_data b/example/ios/Flutter/flutter_assets/vm_snapshot_data index 0a8fb30..cf5970c 100644 Binary files a/example/ios/Flutter/flutter_assets/vm_snapshot_data and b/example/ios/Flutter/flutter_assets/vm_snapshot_data differ diff --git a/example/lib/main.dart b/example/lib/main.dart index 1e9a724..b91ca57 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -62,65 +62,66 @@ class _MyAppState extends State { //Drawing List _polygons = [ new Polygon( - "111", - [ - new Location(45.5231233, -122.6733130), - new Location(45.5231195, -122.6706147), - new Location(45.5231120, -122.6677823), - new Location(45.5230894, -122.6670957), - new Location(45.5230518, -122.6660979), - new Location(45.5230518, -122.6655185), - new Location(45.5232849, -122.6652074), - new Location(45.5230443, -122.6649070), - new Location(45.5230443, -122.6644135), - new Location(45.5230518, -122.6639414), - new Location(45.5231195, -122.6638663), - new Location(45.5231947, -122.6638770), - new Location(45.5233074, -122.6639950), - new Location(45.5232698, -122.6643813), - new Location(45.5235480, -122.6644349), - new Location(45.5244349, -122.6645529), - new Location(45.5245928, -122.6639628), - new Location(45.5248108, -122.6632762), - new Location(45.5249385, -122.6626861), - new Location(45.5249310, -122.6622677), - new Location(45.5250212, -122.6621926), - new Location(45.5251490, -122.6621711), - new Location(45.5251791, -122.6623106), - new Location(45.5252242, -122.6625681), - new Location(45.5251791, -122.6632118), - new Location(45.5249010, -122.6640165), - new Location(45.5247431, -122.6646388), - new Location(45.5249611, -122.6646602), - new Location(45.5253820, -122.6642525), - new Location(45.5260811, -122.6642525), - new Location(45.5260435, -122.6637161), - new Location(45.5261713, -122.6635551), - new Location(45.5263066, -122.6634800), - new Location(45.5265471, -122.6635873), - new Location(45.5269003, -122.6639628), - new Location(45.5270356, -122.6642632), - new Location(45.5271484, -122.6646602), - new Location(45.5274866, -122.6649177), - new Location(45.5271258, -122.6651645), - new Location(45.5269605, -122.6653790), - new Location(45.5267049, -122.6654434), - new Location(45.5262990, -122.6657224), - new Location(45.5261337, -122.6666021), - new Location(45.5256677, -122.6678467), - new Location(45.5245777, -122.6687801), - new Location(45.5236908, -122.6690161), - new Location(45.5233751, -122.6692307), - new Location(45.5233826, -122.6714945), - new Location(45.5233337, -122.6729804), - new Location(45.5233225, -122.6732969), - new Location(45.5232398, -122.6733506), - new Location(45.5231233, -122.6733130), - ], - jointType: FigureJointType.bevel, - strokeWidth: 5.0, - strokeColor: Colors.red, - fillColor: Color.fromARGB(75, 255, 0, 0)), + "111", + [ + new Location(45.5231233, -122.6733130), + new Location(45.5231195, -122.6706147), + new Location(45.5231120, -122.6677823), + new Location(45.5230894, -122.6670957), + new Location(45.5230518, -122.6660979), + new Location(45.5230518, -122.6655185), + new Location(45.5232849, -122.6652074), + new Location(45.5230443, -122.6649070), + new Location(45.5230443, -122.6644135), + new Location(45.5230518, -122.6639414), + new Location(45.5231195, -122.6638663), + new Location(45.5231947, -122.6638770), + new Location(45.5233074, -122.6639950), + new Location(45.5232698, -122.6643813), + new Location(45.5235480, -122.6644349), + new Location(45.5244349, -122.6645529), + new Location(45.5245928, -122.6639628), + new Location(45.5248108, -122.6632762), + new Location(45.5249385, -122.6626861), + new Location(45.5249310, -122.6622677), + new Location(45.5250212, -122.6621926), + new Location(45.5251490, -122.6621711), + new Location(45.5251791, -122.6623106), + new Location(45.5252242, -122.6625681), + new Location(45.5251791, -122.6632118), + new Location(45.5249010, -122.6640165), + new Location(45.5247431, -122.6646388), + new Location(45.5249611, -122.6646602), + new Location(45.5253820, -122.6642525), + new Location(45.5260811, -122.6642525), + new Location(45.5260435, -122.6637161), + new Location(45.5261713, -122.6635551), + new Location(45.5263066, -122.6634800), + new Location(45.5265471, -122.6635873), + new Location(45.5269003, -122.6639628), + new Location(45.5270356, -122.6642632), + new Location(45.5271484, -122.6646602), + new Location(45.5274866, -122.6649177), + new Location(45.5271258, -122.6651645), + new Location(45.5269605, -122.6653790), + new Location(45.5267049, -122.6654434), + new Location(45.5262990, -122.6657224), + new Location(45.5261337, -122.6666021), + new Location(45.5256677, -122.6678467), + new Location(45.5245777, -122.6687801), + new Location(45.5236908, -122.6690161), + new Location(45.5233751, -122.6692307), + new Location(45.5233826, -122.6714945), + new Location(45.5233337, -122.6729804), + new Location(45.5233225, -122.6732969), + new Location(45.5232398, -122.6733506), + new Location(45.5231233, -122.6733130), + ], + jointType: FigureJointType.bevel, + strokeWidth: 5.0, + strokeColor: Colors.red, + fillColor: Color.fromARGB(75, 255, 0, 0), + ), ]; @override @@ -197,8 +198,10 @@ class _MyAppState extends State { new Location(45.526607443935724, -122.66731660813093), 15.0), hideToolbar: false, title: "Recently Visited"), - toolbarActions: [new ToolbarAction("Close", 1)]); - StreamSubscription sub = mapView.onMapReady.listen((_) { + toolbarActions: [ + new ToolbarAction("Close", 1), + ]); + StreamSubscription sub = mapView.onMapReady.listen((_) async { mapView.setMarkers(_markers); mapView.setPolylines(_lines); mapView.setPolygons(_polygons); diff --git a/example/pubspec.yaml b/example/pubspec.yaml index f39250b..2d6039b 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -8,10 +8,10 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. #cupertino_icons: ^0.1.0 - -dev_dependencies: - flutter_test: - sdk: flutter +# +#dev_dependencies: +# flutter_test: +# sdk: flutter map_view: path: ../ diff --git a/ios/Classes/MapViewController.h b/ios/Classes/MapViewController.h index 830beba..63ec34a 100644 --- a/ios/Classes/MapViewController.h +++ b/ios/Classes/MapViewController.h @@ -4,7 +4,7 @@ // // Created by Matthew Smith on 10/30/17. // - +#import "ToolbarAction.h" #import #import #import @@ -24,6 +24,12 @@ - (void)shutdown; - (void)setCamera:(CLLocationCoordinate2D)location zoom:(float)zoom bearing:(CLLocationDirection)bearing tilt:(double)tilt; +- (void)addToolbarAction:(ToolbarAction *)toolbarAction; +- (void)editToolbarAction:(ToolbarAction *)toolbarAction; +- (void)removeToolbarAction:(int)identifier; +- (void)setToolbarActionVisibility:(int)identifier + visible:(BOOL)visible; + - (void)updateAnnotations:(NSArray *)annotations; - (void)clearAnnotations; - (void)addAnnotation:(MapAnnotation *)annotation; diff --git a/ios/Classes/MapViewController.m b/ios/Classes/MapViewController.m index d9c1dd2..e1cbe0e 100644 --- a/ios/Classes/MapViewController.m +++ b/ios/Classes/MapViewController.m @@ -9,6 +9,7 @@ #import "MapAnnotation.h" #import "MapPolyline.h" #import "MapPolygon.h" +#import "ToolbarAction.h" #import "Hole.h" #import "MapViewPlugin.h" #import @@ -24,7 +25,7 @@ @interface MapViewController () @property (nonatomic) BOOL _compassButton; @property (nonatomic) BOOL observingLocation; @property (nonatomic, assign) MapViewPlugin *plugin; -@property (nonatomic, retain) NSArray *navigationItems; +@property (nonatomic, retain) NSMutableArray *navigationItems; @property (nonatomic, retain) GMSCameraPosition *initialCameraPosition; @property (nonatomic, retain) NSMutableDictionary *markerIDLookup; @property (nonatomic, retain) NSMutableDictionary *polylineIDLookup; @@ -35,7 +36,7 @@ @interface MapViewController () @implementation MapViewController - (id)initWithPlugin:(MapViewPlugin *)plugin - navigationItems:(NSArray *)items cameraPosition:(GMSCameraPosition *)cameraPosition { + navigationItems:(NSMutableArray *)items cameraPosition:(GMSCameraPosition *)cameraPosition { self = [super init]; if (self) { self.plugin = plugin; @@ -59,7 +60,7 @@ - (void)dealloc { } - (void)viewDidLoad { - self.navigationItem.rightBarButtonItems = self.navigationItems; + [self updateNavitationItems]; } - (void)setMapOptions:(BOOL)myLocationEnabled @@ -99,6 +100,70 @@ - (void)setCamera:(CLLocationCoordinate2D)location zoom:(float)zoom bearing:(CLL [self.mapView animateToCameraPosition:[GMSCameraPosition cameraWithTarget:location zoom:zoom bearing:bearing viewingAngle:tilt]]; } +- (void)updateNavitationItems{ + NSMutableArray* array=[NSMutableArray new]; + for(ToolbarAction* action in self.navigationItems){ + UIBarButtonItem *button= [self.plugin createBarButtonItem:action.title identifier:action.identifier]; + [array addObject:button]; + } + self.navigationItem.rightBarButtonItems = array; +} + +- (void)addToolbarAction:(ToolbarAction *)toolbarAction{ + BOOL exists = NO; + for (ToolbarAction *action in self.navigationItems) { + if(action.identifier==toolbarAction.identifier){ + exists=YES; + break; + } + } + if(!exists){ + [self.navigationItems addObject:toolbarAction]; + } + [self updateNavitationItems]; +} + +- (void)editToolbarAction:(ToolbarAction *)toolbarAction{ + for (ToolbarAction *action in self.navigationItems) { + if(action.identifier == toolbarAction.identifier){ + action.title = toolbarAction.title; + break; + } + } + [self updateNavitationItems]; +} + +- (void)removeToolbarAction:(int)identifier{ + for (ToolbarAction *action in self.navigationItems) { + if(action.identifier == identifier){ + [self.navigationItems removeObject:action]; + break; + } + } + [self updateNavitationItems]; +} + +- (void)setToolbarActionVisibility:(int)identifier visible:(bool)visible{ + for (UIBarButtonItem *button in self.navigationItem.rightBarButtonItems) { + if(button.tag==identifier){ + if(visible){ + for(ToolbarAction *refAction in self.navigationItems){ + if(refAction.identifier == identifier){ + button.title = refAction.title; + } + } + button.enabled = YES; + button.tintColor = nil; + }else{ + button.enabled = NO; + button.tintColor = UIColor.clearColor; + button.title = nil; + } + break; + } + } +} + - (void)updateAnnotations:(NSArray *)annotations { [self clearAnnotations]; for (MapAnnotation *annotation in annotations) { @@ -329,7 +394,6 @@ - (void)observeValueForKeyPath:(nullable NSString *)keyPath ofObject:(nullable i } } - - (void)stopMonitoringLocationChanges { if (!self.observingLocation) return; [self.mapView removeObserver:self forKeyPath:@"myLocation"]; diff --git a/ios/Classes/MapViewPlugin.h b/ios/Classes/MapViewPlugin.h index 607b98b..e628e2d 100644 --- a/ios/Classes/MapViewPlugin.h +++ b/ios/Classes/MapViewPlugin.h @@ -33,4 +33,6 @@ - (NSDictionary *)mappingIndoorLevel:(GMSIndoorLevel *)level; - (int)getMapViewType:(NSString *)mapViewTypeName; - (NSString *)getAssetPath:(NSString *)iconPath; +- (UIBarButtonItem *) createBarButtonItem:(NSString *)title + identifier:(int)identifier; @end diff --git a/ios/Classes/MapViewPlugin.m b/ios/Classes/MapViewPlugin.m index 0dae765..03ac43b 100644 --- a/ios/Classes/MapViewPlugin.m +++ b/ios/Classes/MapViewPlugin.m @@ -3,6 +3,7 @@ #import "MapAnnotation.h" #import "MapPolyline.h" #import "MapPolygon.h" +#import "ToolbarAction.h" #import @implementation MapViewPlugin @@ -96,7 +97,38 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result } else if ([@"setCamera" isEqualToString:call.method]) { [self handleSetCamera:call.arguments]; result(@YES); - } else if ([@"zoomToFit" isEqualToString:call.method]) { + } else if ([@"encodePath" isEqualToString:call.method]) { + NSString *encodedPath = [self handleEncodePath:call.arguments]; + result(encodedPath); + } else if ([@"decodePath" isEqualToString:call.method]) { + NSArray *decodedPath = [self handleDecodePath:call.arguments]; + NSMutableArray *pointsList = [NSMutableArray new]; + for(CLLocation *location in decodedPath){ + [pointsList addObject:@{@"latitude": @(location.coordinate.latitude), @"longitude": @(location.coordinate.longitude)}]; + } + result(pointsList); + } else if ([@"addToolbarAction" isEqualToString:call.method]) { + NSDictionary *map = call.arguments; + ToolbarAction* action = [ToolbarAction actionFromDictionary:map]; + [self.mapViewController addToolbarAction:action]; + result(@YES); + } else if ([@"editToolbarAction" isEqualToString:call.method]) { + NSDictionary *map = call.arguments; + ToolbarAction* action = [ToolbarAction actionFromDictionary:map]; + [self.mapViewController editToolbarAction:action]; + result(@YES); + } else if ([@"removeToolbarAction" isEqualToString:call.method]) { + NSDictionary *map = call.arguments; + int identifier = [map[@"identifier"] intValue]; + [self.mapViewController removeToolbarAction:identifier]; + result(@YES); + } else if ([@"setToolbarActionVisibility" isEqualToString:call.method]) { + NSDictionary *map = call.arguments; + int identifier = [map[@"identifier"] intValue]; + BOOL visible = [map[@"visible"] boolValue]; + [self.mapViewController setToolbarActionVisibility:identifier visible:visible]; + result(@YES); + } else if ([@"zoomToFit" isEqualToString:call.method]) { [self.mapViewController zoomToAnnotations:[((NSNumber *) call.arguments) intValue]]; result(@YES); } else if ([@"zoomToAnnotations" isEqualToString:call.method]) { @@ -124,17 +156,19 @@ - (NSArray *)buttonItemsFromActions:(NSArray *)actions { NSMutableArray *buttons = [NSMutableArray array]; if (actions) { for (NSDictionary *action in actions) { - UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithTitle:[action valueForKey:@"title"] - style:UIBarButtonItemStylePlain - target:self - action:@selector(handleToolbar:)]; - button.tag = [[action valueForKey:@"identifier"] intValue]; - [buttons addObject:button]; + [buttons addObject:[ToolbarAction actionFromDictionary:action]]; } } return buttons; } - +- (UIBarButtonItem *) createBarButtonItem:(NSString *)title identifier:(int)identifier{ + UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithTitle:title + style:UIBarButtonItemStylePlain + target:self + action:@selector(handleToolbar:)]; + button.tag = identifier; + return button; +} - (void)handleSetAnnotations:(NSArray *)annotations { NSMutableArray *array = [NSMutableArray array]; for (NSDictionary *aDict in annotations) { @@ -207,6 +241,32 @@ - (void)handleRemovePolygon:(NSDictionary *)dict { [self.mapViewController removePolygon:polygon]; } } + +- (NSString *)handleEncodePath:(NSDictionary *)dict { + GMSMutablePath *mutablePath = [GMSMutablePath new]; + NSArray *pointsMapList = dict[@"points"]; + for(NSDictionary *pointMap in pointsMapList){ + double latitude=[pointMap[@"latitude"] doubleValue]; + double longitude=[pointMap[@"longitude"] doubleValue]; + CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(latitude, longitude); + [mutablePath addCoordinate:coordinate]; + } + NSString *encodedPath = [mutablePath encodedPath]; + return encodedPath; +} + +- (NSArray *)handleDecodePath:(NSDictionary *)dict { + NSString *encodedPath = dict[@"encodedPath"]; + NSMutableArray *pointsList= [NSMutableArray new]; + GMSPath *gmsPath = [GMSPath pathFromEncodedPath:encodedPath]; + for(int i=0;i + +@interface ToolbarAction : NSObject +@property (nonatomic) int identifier; +@property (nonatomic, retain) NSString *title; + +- (instancetype)initWithDictionary:(NSDictionary *)dictionary; + ++ (instancetype)actionFromDictionary:(NSDictionary *)dictionary; +@end diff --git a/ios/Classes/ToolbarAction.m b/ios/Classes/ToolbarAction.m new file mode 100644 index 0000000..233a913 --- /dev/null +++ b/ios/Classes/ToolbarAction.m @@ -0,0 +1,24 @@ +// +// ToolbarAction.m +// map_view +// +// Created by CEISUFRO on 26-07-18. +// +#import "ToolbarAction.h" + +@implementation ToolbarAction { + +} +- (instancetype)initWithDictionary:(NSDictionary *)dictionary { + self = [super init]; + if (self) { + self.title = dictionary[@"title"]; + self.identifier = [dictionary[@"identifier"] intValue]; + } + return self; +} + ++ (instancetype)actionFromDictionary:(NSDictionary *)dictionary { + return [[ToolbarAction alloc] initWithDictionary:dictionary]; +} +@end diff --git a/lib/map_view.dart b/lib/map_view.dart index 0798922..3834b5c 100644 --- a/lib/map_view.dart +++ b/lib/map_view.dart @@ -179,6 +179,43 @@ class MapView { _channel.invokeMethod('removePolygon', polygon.toMap()); } + Future encodePath(List points) async { + return await _channel + .invokeMethod("encodePath", {"points": Location.listToMap(points)}); + } + + Future> decodePath(String encodedPath) async { + List result = []; + List locationsList = + await _channel.invokeMethod("decodePath", {"encodedPath": encodedPath}); + locationsList.forEach((locationMap) { + result + .add(new Location(locationMap["latitude"], locationMap["longitude"])); + }); + return result; + } + + void addToolbarAction(ToolbarAction toolbarAction) { + _channel.invokeMethod("addToolbarAction", toolbarAction.toMap); + } + + void editToolbarAction(ToolbarAction toolbarAction) { + _channel.invokeMethod("editToolbarAction", toolbarAction.toMap); + } + + void removeToolbarAction(int identifier) { + _channel.invokeMethod("removeToolbarAction", { + "identifier": identifier, + }); + } + + void setToolbarActionVisibility(int identifier, bool visible) { + _channel.invokeMethod("setToolbarActionVisibility", { + "identifier": identifier, + "visible": visible, + }); + } + void zoomToFit({int padding: 50}) { _channel.invokeMethod('zoomToFit', padding); } diff --git a/lib/polygon.dart b/lib/polygon.dart index d99f54f..b7bc1a9 100644 --- a/lib/polygon.dart +++ b/lib/polygon.dart @@ -10,6 +10,7 @@ class Polygon { final double strokeWidth; final Color fillColor; final Color strokeColor; + ///Only supported in Android. iOS don't have this for some reason. ///https://developers.google.com/android/reference/com/google/android/gms/maps/model/JointType final FigureJointType jointType; @@ -61,7 +62,7 @@ class Polygon { } class Hole { - List points = []; + List points; Hole(this.points); diff --git a/lib/polyline.dart b/lib/polyline.dart index ac16bbc..2da84dc 100644 --- a/lib/polyline.dart +++ b/lib/polyline.dart @@ -6,6 +6,7 @@ import 'package:map_view/location.dart'; class Polyline { final String id; List points; + ///Only supported in Android. iOS don't have this for some reason. ///https://developers.google.com/android/reference/com/google/android/gms/maps/model/JointType final FigureJointType jointType; diff --git a/lib/toolbar_action.dart b/lib/toolbar_action.dart index f8f4f3a..8a15049 100644 --- a/lib/toolbar_action.dart +++ b/lib/toolbar_action.dart @@ -5,9 +5,10 @@ class ToolbarAction { /// Show the button in the toolbar only if there is room. /// DEFAULTS to false /// Only works on Android - bool showIfRoom = false; + bool showIfRoom; - ToolbarAction(this.title, this.identifier); + ToolbarAction(this.title, this.identifier, {this.showIfRoom = false}); - Map get toMap => {"title": title, "identifier": identifier}; + Map get toMap => + {"title": title, "identifier": identifier, "showIfRoom": showIfRoom}; } diff --git a/pubspec.yaml b/pubspec.yaml index 8cbc39b..4563ee3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ author: AppTree Software homepage: https://github.com/apptreesoftware/flutter_google_map_view dependencies: - uri: "^0.11.1" + uri: ^0.11.3 flutter: sdk: flutter