Skip to content

Commit

Permalink
upgrade-ios-version (#277)
Browse files Browse the repository at this point in the history
Co-authored-by: Stefan Schaller <stefan.schaller@tapped.dev>
Co-authored-by: Julian Bissekkou <julian.bissekkou@tapped.dev>
  • Loading branch information
3 people authored Aug 15, 2023
1 parent c6055fd commit 0d43206
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 73 deletions.
12 changes: 6 additions & 6 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ PODS:
- Flutter (1.0.0)
- location (0.0.1):
- Flutter
- MapLibre (5.12.2)
- MapLibre (5.14.0-pre3)
- maplibre_gl (0.0.1):
- Flutter
- MapLibre (~> 5.12.2)
- MapLibre (= 5.14.0-pre3)
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
Expand All @@ -21,7 +21,7 @@ DEPENDENCIES:
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)

SPEC REPOS:
https://github.com/m0nac0/flutter-maplibre-podspecs.git:
trunk:
- MapLibre

EXTERNAL SOURCES:
Expand All @@ -40,10 +40,10 @@ SPEC CHECKSUMS:
device_info_plus: 7545d84d8d1b896cb16a4ff98c19f07ec4b298ea
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
location: 3a2eed4dd2fab25e7b7baf2a9efefe82b512d740
MapLibre: 5aa820115d91293a4d09e681e7470f88bd34b672
maplibre_gl: f48aee1349b694fc372a509ec7bae88d9f9527c4
MapLibre: 620fc933c1d6029b33738c905c1490d024e5d4ef
maplibre_gl: 249958f57ed5cca73baf413ad6cbdbc64be69658
path_provider_foundation: c68054786f1b4f3343858c1e1d0caaded73f0be9

PODFILE CHECKSUM: 583ff63e051d4a697972e0fb94f90560347dabb0
PODFILE CHECKSUM: 00bbce151cce7e3542226c3dbb2422a2cb667d7a

