Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[google_maps_flutter_web] Support for Holes in Polygons #3412

Merged
merged 13 commits into from
Jan 16, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,22 @@ void main() {
[43.354762, -5.850824],
],
},
{
'polygonId': 'polygon-2-with-holes',
'points': [
[43.355114, -5.851333],
[43.354797, -5.851860],
[43.354469, -5.851318],
[43.354762, -5.850824],
],
'holes': [
[
[41.354797, -6.851860],
[41.354469, -6.851318],
[41.354762, -6.850824],
]
]
},
],
'polylinesToAdd': [
{
Expand Down Expand Up @@ -202,6 +218,9 @@ void main() {
expect(capturedMarkers.first.infoWindow.snippet, 'snippet for test');
expect(capturedMarkers.first.infoWindow.title, 'title for test');
expect(capturedPolygons.first.polygonId.value, 'polygon-1');
expect(capturedPolygons.elementAt(1).polygonId.value,
'polygon-2-with-holes');
expect(capturedPolygons.elementAt(1).holes, isNot(null));
expect(capturedPolylines.first.polylineId.value, 'polyline-1');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import 'dart:async';

import 'package:integration_test/integration_test.dart';
import 'package:google_maps/google_maps.dart' as gmaps;
import 'package:google_maps/google_maps_geometry.dart' as geometry;
import 'package:google_maps_flutter_web/google_maps_flutter_web.dart';
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart'
as platform;
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';

Expand Down Expand Up @@ -87,6 +90,29 @@ void main() {
controller.update(options);
verify(polygon.options = options);
});

test('Polygon with hole has a hole', () {
final holedPolygon = platform.Polygon(
polygonId: platform.PolygonId('BermudaTriangle'),
points: [
platform.LatLng(25.774, -80.19),
platform.LatLng(18.466, -66.118),
platform.LatLng(32.321, -64.757),
],
holes: [
[
platform.LatLng(28.745, -70.579),
platform.LatLng(29.57, -67.514),
platform.LatLng(27.339, -66.668),
],
],
);
final controller = PolygonsController(stream: null)
..addPolygons({holedPolygon});
final gmapsPolygon = controller.polygons.values.first.polygon;
final pointInHole = gmaps.LatLng(28.632, -68.401);
expect(geometry.poly.containsLocation(pointInHole, gmapsPolygon), false);
});
});

group('PolylineController', () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<html>
<head>
<title>Browser Tests</title>
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=geometry"></script>
</head>
<body>
<script src="main.dart.js"></script>
Expand Down