Can I prevent some areas on the map from being clicked? not all of them?
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?
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.
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;
});