Coder Social home page Coder Social logo

Comments (15)

zozeei avatar zozeei commented on August 16, 2024

1602149718359

from flutter_map_line_editor.

ibrierley avatar ibrierley commented on August 16, 2024

Have you tried it? What problems did you get ?

from flutter_map_line_editor.

moovida avatar moovida commented on August 16, 2024

@ibrierley , I was investigating multi-geometries and polygons with holes. This might be related for the first.
First off, would I have to create a polyEditor for each Geometry? And then when it comes to create:

DragMarkerPluginOptions(markers: polyEditor.edit()),

would I collect the markers from each? They should not suffer from mixups, right?

from flutter_map_line_editor.

ibrierley avatar ibrierley commented on August 16, 2024

Yes, you would need to create a polyeditor for each currently.

I don't think there should be mixups, assuming the lists of points are separate and not reused between geometries.

I haven't tested this scenario, but I can't think of any caveats, but do let me know if you find any.

from flutter_map_line_editor.

zozeei avatar zozeei commented on August 16, 2024

from flutter_map_line_editor.

ibrierley avatar ibrierley commented on August 16, 2024

Let me know your code for a minimal testing example, and I shall take a look.

from flutter_map_line_editor.

zozeei avatar zozeei commented on August 16, 2024

if i add multipolygon, would I have to create a DragMarkerPluginOptions(markers: polyEditor.edit()) before, right?
Can I add that after the second drawing polygon ?

from flutter_map_line_editor.

zozeei avatar zozeei commented on August 16, 2024
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:latlong/latlong.dart';
import 'package:flutter_map/plugin_api.dart';
import 'package:flutter_map_dragmarker/dragmarker.dart';
import 'polyeditor.dart';

void main() {
  runApp(TestApp());
}

class TestApp extends StatefulWidget {
  @override
  _TestAppState createState() => _TestAppState();
}

class _TestAppState extends State<TestApp> {
  PolyEditor polyEditor, polyEditor2;
  final MapController mapController = MapController();
  List<Polygon> polygons = [];

  List dragMarkerEditor = List();

  var testPolygon = new Polygon(
    color: Colors.deepOrange.withOpacity(0.2),
    points: [],
    borderColor: Colors.deepOrange,
    borderStrokeWidth: 2,
  );
  var testPolygon2 = new Polygon(
    color: Colors.blue.withOpacity(0.2),
    points: [],
    borderColor: Colors.blue,
    borderStrokeWidth: 2,
  );

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

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

    polygons.add(testPolygon);
    polygons.add(testPolygon2);
  }

  @override
  Widget build(BuildContext context) {
//
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: Container(
            child: Stack(
              children: [
                FlutterMap(
                  mapController: mapController,
                  options: MapOptions(
                    onTap: (ll) {
                      polyEditor.add(testPolygon.points, ll);
                      polyEditor2.add(testPolygon2.points, ll);
                    },
                    plugins: [
                      DragMarkerPlugin(),
                    ],
                    center: LatLng(45.5231, -122.6765),
                    zoom: 6.4,
                  ),
                  layers: [
                    TileLayerOptions(
                        urlTemplate:
                            'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
                        subdomains: ['a', 'b', 'c']),
                    PolygonLayerOptions(polygons: polygons),
                    DragMarkerPluginOptions(markers: polyEditor.edit()),
                    DragMarkerPluginOptions(markers: polyEditor2.edit()),
                  ],
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

from flutter_map_line_editor.

ibrierley avatar ibrierley commented on August 16, 2024

I guess the question with the code above is, firstly what happens, and secondly what do you want to happen ?

I can see in onTap you are adding a point to both sets of polyEditors, which looks a bit strange, but what logic do you want to happen when you click on a map ? How do you want to decide which polyEditor you will add a point to. So I think maybe you need to clarify the logic of what you want to happen firstly.

You see normally you would only have an onTap work for one object I would assume, which you have selected via some method. Dragging the existing points on any polygon I would assume to make sense though, does that work ?

from flutter_map_line_editor.

zozeei avatar zozeei commented on August 16, 2024

I try to follow an example. http://leaflet.github.io/Leaflet.Editable/example/undo-redo.html

from flutter_map_line_editor.

ibrierley avatar ibrierley commented on August 16, 2024

So you need to decide what method you are going to 'select' which polygon you are currently working on (adding new points to).

What currently happens ?

from flutter_map_line_editor.

zozeei avatar zozeei commented on August 16, 2024

from flutter_map_line_editor.

ibrierley avatar ibrierley commented on August 16, 2024

What do you expect to do, rather than add the option once for each polygon ?
I'm kind of failing to see what the problem actually is. You could naturally use a list and loop through them to do it, but each poly will need an editor.

from flutter_map_line_editor.

zozeei avatar zozeei commented on August 16, 2024

from flutter_map_line_editor.

ibrierley avatar ibrierley commented on August 16, 2024

Just to be clear, I am guessing there will be problems, if you have many editors live at the same time. It will probably be just the top layer which receives the drag clicks (I haven't had chance to test this yet)...but this is possibly part of the logic which you may need to figure out, which one you have 'selected'. I'm not sure the plugin itself could figure that out...if you need ALL the be simultaneously able to move the markers around and create new ones, I don't think that would work, but if you have the logic of only one you have selected needing the events, it may work.

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.