| | |
| | | let newLat = lat |
| | | |
| | | switch (direction) { |
| | | case 'W': // 向前(heading 方向) |
| | | case 'KeyW': // 向前(heading 方向) |
| | | newLon += moveStep * Math.sin(headingRad) |
| | | newLat += moveStep * Math.cos(headingRad) |
| | | break |
| | | |
| | | case 'S': // 向后(反方向) |
| | | case 'KeyS': // 向后(反方向) |
| | | newLon -= moveStep * Math.sin(headingRad) |
| | | newLat -= moveStep * Math.cos(headingRad) |
| | | break |
| | | |
| | | case 'D': // 向右(heading + 90°) |
| | | case 'KeyD': // 向右(heading + 90°) |
| | | newLon += moveStep * Math.cos(headingRad) |
| | | newLat -= moveStep * Math.sin(headingRad) |
| | | break |
| | | |
| | | case 'A': // 向左(heading - 90°) |
| | | case 'KeyA': // 向左(heading - 90°) |
| | | newLon -= moveStep * Math.cos(headingRad) |
| | | newLat += moveStep * Math.sin(headingRad) |
| | | break |