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
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 0.6.2+2

* Updates README to note that heatmap support was removed from the underlying SDK in 3.65.
* Updates minimum supported SDK version to Flutter 3.38/Dart 3.10.

## 0.6.2+1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,14 @@ If you need marker clustering support, modify the <head> tag to load the [js-mar
</head>
```

## Heatmaps
## Heatmaps (Deprecated)

To use heatmaps, add `&libraries=visualization` to the end of the URL. See [the documentation](https://developers.google.com/maps/documentation/javascript/libraries) for more information.
Heatmap support [has been deprecated](https://developers.google.com/maps/deprecations#heatmap-layer-js-deprecation)
in the JavaScript Google Maps API, and was removed in version 3.65 of the SDK. To use
heatmaps, you must pin the SDK to 3.64. This means that you may be missing bug fixes or
newer features.

To use heatmaps, add `&libraries=visualization&v=3.64` to the end of the URL. See [the documentation](https://developers.google.com/maps/documentation/javascript/libraries) for more information.

## Limitations of the web version

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Platform Implementation Test App

This is a test app for manual testing and automated integration testing
of this platform implementation. It is not intended to demonstrate actual use of
this package, since the intent is that plugin clients use the app-facing
package.

Unless you are making changes to this implementation package, this example is
very unlikely to be relevant.

## Legacy SDK

This test app pins the Google Maps JavaScript SDK to version 3.64, which is
the last version that supported heatmaps. It is used to run integration tests
that use heatmaps, and to test that changes to the package do not break
existing heatmap functionality.

## Testing

This package uses `package:integration_test` to run its tests in a web browser.

See [Plugin Tests > Web Tests](https://github.com/flutter/flutter/blob/master/docs/ecosystem/testing/Plugin-Tests.md#web-tests)
in the Flutter documentation for instructions to set up and run the tests in this package.

Check [flutter.dev > Integration testing](https://docs.flutter.dev/testing/integration-tests)
for more info.
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
// Copyright 2013 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:js_interop';
import 'dart:ui';

import 'package:flutter_test/flutter_test.dart';
import 'package:google_maps/google_maps.dart' as gmaps;
import 'package:google_maps/google_maps_visualization.dart' as visualization;
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';
import 'package:google_maps_flutter_web/google_maps_flutter_web.dart';
// ignore: implementation_imports
import 'package:google_maps_flutter_web/src/utils.dart';
import 'package:integration_test/integration_test.dart';

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

late gmaps.Map map;

setUp(() {
map = gmaps.Map(createDivElement());
});

group('HeatmapsController', () {
late HeatmapsController controller;

const heatmapPoints = <WeightedLatLng>[
WeightedLatLng(LatLng(37.782, -122.447)),
WeightedLatLng(LatLng(37.782, -122.445)),
WeightedLatLng(LatLng(37.782, -122.443)),
WeightedLatLng(LatLng(37.782, -122.441)),
WeightedLatLng(LatLng(37.782, -122.439)),
WeightedLatLng(LatLng(37.782, -122.437)),
WeightedLatLng(LatLng(37.782, -122.435)),
WeightedLatLng(LatLng(37.785, -122.447)),
WeightedLatLng(LatLng(37.785, -122.445)),
WeightedLatLng(LatLng(37.785, -122.443)),
WeightedLatLng(LatLng(37.785, -122.441)),
WeightedLatLng(LatLng(37.785, -122.439)),
WeightedLatLng(LatLng(37.785, -122.437)),
WeightedLatLng(LatLng(37.785, -122.435)),
];

setUp(() {
controller = HeatmapsController();
controller.bindToMap(123, map);
});

testWidgets('addHeatmaps', (WidgetTester tester) async {
final heatmaps = <Heatmap>{
const Heatmap(
heatmapId: HeatmapId('1'),
data: heatmapPoints,
radius: HeatmapRadius.fromPixels(20),
),
const Heatmap(
heatmapId: HeatmapId('2'),
data: heatmapPoints,
radius: HeatmapRadius.fromPixels(20),
),
};

controller.addHeatmaps(heatmaps);

expect(controller.heatmaps.length, 2);
expect(controller.heatmaps, contains(const HeatmapId('1')));
expect(controller.heatmaps, contains(const HeatmapId('2')));
expect(controller.heatmaps, isNot(contains(const HeatmapId('66'))));
});

testWidgets('changeHeatmaps', (WidgetTester tester) async {
final heatmaps = <Heatmap>{
const Heatmap(
heatmapId: HeatmapId('1'),
data: <WeightedLatLng>[],
radius: HeatmapRadius.fromPixels(20),
),
};
controller.addHeatmaps(heatmaps);

expect(
controller.heatmaps[const HeatmapId('1')]!.heatmap!.data.array.toDart,
hasLength(0),
);

final updatedHeatmaps = <Heatmap>{
const Heatmap(
heatmapId: HeatmapId('1'),
data: <WeightedLatLng>[WeightedLatLng(LatLng(0, 0))],
radius: HeatmapRadius.fromPixels(20),
),
};
controller.changeHeatmaps(updatedHeatmaps);

expect(controller.heatmaps.length, 1);
expect(
controller.heatmaps[const HeatmapId('1')]!.heatmap!.data.array.toDart,
hasLength(1),
);
});

testWidgets('removeHeatmaps', (WidgetTester tester) async {
final heatmaps = <Heatmap>{
const Heatmap(
heatmapId: HeatmapId('1'),
data: heatmapPoints,
radius: HeatmapRadius.fromPixels(20),
),
const Heatmap(
heatmapId: HeatmapId('2'),
data: heatmapPoints,
radius: HeatmapRadius.fromPixels(20),
),
const Heatmap(
heatmapId: HeatmapId('3'),
data: heatmapPoints,
radius: HeatmapRadius.fromPixels(20),
),
};

controller.addHeatmaps(heatmaps);

expect(controller.heatmaps.length, 3);

final heatmapIdsToRemove = <HeatmapId>{
const HeatmapId('1'),
const HeatmapId('3'),
};

controller.removeHeatmaps(heatmapIdsToRemove);

expect(controller.heatmaps.length, 1);
expect(controller.heatmaps, isNot(contains(const HeatmapId('1'))));
expect(controller.heatmaps, contains(const HeatmapId('2')));
expect(controller.heatmaps, isNot(contains(const HeatmapId('3'))));
});

testWidgets('Converts colors to CSS', (WidgetTester tester) async {
final heatmaps = <Heatmap>{
const Heatmap(
heatmapId: HeatmapId('1'),
data: heatmapPoints,
gradient: HeatmapGradient(<HeatmapGradientColor>[
HeatmapGradientColor(Color(0xFFFABADA), 0),
]),
radius: HeatmapRadius.fromPixels(20),
),
};

controller.addHeatmaps(heatmaps);

final visualization.HeatmapLayer heatmap =
controller.heatmaps.values.first.heatmap!;

expect(
(heatmap.get('gradient')! as JSArray<JSString>).toDart.map(
(JSString? value) => value!.toDart,
),
<String>['rgba(250, 186, 218, 0.00)', 'rgba(250, 186, 218, 1.00)'],
);
});
});

group('headless tests (no map attachment)', () {
testWidgets('update', (WidgetTester tester) async {
final heatmap = visualization.HeatmapLayer();

final controller = HeatmapController(heatmap: heatmap);
final options = visualization.HeatmapLayerOptions()
..data = <gmaps.LatLng>[gmaps.LatLng(0, 0)].toJS;

expect(heatmap.data.array.toDart, hasLength(0));

controller.update(options);

expect(heatmap.data.array.toDart, hasLength(1));
});

testWidgets('remove drops gmaps instance', (WidgetTester tester) async {
final heatmap = visualization.HeatmapLayer();
final controller = HeatmapController(heatmap: heatmap);

controller.remove();

expect(controller.heatmap, isNull);
});

testWidgets('cannot call update after remove', (WidgetTester tester) async {
final heatmap = visualization.HeatmapLayer();
final controller = HeatmapController(heatmap: heatmap);

final options = visualization.HeatmapLayerOptions()..dissipating = true;

controller.remove();

expect(() {
controller.update(options);
}, throwsAssertionError);
});
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: google_maps_flutter_web_integration_tests
publish_to: none

environment:
sdk: ^3.10.0
flutter: ">=3.38.0"

dependencies:
flutter:
sdk: flutter
google_maps_flutter_platform_interface: ^2.14.0
google_maps_flutter_web:
path: ../..
web: ^1.0.0

dev_dependencies:
flutter_test:
sdk: flutter
google_maps: ^8.1.0
integration_test:
sdk: flutter
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE HTML>
<!-- Copyright 2013 The Flutter Authors
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<html>

<head>
<meta charset="UTF-8" />
<title>Browser Tests</title>
<!-- This API key comes from: go/flutter-maps-web-tests-api-key (GCP project: flutter-infra) -->
<script
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAa9cRBkhuxGq3Xw3HPz8SPwaVOhRmm7kk&libraries=marker,geometry,visualization&v=3.64"></script>
<script src="https://cdn.jsdelivr.net/npm/@googlemaps/markerclusterer@2.5.3/dist/index.umd.min.js"></script>
</head>

<body>
<script src="flutter_bootstrap.js" async></script>
</body>

</html>
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ package.
Unless you are making changes to this implementation package, this example is
very unlikely to be relevant.

## Testing
## Example Structure

This package uses `package:integration_test` to run its tests in a web browser.

See [Plugin Tests > Web Tests](https://github.com/flutter/flutter/blob/master/docs/ecosystem/testing/Plugin-Tests.md#web-tests)
in the Flutter documentation for instructions to set up and run the tests in this package.

Check [flutter.dev > Integration testing](https://docs.flutter.dev/testing/integration-tests)
for more info.
This directory contains two example apps:
- latest/ uses an unpinned SDK load, so it will use the latest SDK version.
This follows the standard recommendation in the package's README.
- 3-64 pins the SDK to 3.64. This is used for integration tests of the
heatmap support, since heatmaps were removed from the SDK in 3.65.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Platform Implementation Test App

This is a test app for manual testing and automated integration testing
of this platform implementation. It is not intended to demonstrate actual use of
this package, since the intent is that plugin clients use the app-facing
package.

Unless you are making changes to this implementation package, this example is
very unlikely to be relevant.

## Testing

This package uses `package:integration_test` to run its tests in a web browser.

See [Plugin Tests > Web Tests](https://github.com/flutter/flutter/blob/master/docs/ecosystem/testing/Plugin-Tests.md#web-tests)
in the Flutter documentation for instructions to set up and run the tests in this package.

Check [flutter.dev > Integration testing](https://docs.flutter.dev/testing/integration-tests)
for more info.
Loading
Loading