I need a PointField that has a “Move here” button next to the map. This way the user doesn’t need to drag, zoom in, drag a bit closer, zoom in some more and then drag some more to get the marker to some exact position. With the “Move here” button, the user needs to navigate to the correct place, click “Move here” and drag marker once, from center of the mapview to the wanted location.
I tried to accomplish this by trial and error:
Adding a Button to the PointField fails, because it won’t accept any ramdom Component to be added.
I considered making an new CustomField that would use a PointField, but I would have to override a lot of methods that would just call the corresponding method in the PointField.
And then I gave up and did it the ugly way:
- Build a FormLayout with a PointField
- Create a VerticalLayout
- Replace the PointField with the VerticalLayout in the FormLayout
- Add the PointField and a Button to the VerticalLayout
Is there a good way to make the marker on a PointField to move when a Button is clicked?
Marker field of PointField is private with no getter so I needed to iterate over the components of the map and cast to LMarker before I could set the location.