How to use the navigation.speedOverGround function in navigation

To help you get started, we’ve selected a few navigation examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vokkim / tuktuk-chart-plotter / src / client / map.js View on Github external
vesselData.onValue(({vesselData, settings}) => {
    const position = vesselData['navigation.position']
    if (position) {
      const newPos = [position.latitude, position.longitude]
      myVessel.setLatLng(newPos)
    }

    const course =
      settings.course === COG ? vesselData['navigation.courseOverGroundTrue'] : vesselData['navigation.headingTrue']
    if (course) {
      myVessel.setRotationAngle(toDegrees(course))
    } else {
      myVessel.setRotationAngle(0)
    }

    const speed = vesselData['navigation.speedOverGround']
    const extensionLineCoordinates = calculateExtensionLine(position, course, speed, settings.extensionLine)
    if (extensionLineCoordinates) {
      pointer.setLatLngs([extensionLineCoordinates.start, extensionLineCoordinates.end])
      pointerEnd.setLatLng(extensionLineCoordinates.end)
    } else {
      pointer.setLatLngs([[0, 0], [0, 0]])
      pointerEnd.setLatLng([0, 0])
    }
    if (settings.follow && (extensionLineCoordinates || position)) {
      const to = extensionLineCoordinates ? extensionLineCoordinates.middle : [position.latitude, position.longitude]
      if (map.getCenter().distanceTo(to) > 100) {
        map.panTo(to)
      }
    }
  })