In Jmix Version 1, the map addon can be incorporated as a formfield in edit page and based on its property, point, polyline or polygon can be drawn on map interactively in edit page. How can we achieve this in updated map-addon in JMIX version 2?
An example of saving point data is available in documentation of JMIX version 2 at https://docs.jmix.io/jmix/maps/data-binding-map.html#saving-coordinates. How can we achieve same in case of polyline or polygon?
I am currently using JMIX 2.3.3.
Please guide.
Or can the developer have access to the base leaflet library? If yes, then how? Thanks.
Hello!
There is an issue for editing and drawing features in Maps 2.x: Add ability to edit features in the Map · Issue #2832 · jmix-framework/jmix · GitHub.
The GeoMap
component in Jmix 2 bases on OpenLayers. You can get access to client-side using getElement()
, for instance:
map.getElement("this.olMap.render()");
However, adding drawing feature is a more complicated process. In this case, you need to extend the GeoMap
component class and the JmixOpenLayersMap
class from the jmix-openlayers-map.js
file, as this requires adding new imports.
import {Draw, Modify, Snap} from 'ol/interaction.js';
See OpenLayers sample: Draw and Modify Features.
Thanks Roman for the reply.
Any expected date till which map-addon with functionality of Draw, Modify and Snap will be released.
But one of the core functionality of application being developed is creating, editing and removing GeoObjects. I have somewhat managed creation of entities by capturing the map click event and gathering the coordinates. But can not manage editing and removing geoObjects.
Even there in no event for mouseMove and geoObjectMove in Map Add-on.
Can you suggest any other easy method to implement modify operations, however crude it is?
Thanks
The feature will be available in minor release in 2025 February.
I guess, another way will be generating the form with fields for GeoObject. Every field correposonds to point in GeoObject.
For instance, make a toggle button that will enable “editor” mode. In this editor mode by click on GeoObject, generate form with field for every point in GeoObject. The user can edit fields manually or you can create for every field, e.g. checkbox that will indicate that coordinates from click on a map should be written to this field.
Probably, you can create similar mode for moving GeoObjects. The first click “selects” GeoObject, the second moves it to new coordinates.
Ok. Thank Roman. Will give it a try and revert back if i encounter some roadblock. Or will wait till February. Just guessing, can i use any vaadin addon for openlayers for creating & editing part?
I didn’t investigate the ability to edit features in the Vaadin map. However, you can try it, as I remember Vaadin provides a 2-week trial license.