0 purchases
map4d map utils
Map4dMap Utility Library for Flutter #
A Flutter plugin that provides utility library for Map4dMap
Installing #
Depend on it #
To use this plugin, run command:
flutter pub add map4d_map_utils
copied to clipboard
Or add map4d_map_utils as a dependency in your pubspec.yaml file.
dependencies:
map4d_map_utils: ^1.0.0
copied to clipboard
Import it #
In your Dart code, you can use:
import 'package:map4d_map_utils/map4d_map_utils.dart';
copied to clipboard
Requirements #
Android SDK 21+
iOS 9.3+
Example Usage #
e.g. Marker Clustering:
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:map4d_map/map4d_map.dart';
import 'package:map4d_map_utils/map4d_map_utils.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
final int maxClusterItemCount = 500;
final double cameraLatitude = 16.0432432;
final double cameraLongitude = 108.032432;
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Map4D Map Utility',
home: MFMapView(
initialCameraPosition: MFCameraPosition(
target: MFLatLng(cameraLatitude, cameraLongitude), zoom: 10),
onMapCreated: onMapCreated,
),
);
}
void onMapCreated(MFMapViewController controller) {
final clusterManager = MFClusterManager(
controller: controller,
onClusterTap: (cluster) => onClusterTap(cluster, controller)
);
// Generate cluster items
const double extent = 0.2;
for (int i = 0; i < maxClusterItemCount; i++) {
double lat = cameraLatitude + extent * (Random().nextDouble() * 2.0 - 1.0);
double lng = cameraLongitude + extent * (Random().nextDouble() * 2.0 - 1.0);
final item = MFClusterItem(position: MFLatLng(lat, lng));
clusterManager.addItem(item);
}
clusterManager.cluster();
}
void onClusterTap(MFCluster cluster, MFMapViewController controller) async {
final zoom = await controller.getZoomLevel();
controller.animateCamera(MFCameraUpdate.newLatLngZoom(cluster.position, zoom + 1));
}
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.