arcgis maps in flutter - flutter

I am trying to put an arcgis WMTS tile layer on top of openstreetmaps WMTS layer in flutter using the flutter_map plugin.
Here is my code :
Widget build(BuildContext context) {
return MaterialApp(
home: FlutterMap(
options: new MapOptions(
center: LatLng(33.8, 9.5),
zoom: 6.0,
pinchZoomWinGestures: MultiFingerGesture.pinchZoom,
),
layers: [
//layer 1 - leaflet tiles
TileLayerOptions(
urlTemplate: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
subdomains: ['a', 'b', 'c'],
tileProvider: NonCachingNetworkTileProvider(),
backgroundColor: Colors.black,
),
//Layer 2 - leaflet tiles
TileLayerOptions(
urlTemplate:
"https://tiles.arcgis.com/tiles/C8EMgrsFcRFL6LrL/arcgis/rest/services/GEBCO_contours/MapServer/tile/{z}/{x}/{y}",
subdomains: ['a', 'b', 'c'],
tileProvider: NonCachingNetworkTileProvider(),
backgroundColor: Colors.transparent,
),
],
),
);
but the arcgis map does not align correctly with the openstreetmap.
as shown in the scrrenshot
I hope you can help me rectify my code and have a great day

I've faced something like this before. I was putting ArcGIS tile on top of Mapbox, and the result was like you described.
Probably the axes differ a little if the layers are made by Esri products.
And for this case, I only have 2 solutions for you :
1 - Use ArcGIS Pro or any ArcGIS tool and try shifting the layers till they fit the OpenStreetMap.
2 - Instead of using OpenStreetMap, use ArcGIS APIs, but you have to add some native code for iOS and Android, and check pub.dev for ArcGIS libraries.

I also have faced the similar issue with the ArcGIS map - it is not aligning correctly in the screen. The below pattern ({z}/{y}/{x}) renders the esri tiles correctly on the screen.
https://services.arcgisonline.com/arcgis/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}

Related

Flutter mapbox polyline maps

I am trying to create polyline map using mapbox, which I am able to create properly.
User can come back and can see see polyline maps in his profile.
Doubt - Is there any way I can convert my list of lat long into some format and store in db and later on we fetch it from db and render map?
I checked geojson format also but if we use geoJson with mapbox it generates static maps.
I am using flutter_map to generate maps.
Updated -
var geoJson = {
"type": "polyline",
"coordinates": [
[
76.61219358444214,
27.555764420824236
],
[
76.6120433807373,
27.55395717009122
],
[
76.61094903945923,
27.55285378133631
],
[
76.61021947860718,
27.55138892051556
],
[
76.61000490188599,
27.550285505956428
],
[
76.6101336479187,
27.549372326903264
],
[
76.6107988357544,
27.548287916916344
],
[
76.61150693893433,
27.547831320034653
],
[
76.61109924316406,
27.54568148421033
],
[
76.61097049713135,
27.54391211873852
]
]
}
Currently I am using flutter_map package and using below code to render map.
var points = [LatLng(latitude:27.591585, longitude:76.61139), LatLng(latitude:27.591548, longitude:76.611397), LatLng(latitude:27.591473, longitude:76.611407), LatLng(latitude:27.591437, longitude:76.611413), LatLng(latitude:27.591362, longitude:76.611425), LatLng(latitude:27.591325, longitude:76.61143), LatLng(latitude:27.59125, longitude:76.611442), LatLng(latitude:27.591177, longitude:76.611452), LatLng(latitude:27.59114, longitude:76.611458), LatLng(latitude:27.591065, longitude:76.61147), LatLng(latitude:27.591028, longitude:76.611475), LatLng(latitude:27.591007, longitude:76.611587), LatLng(latitude:27.591013, longitude:76.611693), LatLng(latitude:27.590777, longitude:76.611805), LatLng(latitude:27.590657, longitude:76.611822), LatLng(latitude:27.590535, longitude:76.61184), LatLng(latitude:27.590413, longitude:76.611857), LatLng(latitude:27.590293, longitude:76.611875), LatLng(latitude:27.590172, longitude:76.611892)]
return new Scaffold(
appBar: new AppBar(title: new Text('Leaflet Maps')),
body: new FlutterMap(
options: new MapOptions(
center: new LatLng(27.563896, 76.600460), minZoom: 10.0),
layers: [
new TileLayerOptions(
urlTemplate:
"https://api.mapbox.com/styles/v1/jainaman8/ckd5v8bs00zm01ir3w3bjrrb3/tiles/256/{z}/{x}/{y}#2x?access_token=ACCESS_TOKEN",
additionalOptions: {
'accessToken': '',
'id': 'mapbox.mapbox-streets-v8'
}
),
new PolylineLayerOptions(
polylines: [
new Polyline(
points: points,
strokeWidth: 2.0,
color: Colors.red
)
]
)
I want to store geoJson object into firebase and then pull this data from there and render map using mapbox.
I read on google that firebase does not support arrays so another doubt is that how can I store this data on firebase ?
You can do the desired by making a collection of field of type geopoint and then get those fields in your flutter project.

Label overflows window when using horizontal scrolling with chart_flutter

I'm using charts_flutter and using a scrollable bar chart. Horizontal scrolling works great with the behaviors SlidingViewport() and PanAndZoomBehavior() (charts_flutter example). I would also like to have labels follow the bar itself and stay inside the chart window when scrolling. See image.
Code
BarChart(
data,
behaviors: [
SlidingViewport(),
PanAndZoomBehavior(),
],
animate: true,
domainAxis: OrdinalAxisSpec(
viewport: OrdinalViewport('Week ${weeks.last}', 4),
),
)
I used ClipRect() to solve that issue, simply wrap your widget with what ever clipper you wish although the default works as well,
ClipRect(child : BarChart(
data,
behaviors: [
SlidingViewport(),
PanAndZoomBehavior(),
],
animate: true,
domainAxis: OrdinalAxisSpec(
viewport: OrdinalViewport('Week ${weeks.last}', 4),
),
))

How to create Tree View Layout in Flutter?

I am making a screen when I need to show design like Screen Below, with tree views and connectors.
It will be a great help if someone can suggest me how to create a design like this, conceptually.
I have tried a Gridview and tree_view so far.
GridView.count(
// Create a grid with 2 columns. If you change the scrollDirection to
// horizontal, this produces 2 rows.
crossAxisCount: 2,
// Generate 100 widgets that display their index in the List.
children: List.generate(100, (index) {
return Center(
child: Text(
'Item $index',
style: Theme.of(context).textTheme.headline,
),
);
}),
);
Use the public flutter package called GraphView
Flutter GraphView is used to display data in graph structures. It can
display Tree layout, Directed and Layered graph. Useful for Family
Tree, Hierarchy View.
The library is designed to support different graph layouts and currently works excellent with small graphs.
graphite is somewhat similar to the design,
DirectGraph(
list: list,
cellWidth: 136.0,
cellPadding: 24.0,
orientation: MatrixOrientation.Vertical,
)

How to fit polylines to street curves in google maps flutter?

How to fit polylines to street curves in google maps flutter?
I did being playing with Polylines in google_maps_flutter for 2 months and I have this doubts:
Polylines do not follow the street curves or the highways.
Polylines has the OnTap callback but, on multi-polylines I can not get any ID or attribute to distinguis who I tapped.
can any one give me a hand with this?
I am new in Flutter and I am using the Directions API from Google. Maybe is not the right API to solve this problem.
I need that polyline set follow the street curves.
Polylines in google_maps_flutter
P.S: Sorry if my code bleed your eyes!
google_maps_flutter widget:
GoogleMap(
onMapCreated: (controller) {
_mapController = controller;
},
initialCameraPosition: CameraPosition(
target: getCurrentLocation(),
zoom: 15,
),
mapType: _currentMapType,
myLocationEnabled: true,
myLocationButtonEnabled: false,
compassEnabled: true,
rotateGesturesEnabled: true,
markers: _markers,
polylines: _polyline,
)
Set state to show the polyline and markers:
setState(
() {
_markers.clear();
for (var point in itinerary) {
_markers.add(
Marker(
markerId: MarkerId("stop ${point.latitude}"),
position: LatLng(point.latitude, point.longitude),
infoWindow: InfoWindow(title: point.address),
),
);
}
_polyline.clear();
_polyline.add(
flutter.Polyline(
polylineId: PolylineId("route"),
points: ccc,
width: 8,
color: Colors.red,
geodesic: true,
jointType: JointType.round,
),
);
_mapController.animateCamera(
CameraUpdate.newLatLngZoom(
LatLng(origin.lat, origin.lng), 13.0),
);
},
);
Google Directions API Call:
GoogleMapsDirections(apiKey: apiKey).directions(origin, destination, waypoints: itinerary, ).then((DirectionsResponse response) { return response }
I got some advice from Github member that told me to try SnapToRoad, now I get more details about the route, but the highways are still helicopter's travel
A simple GET to https://roads.googleapis.com/v1/snapToRoads whit the API_KEy and some points of my previus polyline helps.
Here is the link of SnapToRoad
That's because the polyline it's just a line that you draw, to do what you want need to make a route between points and using that generated coordinates make a polyline.
Check this tutorial that i found: https://www.developerlibs.com/2018/08/flutter-how-can-draw-route-on-google.html
try this pub: google_map_polyline

Flutter charts PanAndZoomBehavior does not zoom on the center of the gesture

I used https://github.com/google/charts inside my flutter app. It works great. But when i zoom on chart, the zoom happens but in the wrong place! It starts expanding keeping the left static. The effect is the chart slide under your finger zooming not in the point you are zooming to. Is there a way to zoom like you zoom on a picture on gallery?
code of my chart
Widget build(BuildContext context) {
return new charts.LineChart(
_chartSeriesFromChartData(seriesList),
animate: false,
defaultRenderer: charts.LineRendererConfig(includeArea: true, includePoints: true),
primaryMeasureAxis: charts.NumericAxisSpec(tickProviderSpec: charts.BasicNumericTickProviderSpec(desiredTickCount: 8)),
behaviors: [ZoomBehaviour()],
)
You can use code like this in your code:
behaviors: [new charts.PanAndZoomBehavior()],
or if you want selection by item in our charts you can use:
behaviors: [new charts.SeriesLegend()],
and if you want use two of them maybe you can use:
behaviors: [new charts.SeriesLegend(), new charts.PanAndZoomBehavior()],