Skip to content

Commit 196efda

Browse files
committed
fix: Various bugs
- Fixed build failure - Added anchor param to Annotation - Added missing comparison of Overlay coordinates, which caused Circles, Annotations, Polylines and Ploygons to not update correctly on coordinate changes.
1 parent 1109092 commit 196efda

File tree

10 files changed

+73
-53
lines changed

10 files changed

+73
-53
lines changed

example/ios/Flutter/.last_build_id

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2c3d94e5130832c3a694663b4d51ce48
1+
591abfdc9d5f6fd539f4691920d32a90

example/ios/Flutter/flutter_export_environment.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export "OTHER_LDFLAGS=$(inherited) -framework Flutter"
99
export "FLUTTER_FRAMEWORK_DIR=/Users/luis/development/flutter/bin/cache/artifacts/engine/ios"
1010
export "FLUTTER_BUILD_NAME=1.0.0"
1111
export "FLUTTER_BUILD_NUMBER=1"
12-
export "DART_DEFINES=flutter.inspector.structuredErrors%3Dtrue"
1312
export "DART_OBFUSCATION=false"
1413
export "TRACK_WIDGET_CREATION=true"
1514
export "TREE_SHAKE_ICONS=false"

example/lib/annotation_icons.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class AnnotationIconsBody extends StatefulWidget {
2323
State<StatefulWidget> createState() => AnnotationIconsBodyState();
2424
}
2525

26-
const LatLng _kMapCenter = LatLng(52.4478, -3.5402);
26+
const LatLng _kMapCenter = LatLng(52.707755, -2.7540658);
2727

