I haven’t used this before, but a customer has a request to be able to drag/drop a shape/point on the map to a new location on the map.
From watching the promo video for the module, it looks like the cursor lat/long positions are accessible, i’m just wondering how the click and drag interaction would be handled, as I believe this would natively pan the map? Can the shape or icon have their own event handlers?
@KyleChase
So I downloaded the module and got this working, however it’s only redrawing the position of the point icon every 1 second while i’m dragging. Is there any way to make this update faster? I’m calling forceRedraw on the mouseDragged event that is updating the dataPoints dataset point coordinates, but it doesn’t seem to help.
Also, the hover over event doesn’t seem to be being released after I let the mouse button go. I have to mouse over the icon and off to get the hover icon to go away and let me click it again. How do I release this automatically?
on mouseDragged
loc = event.source.cursorLocation
mLat = loc.getX()
mLon = loc.getY()
if event.source.pointName != '':
event.source.setNewPointLocation(event.source.pointName, mLat, mLon)
event.source.forceRedraw()
Custom method:
def setNewPointLocation(self, pointName, lat, lon):
pointsDS = self.dataPoints
row = 0
while pointsDS.getValueAt(row, 'Name') != pointName and row < 100:
row += 1
if row < 100:
pointsDS = system.dataset.setValue(pointsDS, row, 'Longitude', lon)
pointsDS = system.dataset.setValue(pointsDS, row, 'Latitude', lat)
self.dataPoints = pointsDS
self.forceRedraw()
Also, on mousePressed, I set a custom property called ‘pointName’ on the map panel component.