Post · 4 min read· pp. 348–350

Map Editor for A* pages

I needed a lightweight map editor for my A* pages, where I’ve been adding some non-grid diagrams. I based this on this project. Drag the nodes. Double click a node to remove. Click a midpoint to divide an edge. Click on a polygon to switch to editing it. Drag the labels around (may not work for the current polygon) to set the “center” point.

diagram

JSON for the A* pages (automatically saved to localStorage):

text
[{"points":[[1,1],[3,1],[4,2],[4,4],[1,4]],"center":[1.5,3]},{"points":[[9,1],[9,6],[7,6],[7,4],[5,4],[5,2],[6,1]],"center":[7,2.5]},{"points":[[10,1],[15,1],[15,7],[14,7],[14,8],[13,7],[12,7],[12,6],[10,6]],"center":[13.5,3.5]},{"points":[[16,1],[20,1],[20,7],[19,7],[19,8],[18,7],[16,7]],"center":[18.5,3.5]},{"points":[[21,1],[25,1],[25,5],[21,5]],"center":[23,3]},{"points":[[30,0],[33,0],[34,2],[34,4]],"center":[32,1]},{"points":[[7,6],[9,6],[9,7],[11,7],[11,8],[10,9],[7,9]],"center":[8.5,8]},{"points":[[10,9],[11,8],[13,8],[13,7],[14,8],[15,8],[15,9],[16,10],[15,10],[15,11],[10,11]],"center":[13.5,9.5]},{"points":[[16,8],[18,8],[18,7],[19,8],[21,8],[21,11],[16,11],[16,10],[15,9],[16,9]],"center":[18.5,9.5]},{"points":[[21,6],[25,6],[25,9],[26,9],[26,10],[25,10],[25,11],[21,11]],"center":[23.5,9.5]},{"points":[[26,5],[33,8],[33,9],[30,10],[27,13],[26,16],[26,10],[26,9]],"center":[27.5,9.5]},{"points":[[26,0],[28,0],[33,5],[33,8],[26,5]],"center":[29.75,4.5]},{"points":[[36,7],[36,2],[35,0],[40,0],[40,7],[37,8]],"center":[38,6]},{"points":[[1,4],[2,4],[2,15],[1,15]],"center":[1.5,11.5]},{"points":[[3,5],[6,5],[6,10],[3,10]],"center":[4.5,8.5]},{"points":[[13,11],[15,11],[15,16],[13,16]],"center":[13.5,13.5]},{"points":[[33.5,13],[34,11],[35,10],[35,8],[36,7],[37,8],[40,7],[40,15]],"center":[37,12]},{"points":[[1,15],[6,15],[6,19],[1,19]],"center":[1.5,16]},{"points":[[7,15],[10,15],[12,16],[12,19],[7,19]],"center":[10,16.5]},{"points":[[13,16],[15,16],[15,19],[13,19]],"center":[14,17]},{"points":[[16,12],[20,12],[20,19],[16,19]],"center":[18,17]},{"points":[[21,12],[25,12],[25,19],[21,19]],"center":[23,15]},{"points":[[26,16],[27,13],[30,10],[33,9],[32,11],[31,12],[30,16],[29,16],[29,17],[30,17],[30,19],[31,20],[26,20]],"center":[28,16]},{"points":[[29,16],[33,16],[33,17],[29,17]],"center":[31,16.5]},{"points":[[32,16],[33.5,13],[40,15],[40,20],[33,20],[32,18],[32,17],[33,17],[33,16]],"center":[34.5,16]},{"points":[[2,11],[2,12],[3,12],[3,14],[9,14],[9,10],[3,10],[3,11]],"center":[4,11.5]},{"points":[[3,1],[4,2],[5,2],[6,1]],"center":[4.5,1.5]},{"points":[[9,2],[9,3],[10,3],[10,2]],"center":[9.5,2.5]},{"points":[[15,3],[15,4],[16,4],[16,3]],"center":[15.5,3.5]},{"points":[[20,2],[20,3],[21,3],[21,2]],"center":[20.5,2.5]},{"points":[[23,5],[23,6],[24,6],[24,5]],"center":[23.5,5.5]},{"points":[[6,17],[6,18],[7,18],[7,17]],"center":[6.5,17.5]},{"points":[[10,12],[10,15],[12,16],[12,14],[13,14],[13,13],[12,13],[12,12]],"center":[11.5,13.5]},{"points":[[15,17],[15,18],[16,18],[16,17]],"center":[15.5,17.5]},{"points":[[20,16],[20,17],[21,17],[21,16]],"center":[20.5,16.5]},{"points":[[23,11],[23,12],[24,12],[24,11]],"center":[23.5,11.5]}]

Quirks: (1) you can’t drag the label for the active polygon because the active polygon is drawn on top; (2) the editor doesn’t show or let you edit the connections between nodes, which turns out to be a problem when you delete a node and they all get renumbered.

List of polygons (in case you can’t click on it directly):

  • 0
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35