Closed adnanefouam closed 4 years ago
i created a variabl named geoJson,
var geoJson = { "type": "FeatureCollection", "features": [ { "geometry": { "coordinates": widget.data, //here i put my data from api "type": "LineString" }, "id": "67482000440040", "properties": { "commune": "67482", "contenance": 9.115727199974797e-07, "created": "", "numero": "40", "prefixe": "000", "section": "44", "updated": "2006-03-09" }, "type": "Feature" }
and i used data =json.encode(geoJson) ; instead of data = await rootBundle .loadString('assets/........');
NOTE : always keep an eye on how much arrays inside the coordinates
thank you guys for this amazing package !!
Hey I'm trying to load geojson multipolygon into the map but can't do that as it throws various catches being LatLong usage polygon duplication and heatmap. I am using Google map flutter, & geojson package from dart repo.
i have multiple adresses from api with coordinates and i want to display their geojson data on the map like this
import 'dart:async'; import 'package:map_controller/map_controller.dart'; class Mapboxtest extends StatefulWidget {
final double lat; final double lon; final Object data;
Mapboxtest ({ Key key, @required this.lat,@required this.lon,this.data }): super(key: key); @override _MapboxtestState createState() => new _MapboxtestState(); }
class _MapboxtestState extends State {
MapController mapController; StatefulMapController statefulMapController; StreamSubscription sub;
final lines = [];
Future parseAndDrawAssetsOnMap() async {
final geo = GeoJson();
geo.processedLines.listen((GeoJsonLine line) {
setState(() => lines.add(Polyline(
borderColor: Colors.red,
strokeWidth: 4.0, color: primarycolor, points: line.geoSerie.toLatLng())));
});
geo.endSignal.listen((_) => geo.dispose());
final data = widget.data;
await geo.parse(data, verbose: true);
}
@override void initState() { mapController = MapController(); statefulMapController = StatefulMapController(mapController: mapController); statefulMapController.onReady.then((_) => parseAndDrawAssetsOnMap()); sub = statefulMapController.changeFeed.listen((change) => setState(() {})); super.initState(); } @override Widget build(BuildContext context) {
} }