b = map_name.removeGeometry(geometryId);
The
Map.removeGeometry function removes Geometry from the Map
map_name.
geometryId should be the id returned by
Map.addGeometry when the Geometry was added to the Map.
The function returns a logical value of 1 (true) if the geometry was found and was successfully removed and 0 (false) if there is an error.
PROC GLOBAL
// Declare a map
Map mymap;
// Declare a geometry to hold boundary polygon
Geometry boundary;
// Declare a variable to hold the id of the boundary on the map
numeric boundaryGeometryId;
function showBoundary()
// Add boundary polygon to the map and save the id
boundaryGeometryId = mymap.addGeometry(boundary);
end;
function hideBoundary()
// Remove the boundary polygon from the map
mymap.removeGeometry(boundaryGeometryId);
boundaryGeometryId = 0;
end;
function toggleBoundary()
if boundaryGeometryId = 0 then
showBoundary();
else
hideBoundary();
endif;
end;
PROC SHOW_MAP
preproc
// Load the boundary polygon from a file
boundary.load("boundary.geojson");
// Add a button to show/hide the boundary
mymap.addTextButton("Boundary", toggleBoundary());
// Display the map
mymap.show();