Skip to content

Commit

Permalink
Merge pull request #1 from MapsPeople/v2.1.1
Browse files Browse the repository at this point in the history
Updated to v2.1.1
  • Loading branch information
matiasholst authored Jan 24, 2024
2 parents 99f0b35 + ef343f1 commit cee3a3b
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 101 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.1.1

* Fixed issue where `OnMapReadyListener` would not be invoked during the initial load on iOS.

## 2.1.0

* Updated MapsIndoors SDK to 4.2.13
Expand Down
29 changes: 6 additions & 23 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,28 +1,11 @@
BSD 3-Clause License
Copyright 2023 Mapspeople

Copyright (c) 2024, MapsPeople A/S
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. 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.

2. 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.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

3. Neither the name of the copyright holder 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 HOLDER 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.
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 HOLDER 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.
44 changes: 19 additions & 25 deletions ios/Classes/MapsIndoorsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ class FLNativeViewFactory: NSObject, FlutterPlatformViewFactory {

class FLNativeView: NSObject, FlutterPlatformView, MPMapControlDelegate, FlutterMapView {

private var _GMSView: GMSMapView?
private let MP_APIKEY = "mapspeople"
private var mapsIndoorsData: MapsIndoorsData? = nil
private var _GMSView: GMSMapView
private var mapsIndoorsData: MapsIndoorsData
private var args: Any? = nil
private let googleApiKey = Bundle.main.object(forInfoDictionaryKey: "GoogleMapsAPIKey") as? String ?? ""

Expand All @@ -47,45 +46,40 @@ class FLNativeView: NSObject, FlutterPlatformView, MPMapControlDelegate, Flutter
binaryMessenger messenger: FlutterBinaryMessenger?,
mapsIndoorsData: MapsIndoorsData
) {
super.init()

self.args = args
self.mapsIndoorsData = mapsIndoorsData;
GMSServices.provideAPIKey(googleApiKey)
_GMSView = GMSMapView(frame: frame, camera: GMSCameraPosition())
super.init()

if (MPMapsIndoors.shared.ready) {
mapsIndoorsData.mapControlMethodChannel?.invokeMethod("create", arguments: args)
mapsIndoorsIsReady()
}else {
mapsIndoorsData.delegate.append(MIReadyDelegate(view: self))
}

mapsIndoorsData.mapView = self
// To fix an odd bug, where the map center would be in the top left corner of the view.
// It should be the center of the view.
_GMSView?.moveCamera(GMSCameraUpdate.setCamera(GMSCameraPosition()))
_GMSView.moveCamera(GMSCameraUpdate.setCamera(GMSCameraPosition()))
}

func view() -> UIView {
return _GMSView!
return _GMSView
}

func mapsIndoorsIsReady() {
if (mapsIndoorsData?.mapView != nil) {
DispatchQueue.main.async { [self] in
let config = MPMapConfig(gmsMapView: _GMSView!, googleApiKey: googleApiKey)
let mapControl = MPMapsIndoors.createMapControl(mapConfig: config)
if (mapControl != nil) {
//TODO: parse config
mapControl?.showUserPosition = true
//pretend config^
mapsIndoorsData!.mapControl = mapControl
mapsIndoorsData?.directionsRenderer = nil
Task {
//Momentary code just to get the map to a place where we show data on the map
mapControl?.goTo(entity: await MPMapsIndoors.shared.venues()[0])
}
}
guard mapsIndoorsData.mapView != nil else { return }

DispatchQueue.main.async { [self] in
let config = MPMapConfig(gmsMapView: _GMSView, googleApiKey: googleApiKey)
if let mapControl = MPMapsIndoors.createMapControl(mapConfig: config) {
//TODO: parse config
mapControl.showUserPosition = true
//pretend config^
mapsIndoorsData.mapControl = mapControl
mapsIndoorsData.directionsRenderer = nil
mapsIndoorsData.mapControlMethodChannel?.invokeMethod("create", arguments: nil)
}
}
}
Expand All @@ -94,14 +88,14 @@ class FLNativeView: NSObject, FlutterPlatformView, MPMapControlDelegate, Flutter
guard let update = makeGMSCameraUpdate(cameraUpdate: cameraUpdate) else {
throw MPError.unknownError
}
_GMSView?.animate(with: update)
_GMSView.animate(with: update)
}

func moveCamera(cameraUpdate: CameraUpdate) throws {
guard let update = makeGMSCameraUpdate(cameraUpdate: cameraUpdate) else {
throw MPError.unknownError
}
_GMSView?.moveCamera(update)
_GMSView.moveCamera(update)
}

func makeGMSCameraUpdate(cameraUpdate: CameraUpdate) -> GMSCameraUpdate? {
Expand Down
65 changes: 14 additions & 51 deletions ios/Classes/core/MapsIndoorsData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,81 +20,44 @@ protocol LiveDataDelegate: AnyObject {
}

public class MapsIndoorsData: NSObject {

private var _mapView: FlutterMapView? = nil
private var _mapControl: MPMapControl? = nil
private var _mapControlMethodChannel: FlutterMethodChannel? = nil
private var _mapControlFloorSelector: FlutterMethodChannel? = nil
private var _mapsIndoorsMethodChannel: FlutterMethodChannel? = nil
private var _directionsRendererMethodChannel: FlutterMethodChannel? = nil
private var _positionProvider: FlutterPositionProvider? = nil
private var _directionsRenderer: MPDirectionsRenderer? = nil
private var _floorSelector: CustomFloorSelector? = nil


var delegate: [MapsIndoorsReadyDelegate] = []

var liveDataDelegate: LiveDataDelegate?

var mapControlListenerDelegate: MapControlDelegate?

var mapView: FlutterMapView? {
set { _mapView = newValue }
get { return _mapView }
}
var mapView: FlutterMapView?

var mapControl: MPMapControl? {
set { _mapControl = newValue }
get { return _mapControl }
}
var mapControl: MPMapControl?

var isMapControlInitialized: Bool {
get { return _mapControl == nil }
get { mapControl != nil }
}

var isMapsIndoorsReady: Bool {
get { return MPMapsIndoors.shared.ready }
get { MPMapsIndoors.shared.ready }
}

func mapsIndoorsReady(error: MPError?) {
delegate.forEach { onReady in
onReady.isReady(error: error)
delegate.forEach {
$0.isReady(error: error)
}
}

var mapControlMethodChannel: FlutterMethodChannel? {
set { _mapControlMethodChannel = newValue }
get { return _mapControlMethodChannel }
}
var mapControlMethodChannel: FlutterMethodChannel?

var directionsRendererMethodChannel: FlutterMethodChannel? {
set { _directionsRendererMethodChannel = newValue }
get { return _directionsRendererMethodChannel }
}
var directionsRendererMethodChannel: FlutterMethodChannel?

var mapsIndoorsMethodChannel: FlutterMethodChannel? {
set { _mapsIndoorsMethodChannel = newValue }
get { return _mapsIndoorsMethodChannel }
}
var mapsIndoorsMethodChannel: FlutterMethodChannel?

var mapControlFloorSelector: FlutterMethodChannel? {
set { _mapControlFloorSelector = newValue }
get { return _mapControlFloorSelector }
}
var mapControlFloorSelector: FlutterMethodChannel?

var positionProvider: FlutterPositionProvider? {
set { _positionProvider = newValue }
get { return _positionProvider }
}
var positionProvider: FlutterPositionProvider?

var directionsRenderer: MPDirectionsRenderer? {
set { _directionsRenderer = newValue }
get { return _directionsRenderer }
}
var directionsRenderer: MPDirectionsRenderer?

var floorSelector: MPCustomFloorSelector? {
set { _floorSelector = newValue as? CustomFloorSelector }
get { return _floorSelector }
}
var floorSelector: MPCustomFloorSelector?
}

public class CustomFloorSelector: UIView, MPCustomFloorSelector {
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: mapsindoors_googlemaps_ios
description: iOS implementation of the mapsindoors plugin
version: 2.1.0
version: 2.1.1
repository: https://github.com/MapsPeople/mapsindoors_flutter_googlemaps_ios
homepage: https://www.mapsindoors.com/

Expand All @@ -18,7 +18,7 @@ flutter:
dependencies:
flutter:
sdk: flutter
mapsindoors_platform_interface: ^2.1.0
mapsindoors_platform_interface: ^2.1.1

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit cee3a3b

Please sign in to comment.