Telogis.GeoBase.MapLayers.AbstractObject |
MapLayers.AbstractObject inherits from AbstractDOMEntity.
An abstract class for map objects that can be displayed in a MapLayers.ObjectLayer. Should not typically be called directly, but instead inherited by objects created using MapLayers.ImageObject and MapLayers.IndexedImageObject.
// ** This example displays a balloon on a map. The balloon text, when clicked, will trigger a function (an alert). // At the top of your .aspx file, add a script reference to "/scripts/skin.balloon.greygradient.js". This defines a default balloon skin style. // Create a Telogis.GeoBase.MapLayers.BalloonSkin with default properties to apply to AbstractObject.config.balloonConfig.skin. var myBalloonSkin = new Telogis.GeoBase.MapLayers.BalloonSkin(); // Create content and an arbitrary function to call using AbstractObject.config.balloonConfig.contentFunc var newDiv = document.createElement('Div'); newDiv.appendChild(document.createTextNode('Click Me')); newDiv.onclick = function() {alert('You clicked the balloon!')}; // Click the balloon to activate an alert // Create an AbstractObject instance on the map ('map') with a balloon containing text // No image (src) can be specified: use Telogis.GeoBase.MapLayers.ImageObject for this functionality. // AbstractObject is typically used only to provide inheritance. var myAbstractObject = new Telogis.GeoBase.MapLayers.AbstractObject({ anchorPoint: new Telogis.GeoBase.Point(0.5,0.0), balloonConfig: { //content: 'This is plain text', // Text content for the balloon. // --- either content or contentFunc should be used, not both contentFunc: function() {return newDiv}, // A function to provide balloon content as HTML show: true, // Show on initial loading hAlign: Telogis.GeoBase.MapLayers.Balloon.ALIGN_RIGHT, // Horizontal alignment of the balloon vAlign: Telogis.GeoBase.MapLayers.Balloon.ALIGN_BOTTOM, // Vertical alignment of the balloon skin: myBalloonSkin // The skin to apply to the balloon }, dragEnabled: false, location: new Telogis.GeoBase.LatLon(33.587137,-117.742878), // The location (Los Angeles). Overridden if also specified in balloonConfig map: map, // May also be referenced as 'parent'. This example assumes a map named 'map' exists });
See MapLayers.BalloonSkin for an example of customising a balloon skin.
Name | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
MapLayers.AbstractObject(config, beforeAttach) | Arguments
|
Name | Description |
---|---|
destroy () | Discards the object, freeing all its allocated resources. |
disableDrag () | Forbids the MapLayers.AbstractObject from being dragged by the mouse. |
enableDrag () | Allows the MapLayers.AbstractObject to be dragged with the mouse. |
getAnchorPixels () | Finds the point on the object that aligns with its designated map location, in pixels. ReturnsPoint - The anchor point of the object. The coordinates of this point are pixel offsets from the object's top-left corner. |
getAnchorPoint () | Finds the point on the object that aligns with its designated map location. ReturnsPoint - The anchor point of the object. The coordinates of this point are proportions of the object's width and height, relative to its top-left corner. |
getBalloon () | Finds a reference to the balloon associated with the map object, if applicable. ReturnsMapLayers.Balloon - The balloon belonging to the map object. |
getHeading () | Finds the fixed heading of an object on the map. ReturnsNumber - The fixed heading of the object. |
getLocation () | Finds the location in latitude-longitude coordinates of the object on the map. ReturnsLatLon - The location of the object. |
getScale () | Returns the current scale of the object. ReturnsNumber - The scale of the object. |
getSize () | Finds the size of the object on the map. ReturnsSize - The dimensions of the object, in pixels. |
hide () | An override for the base class's AbstractDOMEntity.hide method, which also hides the MapLayers.AbstractObject's balloon, if applicable. If the balloon was present and was showing when the object was hidden, it is queued to be re-shown when the object becomes visible again. |
isDragEnabled () | Finds whether the MapLayers.AbstractObject can be dragged on its map by holding the left mouse button down. ReturnsBoolean - True if the object is drag-enabled; false otherwise. |
moveBy (Point delta) | Moves the object relative to its previous location. Arguments
|
setAnchorPoint (Point newAnchorPoint) | Changes the point on the object that should align with its designated map location. Arguments
|
setDragCursor (String css) | Sets the CSS cursor attribute used by MapLayers.AbstractObject elements when they are drag-enabled. Arguments
|
setDragEnabled (Boolean value) | Sets whether the MapLayers.AbstractObject should be able to be dragged on its map by holding the left mouse button down, and updates its CSS cursor property to reflect this. Arguments
|
setHeading (Number newHeading) | Sets the heading of the image at the defined angle, in degrees. The default value, null, indicates that the image will be rotated with the map. Arguments
|
setLayer (Widgets.Map newLayer) | Sets or changes the object layer to which the object is attached, and performs appropriate initializations once having done so. Arguments
|
setLocation (Point newPos, LatLon newLoc) | Repositions the element used to display the MapLayers.AbstractObject. Arguments
|
setScale (Number newScale) | Changes the scale of the object on the map. Arguments
|
setSize (Size newSize) | Changes the size of the object on the map. The anchor-point is scaled appropriately along with the size. Arguments
|
show () | Shows the object on its layer. |
update (Number updateType) | A callback that is executed whenever the MapLayers.ObjectLayer that contains the MapLayers.AbstractObject is updated, and the object remains visible upon it. This can be used to adjust instances of derived classes appropriately when certain map events occur. Arguments
|
whenAdded (Function callback) | Executes a function immediately if the object has been added to a layer. If it has not, the function is queued to be called when the object's MapLayers.AbstractObject.Added event handler is triggered. Arguments
|
Name | Type | Description |
---|---|---|
Added | EventHandler | Triggered when the object is added to the map. |
Drag | EventHandler | Triggered when the object is picked up to be dragged to a new location on the map. |
EndDrag | EventHandler | Triggered when the dragged object is dropped in its new location on the map. |
EVENT_ADDED | Number | A flag that enables or disables the MapLayers.AbstractObject.Added event handler. All event handlers are enabled by default, but you can improve performance by disabling event handlers that will not be used. |
EVENT_DRAG | Number | A flag that enables or disables the MapLayers.AbstractObject.Drag event handler. |
EVENT_END_DRAG | Number | A flag that enables or disables the MapLayers.AbstractObject.EndDrag event handler. |
EVENT_MOVE | Number | A flag that enables or disables the MapLayers.AbstractObject.Move event handler. |
EVENT_REMOVED | Number | A flag that enables or disables the MapLayers.AbstractObject.Removed event handler. |
layer | MapLayers.ObjectLayer | The map layer to which the object is currently attached. |
Move | EventHandler | Triggered when the object is moved by dragging, or using the MapLayers.AbstractObject.SetLocation method. |
Removed | EventHandler | Triggered when the object is removed or deleted from the map. |