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) {
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;