1. Home >
  2. Documentation >
  3. data types >
  4. id
 

id

Each item created can be directly accessed or identified on events thanks to a unique id.
If not defined, an auto generated id will be set.

In this example, marker are removed or updated thanks to its id.

id

  • string: The item id
$("#test").gmap3({
  map:{
    options:{
      center:[46.578498,2.457275],
      zoom: 5
    }
  },
  marker:{
    values:[
      {address:"75001, Paris, France", id:"Paris"},
      {address:"86000 Poitiers, France"},
      {address:"66000 Perpignan, France", id: "Perpignan"}
    ],
    options:{
      draggable: false
    },
    events: {
      click: function(marker, event, context){
        markerSelected(context.id);
      }
    }
  }
});

setTimeout(function(){
  $("#map").gmap3({
    clear: {
      id: "Paris"
    }
  });

  var marker = $("#test").gmap3({
    get: {
      id: "Perpignan"
    }
  });
  
  marker.setIcon("http://maps.google.com/mapfiles/marker_orange.png");
}, 2000);
Close