0

I'm using jvectormap and I noticed that map data is actually accumulating on each call. For example, if there was 1 from spain, and on next load there is 1 from Italy, on 2nd map load it show 1 Spain and 1 Italy and so on.

var singlemap = $('#singleMap').vectorMap({
    map: 'world_en',
    backgroundColor: null,
    color: '#eaeaea',
    hoverOpacity: 0.7,
    //selectedColor: '#666666',
    enableZoom: false,
    showTooltip: true,
    values: {

    },
    scaleColors: ['#6FC6EA', '#0A4D70'],
    normalizeFunction: 'polynomial'
});

I'm using setValues as below for reloading data, how can I clear data from map before showing new?

singlemap.setValues(mapstringJSON);
Googlian
  • 6,077
  • 3
  • 38
  • 44
user3399805
  • 39
  • 1
  • 9

1 Answers1

1

I found solution, on each setvalue i empty the html in div and set singlemap to null and then initialize the map again, before seting values.

$('#singleMap').empty();
singlemap = null;
singlemap = $('#singleMap').vectorMap({
  map: 'world_en',
  backgroundColor: null,
  color: '#eaeaea',
  hoverOpacity: 0.7,
  enableZoom: false,
  showTooltip: true,
  values: {},
  scaleColors: ['#6FC6EA', '#0A4D70'],
  normalizeFunction: 'polynomial'
});
singlemap.setValues(mapstringJSON);
user3399805
  • 39
  • 1
  • 9