- Home >
- Documentation >
- data types >
- tag
tag
Each item created can be accessed or identified on events thanks to tags.
tag
Tag can be
- string
- array of string
- a function which return an array of string
In this example, marker are automatically generated with 2 tags (letter / color) and then, some of them are removed.
var colors = "black brown green purple yellow grey orange white".split(" "), letters = "A B C D E F".split(" "); $("#test").gmap3({ map:{ options:{ zoom: 2, mapTypeId: google.maps.MapTypeId.TERRAIN }, onces: { bounds_changed: function(){ var $this = $(this), bounds = $this.gmap3("get").getBounds(), southWest = bounds.getSouthWest(), northEast = bounds.getNorthEast(), lngSpan = northEast.lng() - southWest.lng(), latSpan = northEast.lat() - southWest.lat(), i, color, letter; for (i = 0; i < 50; i++) { letter = letters[Math.floor(Math.random() * letters.length)]; color = colors[Math.floor(Math.random() * colors.length)]; $this.gmap3({ marker:{ latLng:[southWest.lat() + latSpan * Math.random(), southWest.lng() + lngSpan * Math.random()], options:{ icon: "http://maps.google.com/mapfiles/marker_"+color+letter+".png" }, tag:[color, letter] } }); } } } } }); setTimeout(function(){ $("#test").gmap3({ clear:{ name:"marker", tag: ["black", "brown", "green", "purple", "A", "B", "C"], all: true } }); }, 3000);