
Donald Trump says he’ll meet Vladimir Putin subsequent week. He additionally says that an finish to the battle should contain “some swapping of territories”.
I believed it may be value creating an Appeasers Map to visualise an space of land roughly the scale of Crimea overlaid on prime of america. You possibly can drag the form round to see which areas of america you’ll be most ready to present to Russia.
The map even has a obtain button that lets you share your ‘Donald Trump appeasement’ territory’ on social media.
The Boring Technical Bit
The map was created in Maplibre. Sadly Maplibre doesn’t have a local ‘drag’ occasion for polygons. Subsequently to make the polygon draggable on the map, I carried out a simple interplay utilizing MapLibre GL JS’s occasion system.
First, we hear for a mousedown occasion on the polygon’s fill layer, which alerts the beginning of a drag operation. When the person clicks down on the polygon, we set a flag indicating that dragging has began and retailer the preliminary mouse place (startLngLat). This permits us to trace motion relative to the place the drag started.
Because the person strikes the mouse whereas holding down the button (mousemove occasion), we calculate the distinction between the present mouse place and the final recorded place. We then replace the polygon’s coordinates by making use of this offset to every vertex, successfully shifting the polygon’s form on the map. After updating the polygon’s coordinates, we replace the map’s knowledge supply so the adjustments seem in actual time. Lastly, when the person releases the mouse button (mouseup occasion), we clear the dragging flag and reset the cursor fashion, finishing the drag interplay. This strategy permits the person to pull the polygon wherever they need on the map.