Coder Social home page Coder Social logo

Comments (6)

ibrierley avatar ibrierley commented on July 17, 2024

Hi, I don't think that could be related to the editor, as it doesn't know (or care) about the shape (iirc, it's a while since I did it), it just edits a list of points. So I'm unsure that it could be related to it, unless there's something I'm missing.

Maybe it's worth showing the code...are you sure you aren't repeatedly redrawing the shape multiple times or something ?

from flutter_map_line_editor.

zozeei avatar zozeei commented on July 17, 2024

i am sure ,i aren't repeatedly redrawing the shape multiple times

from flutter_map_line_editor.

ibrierley avatar ibrierley commented on July 17, 2024

from flutter_map_line_editor.

zozeei avatar zozeei commented on July 17, 2024

my code

class _RequestDrawScreenState extends State<RequestDrawScreen> {
  final MapController mapController = MapController();
  final List<Marker> userLocationMarkers = <Marker>[];
  PolyEditor polyEditor;
  List<Polygon> polygons = [];


  var testPolygon =
      new Polygon(color: Colors.deepOrange.withOpacity(0.1), points: []);

  @override
  void initState() {
    super.initState();

    polyEditor = new PolyEditor(
        points: testPolygon.points,
        pointIcon: Icon(
          Icons.crop_square,
          size: 23,
        ),
        intermediateIcon: Icon(Icons.lens, size: 15, color: Colors.grey),
        callbackRefresh: () => {this.setState(() {})});
  }

  @override
  Widget build(BuildContext context) {
    polygons.add(testPolygon);
    return Scaffold(
        body: SafeArea(
      child: Stack(
        children: [
          FlutterMap(
            mapController: mapController,
            options: MapOptions(
              onTap: (latLog) {
                polyEditor.add(testPolygon.points, latLog);
                print(latLog);
              },
              plugins: <MapPlugin>[
                // USAGE NOTE 2: Add the plugin
                LocationPlugin(),
                DragMarkerPlugin(),
              ],
              center: LatLng(45.5231, -122.6765),
              zoom: 6.4,
            ),
            layers: <LayerOptions>[
              TileLayerOptions(
                urlTemplate:
                    'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
                subdomains: <String>['a', 'b', 'c'],
              ),
              // USAGE NOTE 3: Add the layer for the marker
              MarkerLayerOptions(markers: userLocationMarkers),
              PolygonLayerOptions(polygons: polygons),
              DragMarkerPluginOptions(markers: polyEditor.edit()),

            ],
          ),
          Positioned(
              right: 10.0,
              bottom: 100.0,
              child: Column(children: <Widget>[
                IconButton(
                  iconSize: 30.0,
                  icon: const Icon(Icons.map),
                  tooltip: "Map Type",
                  onPressed: null,
                ),
              ])),
        ],
      ),
    ));
  }
}

from flutter_map_line_editor.

ibrierley avatar ibrierley commented on July 17, 2024

I haven't run it, but it looks like you're not resetting your polygons list every build, so as mentioned you're readding it every build, so you will end up with a list of repeated testpolygons. Try adding in polygons = [] as first line in build method.

from flutter_map_line_editor.

zozeei avatar zozeei commented on July 17, 2024

Thanks for the answer, it works. @ibrierley

from flutter_map_line_editor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.