Adding Circles to the map
Opened this issue · 1 comments
socrates-hlapolosa commented
Hi Guys, great package and wonderful work.
I have been struggling to add circles to the map using the google_provider package and discovered that;
I created a circle test inside: packages/google_atlas/test/widget_tests/google_atlas_widget_test.dart that looks like this;
testWidgets(
'should return correct GoogleMap when build is called with one circle',
(WidgetTester tester) async {
final GoogleMaps.Circle expectedCircle = GoogleMaps.Circle(
circleId: GoogleMaps.CircleId('circle-1'),
center: GoogleMaps.LatLng(41.8781, -87.6298),
radius: 10,
);
final Set<Circle> mockCircle = Set<Circle>.from([
Circle(
id: 'circle-1',
radiusInMeters: 10,
center: LatLng(
latitude: 41.8781,
longitude: -87.6298,
),
)
]);
await tester.pumpWidget(MaterialApp(
title: 'Atlas Test Sample with Google Provider',
home: AtlasTestSample(
initialCameraPosition: initialCameraPosition,
circles: mockCircle,
// markers: mockMarker,
),
));
await tester.pumpAndSettle();
final FakePlatformGoogleMap platformGoogleMap =
fakePlatformViewsController.lastCreatedView;
expect(platformGoogleMap.circlesToAdd.length, 1);
final GoogleMaps.Circle actualCircle =
platformGoogleMap.circlesToAdd.first;
expect(platformGoogleMap.circleIdsToRemove.isEmpty, true);
expect(actualCircle, equals(expectedCircle));
});
the only way i could get this test to pass was by altering packages/google_atlas/lib/src/google_atlas.dart as follows;
return FutureBuilder<Set<GoogleMaps.Circle>>(
future: _toGoogleCircles(circles),
initialData: Set<GoogleMaps.Circle>(),
builder: (context, snapshot) {
return GoogleMaps.GoogleMap(
myLocationEnabled: showMyLocation,
myLocationButtonEnabled: showMyLocationButton,
mapType: _toGoogleMapType(mapType),
trafficEnabled: showTraffic,
initialCameraPosition:
CameraUtils.toGoogleCameraPosition(initialCameraPosition),
markers: _toGoogleMarkers(markers),
circles: snapshot.hasError ? Set<GoogleMaps.Circle>() : snapshot.data,
polylines: _toGooglePolylines(lines),
onTap: _toGoogleOnTap(onTap),
onLongPress: _toGoogleOnLongPress(onLongPress),
onMapCreated: _onMapCreated,
onCameraMove: _onCameraMove,
);
},
);
but if i do that, then markers dont work.
How do i go about adding circles to map?
Regards,
Socrates
socrates-hlapolosa commented
BTW i see that support for circle was added in atlas v0.2.0;
- Added support for
Circle
on a Map
v0.2.0 (2019-10-16)
but i'm looking at atlas v1.0.0 ang google_atas v0.7.0 and doesnt seem as if those previous changes are there, what is the new prefered way of working with circles?