(Minor) returnjson should be local to the `if (mapdatamode)` block; it's not used outside that.