Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/google_maps_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 0.1.15

* Refactor the JavaScript interaction layer by introducing `GoogleMapsJsBridge`,
replacing direct `WebViewController` calls.
* Update `webview_flutter` to ^4.13.1 and `webview_flutter_lwe` to ^0.5.0.
* Verify integration tests pass against upstream google_maps_flutter v2.17.0.

## 0.1.14

* Update google_maps_flutter to 2.16.0.
Expand Down
2 changes: 1 addition & 1 deletion packages/google_maps_flutter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This package is not an _endorsed_ implementation of `google_maps_flutter`. There
```yaml
dependencies:
google_maps_flutter: ^2.16.0
google_maps_flutter_tizen: ^0.1.14
google_maps_flutter_tizen: ^0.1.15
```

For detailed usage, see https://pub.dev/packages/google_maps_flutter#sample-usage.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ library google_maps_flutter_tizen;

import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'dart:ui' as ui;

import 'package:flutter/foundation.dart';
Expand All @@ -19,6 +18,7 @@ import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platf
import 'package:stream_transform/stream_transform.dart';
import 'package:webview_flutter/webview_flutter.dart';

import 'src/google_maps_js_bridge.dart';
import 'src/util.dart' as util;

part 'src/circle.dart';
Expand Down
8 changes: 4 additions & 4 deletions packages/google_maps_flutter/lib/src/circle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ class CircleController {
required util.GCircle circle,
bool consumeTapEvents = false,
ui.VoidCallback? onTap,
WebViewController? controller,
required GoogleMapsJsBridge bridge,
}) : _circle = circle,
_consumeTapEvents = consumeTapEvents,
tapEvent = onTap {
_addCircleEvent(controller);
_addCircleEvent(bridge);
}

util.GCircle? _circle;
Expand All @@ -25,10 +25,10 @@ class CircleController {
/// Circle component's tap event.
ui.VoidCallback? tapEvent;

Future<void> _addCircleEvent(WebViewController? controller) async {
Future<void> _addCircleEvent(GoogleMapsJsBridge bridge) async {
final String command =
"$_circle.addListener('click', (event) => CircleClick.postMessage(JSON.stringify(${_circle?.id})));";
await controller!.runJavaScript(command);
await bridge.runJavaScript(command);
}
Comment on lines +28 to 32

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Use the newly introduced bridge.addListener abstraction instead of directly running raw JavaScript. This improves consistency and maintainability.

Suggested change
Future<void> _addCircleEvent(GoogleMapsJsBridge bridge) async {
final String command =
"$_circle.addListener('click', (event) => CircleClick.postMessage(JSON.stringify(${_circle?.id})));";
await controller!.runJavaScript(command);
await bridge.runJavaScript(command);
}
Future<void> _addCircleEvent(GoogleMapsJsBridge bridge) async {
await bridge.addListener(
JsRef(_circle.toString()),
'click',
'CircleClick',
'JSON.stringify(${_circle?.id})',
);
}


/// Returns `true` if this Controller will use its own `onTap` handler to consume events.
Expand Down
13 changes: 9 additions & 4 deletions packages/google_maps_flutter/lib/src/circles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ part of '../google_maps_flutter_tizen.dart';
/// This class manages all the [CircleController]s associated to a [GoogleMapController].
class CirclesController extends GeometryController {
/// Initialize the cache. The [StreamController] comes from the [GoogleMapController], and is shared with other controllers.
CirclesController({required StreamController<MapEvent<Object?>> stream})
: _streamController = stream,
CirclesController({
required StreamController<MapEvent<Object?>> stream,
required GoogleMapsJsBridge bridge,
}) : _streamController = stream,
_bridge = bridge,
_circleIdToController = <CircleId, CircleController>{},
_idToCircleId = <int, CircleId>{};

Expand All @@ -20,6 +23,8 @@ class CirclesController extends GeometryController {
// The stream over which circles broadcast their events
final StreamController<MapEvent<Object?>> _streamController;

final GoogleMapsJsBridge _bridge;

/// Adds a set of [Circle] objects to the cache.
///
/// Wraps each [Circle] into its corresponding [CircleController].
Expand All @@ -35,14 +40,14 @@ class CirclesController extends GeometryController {
final util.GCircleOptions populationOptions = _circleOptionsFromCircle(
circle,
);
final util.GCircle gCircle = util.GCircle(populationOptions);
final util.GCircle gCircle = util.GCircle(_bridge, populationOptions);
final CircleController controller = CircleController(
circle: gCircle,
consumeTapEvents: circle.consumeTapEvents,
onTap: () {
_onCircleTap(circle.circleId);
},
controller: util.webController,
bridge: _bridge,
);
_idToCircleId[gCircle.id] = circle.circleId;
_circleIdToController[circle.circleId] = controller;
Expand Down
Loading
Loading