Skip to content

How to zoom on a polyline? #602

@vinnytwice

Description

@vinnytwice

Hi I'm trying to zoom on the polyline drawn from a List route, but when loading the map I get this error:
´´´
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following assertion was thrown building RoutesCell(dirty):
'package:flutter_map/flutter_map.dart': Failed assertion: line 142 pos 12: '!isOutOfBounds(center)': is not true.

Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
https://github.com/flutter/flutter/issues/new?template=BUG.md

The relevant error-causing widget was:
RoutesCell file:///Volumes/archivi%20recuperati/Flutter%20apps%20/fixit_cloud_biking/lib/Screens/routes_screen.dart:83:67
When the exception was thrown, this was the stack:
#2 new MapOptions (package:flutter_map/flutter_map.dart:142:12)
#3 RoutesCell.build (package:fixit_cloud_biking/models/my_routes_cell.dart:19:22)
#4 StatelessElement.build (package:flutter/src/widgets/framework.dart:4291:28)
#5 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4223:15)
#6 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
...
════════════════════════════════════════════════════════════════════════════════════════════════════
´´´
this is how I set flutter_map:


          FlutterMap(
            options: MapOptions(
//              center: route.coordinates.first,
              nePanBoundary:
                  LatLngBounds.fromPoints(route.coordinates).northEast,
              swPanBoundary:
                  LatLngBounds.fromPoints(route.coordinates).southWest,
              zoom: 15,
//              minZoom: 5.0,
//              maxZoom: 20.0,
              interactive: true,
            ),
            mapController: _mapController,
            layers: [
              new PolylineLayerOptions(
                polylines: [Polyline(points: route.coordinates)],
              ),
            ],
          ),

What am I doing wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions