About clicking areas

Can I prevent some areas on the map from being clicked? not all of them?

1 Like

This is not currently possible in the default maps that ship with farmOS (eg: the ā€œFarm Areasā€ and ā€œFarm Assetsā€ maps).

It could be achieved by programming a custom map, however, and only enabling the popup on certain layers.

For example, when we connect with the phone, when we want to click on the point where the red points and the red line intersect, we can accidentally click the line instead of the red point. is there any way to prevent this?

1 Like

I donā€™t think thereā€™s much we can do to address this. When geometries are close together and youā€™re using a touch interface itā€™s inherently difficult.

Perhaps zooming in further would help?

Canā€™t we turn off the click feature of that area?

With a custom map, perhaps, yes. You would need to write your own logic to add the layers you want to the map, and decide which ones you want to be clickable. If the points and lines are the same area type that would be more complicated.

I actually have a similar use-case where we usually create a surrounding area for a whole garden/field then named beds within that. I think it depends on the order of the features, but it is sometimes hard to select smaller features that fall within another feature.

Thereā€™s obviously other ways to navigate, but I believe this affects the general usability of the map as a selection/navigation tool.

It could be addressed via a custom select function, by populating relative z-indexes based on feature size, or by inheriting inverse z-indexes from the area hierarchy.

1 Like

For example, I donā€™t want a popup to appear in my sb23 area. The code I use is as follows. Where should I make this addition to prevent popups in the area named sb23?

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

instance.popup = instance.addPopup(function (event) {
var content = ā€˜ā€™;
var feature = instance.map.forEachFeatureAtPixel(event.pixel, function(feature, layer) { return feature; });
if (feature) {
// If the feature is a cluster, then create a list of names and add it
// to the overall featureā€™s description.
var features = feature.get(ā€˜featuresā€™);
if (features !== undefined) {
var names = [];
features.forEach(function (item) {
if (item.get(ā€˜nameā€™) !== undefined) {
names.push(item.get(ā€˜nameā€™));
}
});
if (names.length !==0) {
feature.set(ā€˜descriptionā€™, ā€˜

  • ā€™ + names.join(ā€™
  • ā€™) + ā€˜
ā€™);
}
feature.set(ā€˜nameā€™, names.length + ā€™ item(s):ā€™);
}

      var name = feature.get('name') || '';
      var description = feature.get('description') || '';
      var measurement = instance.measureGeometry(feature.getGeometry(), instance.units);
       if (name !== '' ||  description !== '') {
        content = '<div class="ol-popup-content"><h4 class="ol-popup-name">' + name + '</h4></div><div class="ol-popup-description">' + description + '</div></div>';
      }

      }
    return content;
  });