createMarker: function( | lonLat, | | attributes, | | style, | | addMarker | ) |
|
Create a vector marker and add it to the layer. If style is not provided and marker type is not custom, then one of the predefined styles will be used. Predefined marker icon styles are default, blue, green and gold. If style is supplied, this style will override layer style. If no style is available, user may need to provide a style map for showing custom markers when the layer is created.
Parameters
lonLat | {ALKMaps.LonLat} The marker location. |
attributes | {Object} An optional object that will be mapped to the <attributes> property. |
style | {Object} An optional style object. |
addMarker | {Boolean} If it is set to false, the marker will not be added to the layer. |
Note: attributes have following reserved properties
- isMarker - {Boolean} Set to true by the system. Read-only.
- markerType - {String} “green”, “gold”, “blue”, “default”, and “custom”.
- popupSize - {ALKMaps.Size} Popup size
- popupContentHTML - {String} Popup content
- anchor- {Object} Popup anchor such as { size: new ALKMaps.Size(21,25), offset: new ALKMaps.Pixel(-11,-25)}.
- overflow - {String} Popup overflow style such as ‘auto’.
var point = new ALKMaps.LonLat(-74.273297, 39.942892).transform(new ALKMaps.Projection("EPSG:4326"), map.getProjectionObject());
// Uses default marker icon.
var vm = vectorLayer.createMarker(point);
// Uses green marker icon. Predefined icons: blue, green, gold and default.
var vmGreen = vectorLayer.createMarker(point, {markerType: "green"});
// Uses custom style such as layer style map.
var vmCustom = vectorLayer.createMarker(point, {markerType: "custom"});
// Uses this style to override layer level style. Marker type is ignored.
var vmStyle = vectorLayer.createMarker(point, null, {
externalGraphic: ALKMaps.IMAGE.MARKER_BLUE,
graphicHeight: 25,
graphicWidth: 21,
graphicXOffset: -11,
graphicYOffset: -25
});
// Attach popup data to a marker
var vmPopup= vectorLayer.createMarker(point, {markerType: "gold",
popupSize: new ALKMaps.Size(200, 80),
popupContentHTML: "<p><b>Driver status:</b> Dispatched<br/><b>Cell Phone:</b>87654321<br/></p>",
anchor: { size: new ALKMaps.Size(21,25), offset: new ALKMaps.Pixel(-11,-25)},
overflow: 'auto'
});
// ...
// Create popup.
feature.createPopup(true);