COCOAPODS: 1.12.1
5 changes: 3 additions & 2 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/MapLibreAnnotationExtension-framework/MapLibreAnnotationExtension.framework",
"${BUILT_PRODUCTS_DIR}/device_info_plus/device_info_plus.framework",
"${BUILT_PRODUCTS_DIR}/location/location.framework",
"${BUILT_PRODUCTS_DIR}/maplibre_gl/maplibre_gl.framework",
Expand All @@ -258,7 +257,6 @@
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapLibreAnnotationExtension.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/device_info_plus.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/location.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/maplibre_gl.framework",
Expand Down Expand Up @@ -382,6 +380,7 @@
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -513,6 +512,7 @@
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -540,6 +540,7 @@
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
20 changes: 10 additions & 10 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
Expand All @@ -22,6 +24,14 @@
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>MGLMapboxMetricsEnabledSettingShownInApp</key>
<true/>
<key>NSLocationAlwaysUsageDescription</key>
<string>Shows your location on the map and helps improve the map</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Shows your location on the map and helps improve the map</string>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
Expand All @@ -43,15 +53,5 @@
<false/>
<key>io.flutter.embedded_views_preview</key>
<true/>
<key>MGLMapboxMetricsEnabledSettingShownInApp</key>
<true/>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Shows your location on the map and helps improve the map</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Shows your location on the map and helps improve the map</string>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>
9 changes: 9 additions & 0 deletions example/lib/animate_camera.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ class AnimateCameraState extends State<AnimateCamera> {
},
child: const Text('zoomBy with focus'),
),
TextButton(
onPressed: () {
mapController.animateCamera(
CameraUpdate.newLatLngZoom(const LatLng(48, 11), 5),
duration: const Duration(milliseconds: 300),
);
},
child: const Text('latlngZoom'),
),
TextButton(
onPressed: () {
mapController.animateCamera(
Expand Down
36 changes: 24 additions & 12 deletions ios/Classes/Convert.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,21 @@ class Convert {
delegate.setAttributionButtonPosition(position: position)
}
}

class func parseLatLngBoundsPadding(_ cameraUpdate: [Any]) -> UIEdgeInsets? {
guard let methodName = cameraUpdate[0] as? String else { return nil }

if(methodName != "newLatLngBounds") {
return nil
}

guard let paddingLeft = cameraUpdate[2] as? CGFloat else { return nil }
guard let paddingTop = cameraUpdate[3] as? CGFloat else { return nil }
guard let paddingRight = cameraUpdate[4] as? CGFloat else { return nil }
guard let paddingBottom = cameraUpdate[5] as? CGFloat else { return nil }

return UIEdgeInsets(top: paddingTop, left: paddingLeft, bottom: paddingBottom, right: paddingRight)
}

class func parseCameraUpdate(cameraUpdate: [Any], mapView: MGLMapView) -> MGLMapCamera? {
guard let type = cameraUpdate[0] as? String else { return nil }
Expand All @@ -84,19 +99,16 @@ class Convert {
return camera
case "newLatLngBounds":
guard let bounds = cameraUpdate[1] as? [[Double]] else { return nil }
guard let paddingLeft = cameraUpdate[2] as? CGFloat else { return nil }
guard let paddingTop = cameraUpdate[3] as? CGFloat else { return nil }
guard let paddingRight = cameraUpdate[4] as? CGFloat else { return nil }
guard let paddingBottom = cameraUpdate[5] as? CGFloat else { return nil }
return mapView.cameraThatFitsCoordinateBounds(
MGLCoordinateBounds.fromArray(bounds),
edgePadding: UIEdgeInsets(
top: paddingTop,
left: paddingLeft,
bottom: paddingBottom,
right: paddingRight

if let padding = parseLatLngBoundsPadding(cameraUpdate) {
return mapView.cameraThatFitsCoordinateBounds(
MGLCoordinateBounds.fromArray(bounds),
edgePadding: padding
)
)
}

return mapView.cameraThatFitsCoordinateBounds(MGLCoordinateBounds.fromArray(bounds))

case "newLatLngZoom":
guard let coordinate = cameraUpdate[1] as? [Double] else { return nil }
guard let zoom = cameraUpdate[2] as? Double else { return nil }
Expand Down
60 changes: 19 additions & 41 deletions ios/Classes/MapboxMapController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma
direction: camera.heading,
animated: false
)
if let bounds = cameraTargetBounds {
mapView.setLatLngBounds(bounds)
}
initialTilt = camera.pitch
}
// if let onAttributionClickOverride = args["onAttributionClickOverride"] as? Bool {
Expand Down Expand Up @@ -304,29 +307,31 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma
case "camera#move":
guard let arguments = methodCall.arguments as? [String: Any] else { return }
guard let cameraUpdate = arguments["cameraUpdate"] as? [Any] else { return }
if let camera = Convert
.parseCameraUpdate(cameraUpdate: cameraUpdate, mapView: mapView)
{

if let camera = Convert.parseCameraUpdate(cameraUpdate: cameraUpdate, mapView: mapView) {
mapView.setCamera(camera, animated: false)
}
result(nil)
case "camera#animate":
guard let arguments = methodCall.arguments as? [String: Any] else { return }
guard let cameraUpdate = arguments["cameraUpdate"] as? [Any] else { return }
if let camera = Convert
.parseCameraUpdate(cameraUpdate: cameraUpdate, mapView: mapView)
{
if let duration = arguments["duration"] as? TimeInterval {
mapView.setCamera(camera, withDuration: TimeInterval(duration / 1000),
animationTimingFunction: CAMediaTimingFunction(name: CAMediaTimingFunctionName
.easeInEaseOut))
result(nil)
guard let camera = Convert.parseCameraUpdate(cameraUpdate: cameraUpdate, mapView: mapView) else { return }


let completion = {
result(nil)
}

if let duration = arguments["duration"] as? TimeInterval {
if let padding = Convert.parseLatLngBoundsPadding(cameraUpdate) {
mapView.fly(to: camera, edgePadding: padding, withDuration: duration / 1000, completionHandler: completion)
} else {
mapView.setCamera(camera, animated: true)
mapView.fly(to: camera, withDuration: duration / 1000, completionHandler: completion)
}
} else {
mapView.setCamera(camera, animated: true)
completion()
}
result(nil)

case "symbolLayer#add":
guard let arguments = methodCall.arguments as? [String: Any] else { return }
guard let sourceId = arguments["sourceId"] as? String else { return }
Expand Down Expand Up @@ -627,7 +632,6 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma
if let maxzoom = maxzoom {
layer.maximumZoomLevel = Float(maxzoom)
}

mapView.style?.insertLayer(layer, below: belowLayer)
result(nil)

Expand Down Expand Up @@ -1035,32 +1039,6 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma
return loadIconImage(name: name)
}

func mapView(_ mapView: MGLMapView, shouldChangeFrom _: MGLMapCamera,
to newCamera: MGLMapCamera) -> Bool
{
guard let bbox = cameraTargetBounds else { return true }

// Get the current camera to restore it after.
let currentCamera = mapView.camera

// From the new camera obtain the center to test if it’s inside the boundaries.
let newCameraCenter = newCamera.centerCoordinate

// Set the map’s visible bounds to newCamera.
mapView.camera = newCamera
let newVisibleCoordinates = mapView.visibleCoordinateBounds

// Revert the camera.
mapView.camera = currentCamera

// Test if the newCameraCenter and newVisibleCoordinates are inside bbox.
let inside = MGLCoordinateInCoordinateBounds(newCameraCenter, bbox)
let intersects = MGLCoordinateInCoordinateBounds(newVisibleCoordinates.ne, bbox) &&
MGLCoordinateInCoordinateBounds(newVisibleCoordinates.sw, bbox)

return inside && intersects
}

func mapView(_: MGLMapView, didUpdate userLocation: MGLUserLocation?) {
if let channel = channel, let userLocation = userLocation,
let location = userLocation.location
Expand Down
4 changes: 2 additions & 2 deletions ios/maplibre_gl.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ A new Flutter plugin.
s.source_files = 'Classes/**/*'
s.public_header_files = 'Classes/**/*.h'
s.dependency 'Flutter'
s.dependency 'MapLibre', '~> 5.12.2'
s.dependency 'MapLibre', '5.14.0-pre3'
s.swift_version = '4.2'
s.ios.deployment_target = '9.0'
s.ios.deployment_target = '11.0'
end

0 comments on commit 0d43206

Please sign in to comment.