0

In my app, posts include a location. Currently, I am able to get coordinates (latitude and longitude), but for obvious reasons, I don't want to display users' coordinates publicly. My goal is to get the city, state, and country from those coordinates and then show a radius over that city on a map instead of a pin directly on the coordinates. Is this possible in Flutter and are there any examples of it?

Globe
  • 514
  • 3
  • 17

1 Answers1

0

After checking the source code of google_maps_flutter plugin, there is an example there of using the circles argument of GoogleMap Widget's constructor.

And on Circle's API documentation, you may create a Circle with an unique ID, then supply it to GoogleMap Widget's constructor

import 'package:google_maps_flutter/google_maps_flutter.dart';

// declare one Circle
Circle aCircle = Circle(
  circleId: CircleId('unique_id_for_your_circle'), // required, unique
  consumeTapEvents: false, // or true if you want it to intercept onTap events
  fillColor: Colors.blue.withOpacity(0.5,), // to give it a color
  center: const LatLng(0.0, 0.0), // where it is centered on your Map
  radius = 100.0, // it's size
  onTap: () {}, // if you want it to intercept if consumeTapEvents is true, or set to null if not used
);

// your Widget constructor
GoogleMap(
  // ...other required arguments
  circles: <Circle>{aCircle,}, // add your [Circle]s here, it's a Set, not a List
);
nsNeruno
  • 61
  • 2
  • 2