Skip to main content
English usage; removed unrelated tag
Source Link
Vince
  • 20.3k
  • 16
  • 48
  • 65

I would like to use two layers (units, calls) over the streets base map.

I have a timer loop that runs every 30 seconds and iI would like to clear the units layer, then add the new unit markers to the unit layer.

  var units = new Graphic();  // graphic with units
  var calls = new Graphic();  // graphic with calls


  map = new Map({
    basemap: "streets-navigation-vector"
  });

  view = new MapView({
    container: "viewDiv",
    map: map,
    zoom: 12,
    center: {
      latitude: 38.8935,
      longitude: -77.0487
    }
  });


  var unitsLayer = new GraphicsLayer({
    graphics: [units]
  });

  var callsLayer = new GraphicsLayer({
    graphics: [calls]
  });


  map.add(unitsLayer);
  map.add(callsLayer);
  • Question 1) How do iI clear a layer of markers without effecting the other layers?
  • Question 2) How do iI add a marker to the units layer at run time?

I would like to use two layers (units, calls) over the streets base map.

I have a timer loop that runs every 30 seconds and i would like to clear the units layer, then add the new unit markers to the unit layer.

  var units = new Graphic();  // graphic with units
  var calls = new Graphic();  // graphic with calls


  map = new Map({
    basemap: "streets-navigation-vector"
  });

  view = new MapView({
    container: "viewDiv",
    map: map,
    zoom: 12,
    center: {
      latitude: 38.8935,
      longitude: -77.0487
    }
  });


  var unitsLayer = new GraphicsLayer({
    graphics: [units]
  });

  var callsLayer = new GraphicsLayer({
    graphics: [calls]
  });


  map.add(unitsLayer);
  map.add(callsLayer);
  • Question 1) How do i clear a layer of markers without effecting the other layers?
  • Question 2) How do i add a marker to the units layer at run time?

I would like to use two layers (units, calls) over the streets base map.

I have a timer loop that runs every 30 seconds and I would like to clear the units layer, then add the new unit markers to the unit layer.

  var units = new Graphic();  // graphic with units
  var calls = new Graphic();  // graphic with calls


  map = new Map({
    basemap: "streets-navigation-vector"
  });

  view = new MapView({
    container: "viewDiv",
    map: map,
    zoom: 12,
    center: {
      latitude: 38.8935,
      longitude: -77.0487
    }
  });


  var unitsLayer = new GraphicsLayer({
    graphics: [units]
  });

  var callsLayer = new GraphicsLayer({
    graphics: [calls]
  });


  map.add(unitsLayer);
  map.add(callsLayer);
  • Question 1) How do I clear a layer of markers without effecting the other layers?
  • Question 2) How do I add a marker to the units layer at run time?
Source Link

Adding markers to a layer at runtime

I would like to use two layers (units, calls) over the streets base map.

I have a timer loop that runs every 30 seconds and i would like to clear the units layer, then add the new unit markers to the unit layer.

  var units = new Graphic();  // graphic with units
  var calls = new Graphic();  // graphic with calls


  map = new Map({
    basemap: "streets-navigation-vector"
  });

  view = new MapView({
    container: "viewDiv",
    map: map,
    zoom: 12,
    center: {
      latitude: 38.8935,
      longitude: -77.0487
    }
  });


  var unitsLayer = new GraphicsLayer({
    graphics: [units]
  });

  var callsLayer = new GraphicsLayer({
    graphics: [calls]
  });


  map.add(unitsLayer);
  map.add(callsLayer);
  • Question 1) How do i clear a layer of markers without effecting the other layers?
  • Question 2) How do i add a marker to the units layer at run time?