Giter VIP home page Giter VIP logo

leaflet-tracksymbol2's People

Contributors

ngyewch avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

leaflet-tracksymbol2's Issues

Cannot read properties of null (reading 'toString')

aismaps.js:40 Error fetching AIS data: TypeError: Cannot read properties of null (reading 'toString')
    at Ei (aisTrackSymbol.ts:373:25)
const aisItem = {
    "id": 373001,
    "sensor_data_id": 419208,
    "vessel_id": 1222,
    "latitude": "-9.6449217",
    "longitude": "114.7692100",
    "speed": "11.50",
    "course": 54,
    "heading": 53,
    "navigation_status": "Under way using engine",
    "turning_rate": 0,
    "is_inside_geofence": null,
    "turning_direction": 1,
    "timestamp": "2023-12-13 04:20:48",
    "distance": "513.63",
    "created_at": "2023-12-13T04:20:48.000000Z",
    "updated_at": "2023-12-13T04:20:48.000000Z",
    "vessel": {
        "id": 1222,
        "vessel_name": null,
        "vessel_type": null,
        "mmsi": "636093023",
        "imo": null,
        "callsign": null,
        "draught": null,
        "dimension_to_bow": null,
        "dimension_to_stern": null,
        "dimension_to_port": null,
        "dimension_to_starboard": null,
        "reported_destination": null,
        "out_of_range": "0",
        "type_number": null,
        "reported_eta": null,
        "created_at": "2023-12-13T04:20:48.000000Z",
        "updated_at": "2023-12-13T04:20:48.000000Z"
    },
    "sensor_data": {
        "id": 419208,
        "sensor_id": 1,
        "payload": "!ABVDM,1,1,,B,19N`2Gh0Ak8=GjerNjej61cN00Ra,0*02",
        "timestamp": "2023-12-13 04:20:48",
        "created_at": "2023-12-13T04:20:48.000000Z",
        "updated_at": "2023-12-13T04:20:48.000000Z",
        "sensor": {
            "id": 1,
            "datalogger_id": 1,
            "name": "AIS",
            "status": "Active",
            "interval": 5,
            "jarak": 20,
            "jumlah_data": 200,
            "created_at": "2023-12-02T09:16:49.000000Z",
            "updated_at": "2023-12-02T09:16:49.000000Z",
            "datalogger": {
                "id": 1,
                "name": "Datalogger 1",
                "serial_number": "DL001",
                "latitude": "-6.2256992",
                "longitude": "106.8503082",
                "status": "Online",
                "installation_date": "2022-01-01",
                "last_online": "2023-05-24 12:34:56",
                "coverage": null,
                "created_at": "2023-12-02T09:16:49.000000Z",
                "updated_at": "2023-12-02T09:16:49.000000Z"
            }
        }
    }
};
const p1 = [+aisItem.latitude || 0, +aisItem.longitude || 0];
        const trueHeading1 = aisItem.heading || 0;
        const cog1 = aisItem.course || 0;
        const sog1 = +aisItem.speed || 0;

        // Creating the PositionReport
        let positionReport1 = {
            latitude: p1[0],
            longitude: p1[1],
            trueHeading: trueHeading1,
            cog: cog1,
            sog: sog1,
        };

        const aisTrackSymbol = new L.AISTrackSymbol(positionReport1, {
            shipStaticData: {
                userId: aisItem.vessel.id || 0,
                imoNumber: aisItem.vessel.imo || 0,
                callSign: aisItem.vessel.callsign || "",
                name: aisItem.vessel.vessel_name || "",
                type: aisItem.vessel.type_number || 0,
                dimension: {
                    A: aisItem.vessel.dimension_to_bow || 0,
                    B: aisItem.vessel.dimension_to_stern || 0,
                    C: aisItem.vessel.dimension_to_port || 0,
                    D: aisItem.vessel.dimension_to_starboard || 0,
                },
                fixType: aisItem.vessel.out_of_range || 0,
                eta: {
                    month: aisItem.vessel.reported_eta
                        ? new Date(aisItem.vessel.reported_eta).getMonth() + 1
                        : null,
                    day: aisItem.vessel.reported_eta
                        ? new Date(aisItem.vessel.reported_eta).getDate()
                        : null,
                    hour: aisItem.vessel.reported_eta
                        ? new Date(aisItem.vessel.reported_eta).getHours()
                        : null,
                    minute: aisItem.vessel.reported_eta
                        ? new Date(aisItem.vessel.reported_eta).getMinutes()
                        : null,
                },
                destination: aisItem.vessel.reported_destination || "",
                dte: aisItem.vessel.dte === "1",
            },
        });
        aisTrackSymbol.bindTooltip(aisItem.vessel.vessel_name || "");
        aisTrackSymbol.addTo(map);

Tasks

No tasks being tracked yet.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.