Open romreed opened 4 years ago
I can create a polygon with empty space. For create i use https://geoman.io/geojson-editor created data { "type": "FeatureCollection", "features": [{ "id": "b30cc812-c8ba-41d0-98a7-76b3d7f5ec28", "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ [ [-113.52572, 53.644638], [-113.593727, 53.623059], [-113.652804, 53.590059], [-113.661735, 53.5709], [-113.658987, 53.524799], [-113.661735, 53.482325], [-113.655552, 53.474561], [-113.612275, 53.45862], [-113.592354, 53.432856], [-113.562128, 53.427128], [-113.505112, 53.436128], [-113.450844, 53.435719], [-113.372533, 53.43531], [-113.342307, 53.448398], [-113.343889, 53.510918], [-113.343681, 53.570492], [-113.345259, 53.592097], [-113.356046, 53.612062], [-113.372038, 53.625095], [-113.397446, 53.637311], [-113.449626, 53.647487], [-113.52572, 53.644638] ], [ [-113.537341, 53.53893], [-113.534078, 53.539899], [-113.52884, 53.53944], [-113.523001, 53.538828], [-113.519567, 53.537502], [-113.515445, 53.536176], [-113.511495, 53.534135], [-113.509263, 53.534135], [-113.509949, 53.531585], [-113.501105, 53.530003], [-113.502565, 53.526125], [-113.506171, 53.524289], [-113.511495, 53.524085], [-113.513127, 53.525411], [-113.517506, 53.526636], [-113.520082, 53.528166], [-113.524547, 53.529799], [-113.529871, 53.530513], [-113.538372, 53.532809], [-113.539831, 53.535411], [-113.537341, 53.53893] ] ], "city_id": 1, "city_name": "Edmonton" }, "properties": { "name": "Edmonton", "shape": "Polygon", "category": "default" } }, { "id": "83af9f01-abb7-458d-9f18-fe8dac645a89", "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ [ [-113.705187, 53.535819], [-113.859748, 53.521533], [-113.892034, 53.477831], [-113.8886, 53.431628], [-113.808228, 53.409123], [-113.701752, 53.434901], [-113.695569, 53.488454], [-113.705187, 53.535819] ], [ [-113.842575, 53.479081], [-113.835706, 53.516185], [-113.745717, 53.519446], [-113.74709, 53.474186], [-113.842575, 53.479081] ], [ [-113.846009, 53.455343], [-113.762889, 53.463501], [-113.758277, 53.435567], [-113.841877, 53.42784], [-113.846009, 53.455343] ] ], "city_id": 1, "city_name": "Edmonton" }, "properties": { "name": "Unnamed Layer", "shape": "Polygon", "category": "default" } }, { "id": "5c988165-fad6-4726-a90d-fc3ddd8cd0f9", "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ [ [-113.321896, 53.466796], [-113.18176, 53.466796], [-113.18176, 53.54398], [-113.321896, 53.54398], [-113.321896, 53.466796] ] ], "city_id": 1, "city_name": "Edmonton" }, "properties": { "name": "Unnamed Layer", "shape": "Rectangle", "category": "default" } }, { "id": "b8952823-dbd0-425a-99ec-a63037bdf3e3", "type": "Feature", "geometry": { "type": "Point", "coordinates": [-113.293045, 53.581092], "city_id": 1, "city_name": "Edmonton" }, "properties": { "name": "Unnamed Layer", "shape": "Circle", "radius": 2909.9754362977806, "category": "default" } }] } In web page I see
{ "type": "FeatureCollection", "features": [{ "id": "b30cc812-c8ba-41d0-98a7-76b3d7f5ec28", "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ [ [-113.52572, 53.644638], [-113.593727, 53.623059], [-113.652804, 53.590059], [-113.661735, 53.5709], [-113.658987, 53.524799], [-113.661735, 53.482325], [-113.655552, 53.474561], [-113.612275, 53.45862], [-113.592354, 53.432856], [-113.562128, 53.427128], [-113.505112, 53.436128], [-113.450844, 53.435719], [-113.372533, 53.43531], [-113.342307, 53.448398], [-113.343889, 53.510918], [-113.343681, 53.570492], [-113.345259, 53.592097], [-113.356046, 53.612062], [-113.372038, 53.625095], [-113.397446, 53.637311], [-113.449626, 53.647487], [-113.52572, 53.644638] ], [ [-113.537341, 53.53893], [-113.534078, 53.539899], [-113.52884, 53.53944], [-113.523001, 53.538828], [-113.519567, 53.537502], [-113.515445, 53.536176], [-113.511495, 53.534135], [-113.509263, 53.534135], [-113.509949, 53.531585], [-113.501105, 53.530003], [-113.502565, 53.526125], [-113.506171, 53.524289], [-113.511495, 53.524085], [-113.513127, 53.525411], [-113.517506, 53.526636], [-113.520082, 53.528166], [-113.524547, 53.529799], [-113.529871, 53.530513], [-113.538372, 53.532809], [-113.539831, 53.535411], [-113.537341, 53.53893] ] ], "city_id": 1, "city_name": "Edmonton" }, "properties": { "name": "Edmonton", "shape": "Polygon", "category": "default" } }, { "id": "83af9f01-abb7-458d-9f18-fe8dac645a89", "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ [ [-113.705187, 53.535819], [-113.859748, 53.521533], [-113.892034, 53.477831], [-113.8886, 53.431628], [-113.808228, 53.409123], [-113.701752, 53.434901], [-113.695569, 53.488454], [-113.705187, 53.535819] ], [ [-113.842575, 53.479081], [-113.835706, 53.516185], [-113.745717, 53.519446], [-113.74709, 53.474186], [-113.842575, 53.479081] ], [ [-113.846009, 53.455343], [-113.762889, 53.463501], [-113.758277, 53.435567], [-113.841877, 53.42784], [-113.846009, 53.455343] ] ], "city_id": 1, "city_name": "Edmonton" }, "properties": { "name": "Unnamed Layer", "shape": "Polygon", "category": "default" } }, { "id": "5c988165-fad6-4726-a90d-fc3ddd8cd0f9", "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ [ [-113.321896, 53.466796], [-113.18176, 53.466796], [-113.18176, 53.54398], [-113.321896, 53.54398], [-113.321896, 53.466796] ] ], "city_id": 1, "city_name": "Edmonton" }, "properties": { "name": "Unnamed Layer", "shape": "Rectangle", "category": "default" } }, { "id": "b8952823-dbd0-425a-99ec-a63037bdf3e3", "type": "Feature", "geometry": { "type": "Point", "coordinates": [-113.293045, 53.581092], "city_id": 1, "city_name": "Edmonton" }, "properties": { "name": "Unnamed Layer", "shape": "Circle", "radius": 2909.9754362977806, "category": "default" } }] }
code i use in my app: geo.processedPolygons.listen((GeoJsonPolygon multiPolygon) { geoJsonPolygons.add({ 'poligon': multiPolygon, 'city_id': cityId, }); for (final polygon in multiPolygon.geoSeries) { final geoSerie = GeoSerie( type: GeoSerieType.polygon, name: polygon.name, geoPoints: <GeoPoint>[]); geoSerie.geoPoints.addAll(polygon.geoPoints); Polygon poly = Polygon( consumeTapEvents: true, onTap: () { _onPolygonTapped(PolygonId( "${(math.Random().nextDouble() * 0xFFFFFF).toInt() << 0}")); }, strokeColor: Colors.orange, polygonId: PolygonId( "${(math.Random().nextDouble() * 0xFFFFFF).toInt() << 0}"), fillColor: Color.fromRGBO(75, 178, 68, 0.20), points: toLatLng(geoSerie.geoPoints, ignoreErrors: true), strokeWidth: 2, ); GeoJsonPolygon(geoSeries: [geoSerie]); polygons.add(poly); notifyListeners(); pointInsideCheck(); } }); for (var i = 0; i < polygonsData.length; i++) { if (polygonsData[i]['area_geojson'] != null) { var currentCityId = polygonsData[i]['city_id']; cityId = currentCityId; await geo.parse( json.encode(polygonsData[i]['area_geojson']), nameProperty: currentCityId.toString(), verbose: true, ); } }
geo.processedPolygons.listen((GeoJsonPolygon multiPolygon) { geoJsonPolygons.add({ 'poligon': multiPolygon, 'city_id': cityId, }); for (final polygon in multiPolygon.geoSeries) { final geoSerie = GeoSerie( type: GeoSerieType.polygon, name: polygon.name, geoPoints: <GeoPoint>[]); geoSerie.geoPoints.addAll(polygon.geoPoints); Polygon poly = Polygon( consumeTapEvents: true, onTap: () { _onPolygonTapped(PolygonId( "${(math.Random().nextDouble() * 0xFFFFFF).toInt() << 0}")); }, strokeColor: Colors.orange, polygonId: PolygonId( "${(math.Random().nextDouble() * 0xFFFFFF).toInt() << 0}"), fillColor: Color.fromRGBO(75, 178, 68, 0.20), points: toLatLng(geoSerie.geoPoints, ignoreErrors: true), strokeWidth: 2, ); GeoJsonPolygon(geoSeries: [geoSerie]); polygons.add(poly); notifyListeners(); pointInsideCheck(); } }); for (var i = 0; i < polygonsData.length; i++) { if (polygonsData[i]['area_geojson'] != null) { var currentCityId = polygonsData[i]['city_id']; cityId = currentCityId; await geo.parse( json.encode(polygonsData[i]['area_geojson']), nameProperty: currentCityId.toString(), verbose: true, ); } }
in my app map look like this
I can create a polygon with empty space. For create i use https://geoman.io/geojson-editor created data
{ "type": "FeatureCollection", "features": [{ "id": "b30cc812-c8ba-41d0-98a7-76b3d7f5ec28", "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ [ [-113.52572, 53.644638], [-113.593727, 53.623059], [-113.652804, 53.590059], [-113.661735, 53.5709], [-113.658987, 53.524799], [-113.661735, 53.482325], [-113.655552, 53.474561], [-113.612275, 53.45862], [-113.592354, 53.432856], [-113.562128, 53.427128], [-113.505112, 53.436128], [-113.450844, 53.435719], [-113.372533, 53.43531], [-113.342307, 53.448398], [-113.343889, 53.510918], [-113.343681, 53.570492], [-113.345259, 53.592097], [-113.356046, 53.612062], [-113.372038, 53.625095], [-113.397446, 53.637311], [-113.449626, 53.647487], [-113.52572, 53.644638] ], [ [-113.537341, 53.53893], [-113.534078, 53.539899], [-113.52884, 53.53944], [-113.523001, 53.538828], [-113.519567, 53.537502], [-113.515445, 53.536176], [-113.511495, 53.534135], [-113.509263, 53.534135], [-113.509949, 53.531585], [-113.501105, 53.530003], [-113.502565, 53.526125], [-113.506171, 53.524289], [-113.511495, 53.524085], [-113.513127, 53.525411], [-113.517506, 53.526636], [-113.520082, 53.528166], [-113.524547, 53.529799], [-113.529871, 53.530513], [-113.538372, 53.532809], [-113.539831, 53.535411], [-113.537341, 53.53893] ] ], "city_id": 1, "city_name": "Edmonton" }, "properties": { "name": "Edmonton", "shape": "Polygon", "category": "default" } }, { "id": "83af9f01-abb7-458d-9f18-fe8dac645a89", "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ [ [-113.705187, 53.535819], [-113.859748, 53.521533], [-113.892034, 53.477831], [-113.8886, 53.431628], [-113.808228, 53.409123], [-113.701752, 53.434901], [-113.695569, 53.488454], [-113.705187, 53.535819] ], [ [-113.842575, 53.479081], [-113.835706, 53.516185], [-113.745717, 53.519446], [-113.74709, 53.474186], [-113.842575, 53.479081] ], [ [-113.846009, 53.455343], [-113.762889, 53.463501], [-113.758277, 53.435567], [-113.841877, 53.42784], [-113.846009, 53.455343] ] ], "city_id": 1, "city_name": "Edmonton" }, "properties": { "name": "Unnamed Layer", "shape": "Polygon", "category": "default" } }, { "id": "5c988165-fad6-4726-a90d-fc3ddd8cd0f9", "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ [ [-113.321896, 53.466796], [-113.18176, 53.466796], [-113.18176, 53.54398], [-113.321896, 53.54398], [-113.321896, 53.466796] ] ], "city_id": 1, "city_name": "Edmonton" }, "properties": { "name": "Unnamed Layer", "shape": "Rectangle", "category": "default" } }, { "id": "b8952823-dbd0-425a-99ec-a63037bdf3e3", "type": "Feature", "geometry": { "type": "Point", "coordinates": [-113.293045, 53.581092], "city_id": 1, "city_name": "Edmonton" }, "properties": { "name": "Unnamed Layer", "shape": "Circle", "radius": 2909.9754362977806, "category": "default" } }] }
In web page I seecode i use in my app:
geo.processedPolygons.listen((GeoJsonPolygon multiPolygon) { geoJsonPolygons.add({ 'poligon': multiPolygon, 'city_id': cityId, }); for (final polygon in multiPolygon.geoSeries) { final geoSerie = GeoSerie( type: GeoSerieType.polygon, name: polygon.name, geoPoints: <GeoPoint>[]); geoSerie.geoPoints.addAll(polygon.geoPoints); Polygon poly = Polygon( consumeTapEvents: true, onTap: () { _onPolygonTapped(PolygonId( "${(math.Random().nextDouble() * 0xFFFFFF).toInt() << 0}")); }, strokeColor: Colors.orange, polygonId: PolygonId( "${(math.Random().nextDouble() * 0xFFFFFF).toInt() << 0}"), fillColor: Color.fromRGBO(75, 178, 68, 0.20), points: toLatLng(geoSerie.geoPoints, ignoreErrors: true), strokeWidth: 2, ); GeoJsonPolygon(geoSeries: [geoSerie]); polygons.add(poly); notifyListeners(); pointInsideCheck(); } }); for (var i = 0; i < polygonsData.length; i++) { if (polygonsData[i]['area_geojson'] != null) { var currentCityId = polygonsData[i]['city_id']; cityId = currentCityId; await geo.parse( json.encode(polygonsData[i]['area_geojson']), nameProperty: currentCityId.toString(), verbose: true, ); } }
in my app map look like this