b = geometry_name.walkPolygon(ʃmap_nameʅ);
The
Geometry.walkPolygon function displays an interactive map-based interface allowing the user to create a polygon by walking the perimeter of an area and recording their location using the GPS. The interface is similar to that used by
Geometry.tracePolygon except that rather than tapping on the map to place the vertices of the polygon, there is an add vertex button that places a vertex at the user's current location as determined by GPS. While walking the outline, the user may also drag vertices of the polygon by long pressing on them in order to modify the polygon. The function returns when the user has finished creating the polygon on the map and taps the save button.
The optional argument
map_name is the name of a
Map object that will provide the display parameters used for the map that is shown while the user walks the polygon. You can use this parameter to set the
base map,
title, and
location/zoom level of the map. You can also use the map parameter to display
markers and
geometry on the map, however any callbacks for clicking on markers or on the map itself are ignored while walking the polygon. Any buttons on the map are replaced by buttons for adding a vertex, saving, clearing, and deleting the last point placed while the polygon is being walked. If the argument
map_name is omitted, a map with default settings is displayed while walking the polygon.
After walking the polygon, you can
save the geometry to a file, compute the
area of the polygon, or compute the
perimeter of the polygon.
If
geometry_name already contains a polygon, this polygon will be displayed and the user will be able to modify it by long pressing on the vertices to drag them. If the geometry contains more than one polygon, only the first polygon is shown. All entities in the geometry other than polygons are ignored. If the geometry was loaded from GeoJSON, any polygons in entities of type MultiPolygon are ignored. If you wish to capture a new polygon rather than editing the existing geometry, use the
Geometry.clear function before calling
Geometry.walkPolygon.
The function returns a logical value of 1 (true) if the user created a polygon and 0 (false) if the file user canceled polygon walking by tapping the back button.
// Declare a geometry
Geometry outline;
// Have the user walk the outline of a polygon
if outline.walkPolygon() then
// Save the outline to a GeoJSON file
outline.save("outline.geojson");
endif;
// Declare a geometry
Geometry plot;
// Declare a map
Map mymap;
// Set map display parameters
mymap.setBaseMap("basemap.mbtiles");
mymap.setTitle("Tap points on the map to outline the plot");
// Have the user walk the outline of a polygon using the map
if plot.walkPolygon(mymap) then
// Capture the plot area
PLOT_AREA = plot.area();
endif;