miguelgfierro / ai_projects

AI projects
https://miguelgfierro.com/
Other
773 stars 175 forks source link

amcharts shows only the last event, not all the previous ones #89

Closed miguelgfierro closed 5 years ago

miguelgfierro commented 5 years ago
    var mapLocations = [];
    // Based on https://www.amcharts.com/demos/custom-html-elements-map-markers/ 
    var map = AmCharts.makeChart("chartdiv", {
        "type": "map",
        "theme": "none",
        "projection": "miller",
        "imagesSettings": {
            "rollOverColor": "#089282",
            "rollOverScale": 3,
            "selectedScale": 3,
            "selectedColor": "#089282",
            "color": "#13564e"
        },
        "areasSettings": {
            "unlistedAreasColor": "#222222" /* change color of the map */
        },
        "dataProvider": {
            "map": "worldLow",
            "images": mapLocations
        },
    });
    // Location updated emitted by the server via websockets
    socket.on("map_update", function (msg) {
        var message = "New event in " + msg.title + " (" + msg.latitude
            + "," + msg.longitude + ")";
        console.log(message);
        newLocation = new Location(msg.title, msg.latitude, msg.longitude);
        mapLocations.push(newLocation);
        map.dataProvider.images = mapLocations;
        map.validateData(); //call to redraw the map with new data
    });

With this code, only the latest location that is sent with the websocket is shown in the map. Even though if I log map I see an array of locations inside map.dataProvider.images

miguelgfierro commented 5 years ago

Sent a request for support: https://amcharts.zendesk.com/hc/en-us/requests/38417