demo: https://allyoucanmap.github.io/map-station/index.html
-
MapStation.mapAsteroids(selector, options);
asteroids game [A] -
MapStation.mapSnake(selector, options);
snake game [S] -
arguments
selector
{string}options
{object}:featureCollection
{object} Polygon and MultiPolygon GeoJSONpropertyName
{string} property of feature to display as labelprojection
{function} must return an array of coordinares [x, y], examplefunction(coords) { return [coords[1], coords[0]];}
controlsKeys
{object} array of controls objectsflipYCoords
{boolean} flip y coordinateswarpPole
{boolean} [S] if true snake will warp between poles
-
.mapAsteroids
left
rotate leftright
rotate rightup
movebuttonA
fire
-
.mapSnake
up
move upright
move rightdown
move downleft
move left
-
default controlKeys
:
[
{ name: 'left', code: 65 }, // a
{ name: 'right', code: 68 }, // d
{ name: 'up', code: 87 }, // w
{ name: 'down', code: 83 }, // s
{ name: 'buttonA', code: 32 }, // spacebar
{ name: 'buttonB', code: 77 }, // m
{ name: 'start', code: 13 }, // enter
{ name: 'select', code: 27} // esc
]
<body>
<div id="container"></div>
<script src="dist/map-station.js"></script>
<script>
fetch('my-polygon.geo.json')
.then(function (res) {
res.json()
.then(function (featureCollection) {
MapStation.mapAsteroids(
'#container'
{ featureCollection }
);
})
});
</script>
</body>
Work only with Polygon
and MultiPolygon
feature
npm install
npm start
-> http://localhost:3000
country.geo.json data from https://github.com/johan/world.geo.json