add headers & package name costumization
This commit is contained in:
@@ -55,13 +55,23 @@ typedef ImageAndLocationCallback = void Function(ImageAndLocationData data);
|
||||
class MapCameraLocation extends StatefulWidget {
|
||||
final CameraDescription camera;
|
||||
final ImageAndLocationCallback? onImageCaptured;
|
||||
final String userAgent;
|
||||
final String refererUrl;
|
||||
final String packageName;
|
||||
|
||||
/// Constructs a MapCameraLocation widget.
|
||||
///
|
||||
/// The [camera] parameter is required and represents the camera to be used for capturing images.
|
||||
/// The [onImageCaptured] parameter is an optional callback function that will be triggered when an image and location data are captured.
|
||||
const MapCameraLocation(
|
||||
{super.key, required this.camera, this.onImageCaptured});
|
||||
/// The [userAgent], [refererUrl], and [packageName] parameters are required for open street map policies https://operations.osmfoundation.org/policies/tiles.
|
||||
const MapCameraLocation({
|
||||
super.key,
|
||||
required this.camera,
|
||||
this.onImageCaptured,
|
||||
required this.userAgent,
|
||||
required this.refererUrl,
|
||||
required this.packageName,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MapCameraLocation> createState() => _MapCameraLocationState();
|
||||
@@ -226,8 +236,17 @@ class _MapCameraLocationState extends State<MapCameraLocation> {
|
||||
TileLayer(
|
||||
urlTemplate:
|
||||
'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
tileProvider:
|
||||
NetworkTileProvider(
|
||||
headers: {
|
||||
'User-Agent':
|
||||
widget.userAgent,
|
||||
'Referer':
|
||||
widget.refererUrl
|
||||
},
|
||||
),
|
||||
userAgentPackageName:
|
||||
'com.example.app',
|
||||
widget.packageName,
|
||||
minZoom: 12,
|
||||
),
|
||||
CurrentLocationLayer(
|
||||
|
||||
Reference in New Issue
Block a user