2828
class AnnotationIconsBodyState extends State<AnnotationIconsBody> {
2929
AppleMapController controller;
@@ -43,7 +43,7 @@ class AnnotationIconsBodyState extends State<AnnotationIconsBody> {
4343
child: AppleMap(
4444
initialCameraPosition: const CameraPosition(
4545
target: _kMapCenter,
46-
zoom: 7,
46+
zoom: 8,
4747
),
4848
annotations: _createAnnotation(),
4949
onMapCreated: _onMapCreated,
@@ -58,6 +58,7 @@ class AnnotationIconsBodyState extends State<AnnotationIconsBody> {
5858
return <Annotation>[
5959
Annotation(
6060
annotationId: AnnotationId("annotation_1"),
61+
anchor: Offset(0.5, -4),
6162
position: LatLng(52.707755, -2.7540658),
6263
icon: _annotationIcon,
6364
),

example/pubspec.lock

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ packages:
77
name: _fe_analyzer_shared
88
url: "https://pub.dartlang.org"
99
source: hosted
10-
version: "6.0.0"
10+
version: "11.0.0"
1111
analyzer:
1212
dependency: transitive
1313
description:
1414
name: analyzer
1515
url: "https://pub.dartlang.org"
1616
source: hosted
17-
version: "0.39.16"
17+
version: "0.40.4"
1818
apple_maps_flutter:
1919
dependency: "direct dev"
2020
description:
@@ -70,7 +70,7 @@ packages:
7070
name: cli_util
7171
url: "https://pub.dartlang.org"
7272
source: hosted
73-
version: "0.1.4"
73+
version: "0.2.0"
7474
clock:
7575
dependency: transitive
7676
description:
@@ -98,21 +98,14 @@ packages:
9898
name: coverage
9999
url: "https://pub.dartlang.org"
100100
source: hosted
101-
version: "0.13.9"
101+
version: "0.14.1"
102102
crypto:
103103
dependency: transitive
104104
description:
105105
name: crypto
106106
url: "https://pub.dartlang.org"
107107
source: hosted
108108
version: "2.1.5"
109-
csslib:
110-
dependency: transitive
111-
description:
112-
name: csslib
113-
url: "https://pub.dartlang.org"
114-
source: hosted
115-
version: "0.16.1"
116109
cupertino_icons:
117110
dependency: "direct main"
118111
description:
@@ -161,20 +154,13 @@ packages:
161154
url: "https://pub.dartlang.org"
162155
source: hosted
163156
version: "1.2.0"
164-
html:
165-
dependency: transitive
166-
description:
167-
name: html
168-
url: "https://pub.dartlang.org"
169-
source: hosted
170-
version: "0.14.0+3"
171157
http:
172158
dependency: transitive
173159
description:
174160
name: http
175161
url: "https://pub.dartlang.org"
176162
source: hosted
177-
version: "0.12.0+4"
163+
version: "0.12.2"
178164
http_multi_server:
179165
dependency: transitive
180166
description:
@@ -188,21 +174,21 @@ packages:
188174
name: http_parser
189175
url: "https://pub.dartlang.org"
190176
source: hosted
191-
version: "3.1.3"
177+
version: "3.1.4"
192178
io:
193179
dependency: transitive
194180
description:
195181
name: io
196182
url: "https://pub.dartlang.org"
197183
source: hosted
198-
version: "0.3.3"
184+
version: "0.3.4"
199185
js:
200186
dependency: transitive
201187
description:
202188
name: js
203189
url: "https://pub.dartlang.org"
204190
source: hosted
205-
version: "0.6.3-nullsafety.1"
191+
version: "0.6.3-nullsafety.2"
206192
json_rpc_2:
207193
dependency: transitive
208194
description:
@@ -237,28 +223,28 @@ packages:
237223
name: mime
238224
url: "https://pub.dartlang.org"
239225
source: hosted
240-
version: "0.9.6+3"
226+
version: "0.9.7"
241227
node_interop:
242228
dependency: transitive
243229
description:
244230
name: node_interop
245231
url: "https://pub.dartlang.org"
246232
source: hosted
247-
version: "1.0.3"
233+
version: "1.1.1"
248234
node_io:
249235
dependency: transitive
250236
description:
251237
name: node_io
252238
url: "https://pub.dartlang.org"
253239
source: hosted
254-
version: "1.0.1+2"
240+
version: "1.1.1"
255241
node_preamble:
256242
dependency: transitive
257243
description:
258244
name: node_preamble
259245
url: "https://pub.dartlang.org"
260246
source: hosted
261-
version: "1.4.8"
247+
version: "1.4.12"
262248
package_config:
263249
dependency: transitive
264250
description:
@@ -279,7 +265,7 @@ packages:
279265
name: pedantic
280266
url: "https://pub.dartlang.org"
281267
source: hosted
282-
version: "1.10.0-nullsafety.1"
268+
version: "1.10.0-nullsafety.2"
283269
platform:
284270
dependency: transitive
285271
description:
@@ -293,7 +279,7 @@ packages:
293279
name: pool
294280
url: "https://pub.dartlang.org"
295281
source: hosted
296-
version: "1.5.0-nullsafety.1"
282+
version: "1.5.0-nullsafety.2"
297283
process:
298284
dependency: transitive
299285
description:
@@ -314,7 +300,7 @@ packages:
314300
name: shelf
315301
url: "https://pub.dartlang.org"
316302
source: hosted
317-
version: "0.7.5"
303+
version: "0.7.9"
318304
shelf_packages_handler:
319305
dependency: transitive
320306
description:
@@ -347,14 +333,14 @@ packages:
347333
name: source_map_stack_trace
348334
url: "https://pub.dartlang.org"
349335
source: hosted
350-
version: "2.1.0-nullsafety.2"
336+
version: "2.1.0-nullsafety.3"
351337
source_maps:
352338
dependency: transitive
353339
description:
354340
name: source_maps
355341
url: "https://pub.dartlang.org"
356342
source: hosted
357-
version: "0.10.10-nullsafety.1"
343+
version: "0.10.10-nullsafety.2"
358344
source_span:
359345
dependency: transitive
360346
description:
@@ -438,7 +424,7 @@ packages:
438424
name: vm_service
439425
url: "https://pub.dartlang.org"
440426
source: hosted
441-
version: "4.0.0"
427+
version: "5.2.0"
442428
vm_service_client:
443429
dependency: transitive
444430
description:
@@ -452,7 +438,7 @@ packages:
452438
name: watcher
453439
url: "https://pub.dartlang.org"
454440
source: hosted
455-
version: "0.9.7+14"
441+
version: "0.9.7+15"
456442
web_socket_channel:
457443
dependency: transitive
458444
description:
@@ -473,14 +459,14 @@ packages:
473459
name: webkit_inspection_protocol
474460
url: "https://pub.dartlang.org"
475461
source: hosted
476-
version: "0.5.0+1"
462+
version: "0.7.3"
477463
yaml:
478464
dependency: transitive
479465
description:
480466
name: yaml
481467
url: "https://pub.dartlang.org"
482468
source: hosted
483-
version: "2.2.0"
469+
version: "2.2.1"
484470
sdks:
485471
dart: ">=2.10.0-110 <2.11.0"
486472
flutter: ">=1.10.0 <2.0.0"

ios/Classes/Annotations/AnnotationController.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ class AnnotationController: NSObject {
4747
if annotation.icon.iconType != .MARKER {
4848
initInfoWindow(annotation: annotation, annotationView: annotationView!)
4949
if annotation.icon.iconType != .PIN {
50-
annotationView!.centerOffset = CGPoint(x: 0, y: -annotationView!.frame.size.height / 2)
50+
let x = (0.5 - annotation.anchor.x) * Double(annotationView!.frame.size.width)
51+
let y = (0.5 - annotation.anchor.y) * Double(annotationView!.frame.size.height)
52+
annotationView!.centerOffset = CGPoint(x: x, y: y)
5153
}
5254
}
5355
annotationView!.canShowCallout = true
@@ -111,7 +113,6 @@ class AnnotationController: NSObject {
111113
}
112114

113115
private func initInfoWindow(annotation: FlutterAnnotation, annotationView: MKAnnotationView) {
114-
\(CGFloat(annotation.calloutOffset.y))")
115116
let x = self.getInfoWindowXOffset(annotationView: annotationView, annotation: annotation)
116117
let y = self.getInfoWindowYOffset(annotationView: annotationView, annotation: annotation)
117118
annotationView.calloutOffset = CGPoint(x: x, y: y)
@@ -190,14 +191,14 @@ class AnnotationController: NSObject {
190191
annotationView?.image = annotation.icon.image
191192
return annotationView!
192193
}
193-
194+
194195
private func getInfoWindowXOffset(annotationView: MKAnnotationView, annotation: FlutterAnnotation) -> CGFloat {
195196
if annotation.icon.iconType == .PIN {
196197
return annotationView.frame.origin.x - (annotationView.frame.origin.x * CGFloat(annotation.calloutOffset.x))
197198
}
198199
return annotationView.frame.origin.x + (annotationView.frame.width * CGFloat(annotation.calloutOffset.x))
199200
}
200-
201+
201202
private func getInfoWindowYOffset(annotationView: MKAnnotationView, annotation: FlutterAnnotation) -> CGFloat {
202203
return annotationView.frame.height * CGFloat(annotation.calloutOffset.y)
203204
}

ios/Classes/Annotations/FlutterAnnotation.swift

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ class FlutterAnnotation: NSObject, MKAnnotation {
1616
var infoWindowConsumesTapEvents: Bool = false
1717
var image: UIImage?
1818
var alpha: Double?
19+
var anchor: Offset = Offset()
1920
var isDraggable: Bool?
2021
var wasDragged: Bool = false
2122
var isVisible: Bool? = true
22-
var calloutOffset: CalloutOffset = CalloutOffset(x: 0, y: 0)
23+
var calloutOffset: Offset = Offset()
2324
var icon: AnnotationIcon = AnnotationIcon.init()
2425

2526
public init(fromDictionary annotationData: Dictionary<String, Any>, registrar: FlutterPluginRegistrar) {
@@ -37,12 +38,17 @@ class FlutterAnnotation: NSObject, MKAnnotation {
3738
if let alpha: Double = annotationData["alpha"] as? Double {
3839
self.alpha = alpha
3940
}
41+
42+
if let anchorJSON: Array<Double> = annotationData["anchor"] as? Array<Double> {
43+
self.anchor = Offset(from: anchorJSON)
44+
}
45+
4046
if let iconData: Array<Any> = annotationData["icon"] as? Array<Any> {
4147
self.icon = FlutterAnnotation.getAnnotationIcon(iconData: iconData, registrar: registrar, annotationId: id)
4248
}
4349

4450
if let calloutOffsetJSON = infoWindow["anchor"] as? Array<Double> {
45-
self.calloutOffset = CalloutOffset(x: calloutOffsetJSON[0], y: calloutOffsetJSON[1])
51+
self.calloutOffset = Offset(from: calloutOffsetJSON)
4652
}
4753
}
4854

@@ -51,7 +57,7 @@ class FlutterAnnotation: NSObject, MKAnnotation {
5157
var icon: AnnotationIcon
5258
let iconType: IconType = iconTypeMap[iconData[0] as! String] ?? .PIN
5359
var scaleParam: CGFloat?
54-
60+
5561
if iconType == .CUSTOM_FROM_ASSET {
5662
let assetPath: String = iconData[1] as! String
5763
scaleParam = CGFloat(iconData[2] as? Double ?? 1.0)
@@ -65,17 +71,33 @@ class FlutterAnnotation: NSObject, MKAnnotation {
6571
}
6672

6773
static func == (lhs: FlutterAnnotation, rhs: FlutterAnnotation) -> Bool {
68-
return lhs.id == rhs.id && lhs.title == rhs.title && lhs.subtitle == rhs.subtitle && lhs.image == rhs.image && lhs.alpha == rhs.alpha
69-
&& lhs.isDraggable == rhs.isDraggable && lhs.wasDragged == rhs.wasDragged && lhs.isVisible == rhs.isVisible && lhs.icon == rhs.icon
70-
&& lhs.coordinate.latitude == rhs.coordinate.latitude && lhs.coordinate.longitude == rhs.coordinate.longitude
74+
return lhs.id == rhs.id && lhs.title == rhs.title && lhs.subtitle == rhs.subtitle && lhs.image == rhs.image && lhs.alpha == rhs.alpha && lhs.isDraggable == rhs.isDraggable && lhs.wasDragged == rhs.wasDragged && lhs.isVisible == rhs.isVisible && lhs.icon == rhs.icon && lhs.coordinate.latitude == rhs.coordinate.latitude && lhs.coordinate.longitude == rhs.coordinate.longitude && lhs.infoWindowConsumesTapEvents == rhs.infoWindowConsumesTapEvents && lhs.anchor == rhs.anchor && lhs.calloutOffset == rhs.calloutOffset && lhs.coordinate.latitude == rhs.coordinate.latitude && lhs.coordinate.longitude == rhs.coordinate.longitude
7175
}
7276

7377
static func != (lhs: FlutterAnnotation, rhs: FlutterAnnotation) -> Bool {
7478
return !(lhs == rhs)
7579
}
7680
}
7781

78-
struct CalloutOffset {
82+
struct Offset {
7983
let x: Double
8084
let y: Double
85+
86+
public init(from json: Array<Double>) {
87+
self.x = json[0]
88+
self.y = json[1]
89+
}
90+
91+
public init() {
92+
self.x = 0
93+
self.y = 0
94+
}
95+
96+
static func == (lhs: Offset, rhs: Offset) -> Bool {
97+
return lhs.x == rhs.x && lhs.y == rhs.y
98+
}
99+
100+
static func != (lhs: Offset, rhs: Offset) -> Bool {
101+
return !(lhs == rhs)
102+
}
81103
}

ios/Classes/Polygons/FlutterPolygon.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class FlutterPolygon: MKPolygon {
3636
}
3737

3838
static func == (lhs: FlutterPolygon, rhs: FlutterPolygon) -> Bool {
39-
return lhs.strokeColor == rhs.strokeColor && lhs.fillColor == rhs.fillColor && lhs.isConsumingTapEvents == rhs.isConsumingTapEvents && lhs.width == rhs.width && lhs.isVisible == rhs.isVisible && lhs.zIndex == rhs.zIndex
39+
return lhs.strokeColor == rhs.strokeColor && lhs.fillColor == rhs.fillColor && lhs.isConsumingTapEvents == rhs.isConsumingTapEvents && lhs.width == rhs.width && lhs.isVisible == rhs.isVisible && lhs.zIndex == rhs.zIndex && lhs.coordinate.latitude == rhs.coordinate.latitude && lhs.coordinate.longitude == rhs.coordinate.longitude
4040
}
4141

4242
static func != (lhs: FlutterPolygon, rhs: FlutterPolygon) -> Bool {

ios/Classes/Polylines/FlutterPolyline.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class FlutterPolyline: MKPolyline {
4141

4242
static func == (lhs: FlutterPolyline, rhs: FlutterPolyline) -> Bool {
4343
return lhs.color == rhs.color && lhs.isConsumingTapEvents == rhs.isConsumingTapEvents && lhs.width == rhs.width
44-
&& lhs.isVisible == rhs.isVisible && lhs.capType == rhs.capType && lhs.pattern == rhs.pattern && lhs.lineJoin == rhs.lineJoin && rhs.zIndex == lhs.zIndex
44+
&& lhs.isVisible == rhs.isVisible && lhs.capType == rhs.capType && lhs.pattern == rhs.pattern && lhs.lineJoin == rhs.lineJoin && rhs.zIndex == lhs.zIndex && lhs.coordinate.latitude == rhs.coordinate.latitude && lhs.coordinate.longitude == rhs.coordinate.longitude
4545
}
4646

4747
static func != (lhs: FlutterPolyline, rhs: FlutterPolyline) -> Bool {

ios/Classes/circles/FlutterCircle.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class FlutterCircle: MKCircle {
3232
}
3333

3434
static func == (lhs: FlutterCircle, rhs: FlutterCircle) -> Bool {
35-
return lhs.strokeColor == rhs.strokeColor && lhs.fillColor == rhs.fillColor && lhs.isConsumingTapEvents == rhs.isConsumingTapEvents && lhs.strokeWidth == rhs.strokeWidth && lhs.isVisible == rhs.isVisible && lhs.zIndex == rhs.zIndex
35+
return lhs.strokeColor == rhs.strokeColor && lhs.fillColor == rhs.fillColor && lhs.isConsumingTapEvents == rhs.isConsumingTapEvents && lhs.strokeWidth == rhs.strokeWidth && lhs.isVisible == rhs.isVisible && lhs.zIndex == rhs.zIndex && lhs.coordinate.latitude == rhs.coordinate.latitude && lhs.coordinate.longitude == rhs.coordinate.longitude
3636
}
3737

3838
static func != (lhs: FlutterCircle, rhs: FlutterCircle) -> Bool {

0 commit comments

Comments
 (0)