HMPlot

Dragging cities on a map

Drag a city on a Mercator map: the drag goes back through the projection and writes offsets in degrees; the point and its label both read moved().

Drag a city on a Mercator map: the drag goes back through the projection and writes offsets in degrees; the point and its label both read moved().

Static preview; loading the interactive plot

<Data value={cities} key="name">
  <Plot type="2d" coordinates="spherical" projection="mercator"
    x={{ domain: [-180, 180], visible: false }} y={{ domain: [-60, 75], visible: false }}>
    <GeoJSON data={countries} fill="#d8dde3" />
    <Points x={moved("lon")} y={moved("lat")} fill="#d62728" drag />
    <Text x={moved("lon")} y={moved("lat")} text="name" dy={14} />
  </Plot>
</Data>