Click or drag to resize

Telogis.GeoBase.MapLayers.AbstractObject

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release

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.

JavaScript
// ** 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.

Constructor
NameDescription
MapLayers.AbstractObject(config, beforeAttach)

Arguments

  • config (Object) - Configuration options for the MapLayers.AbstractObject.

    Properties
    NameTypeDescription
    anchorPointPoint

    The point within the object that corresponds to the actual point on the map it is associated with. The coordinates of this point are proportions of the object's width and height, relative to its top-left corner.

    Defaults to new Point (0.5).
    balloonConfigObject

    The configuration object for a context balloon to display when the user mouses over the object. The AbstractDOMEntity.config.id and MapLayers.AbstractObject.config.location configuration properties must be specified in sub-classes, if present (for example in MapLayers.Balloon.config.location). The AbstractDOMEntity.config.events, AbstractDOMEntity.show and AbstractDOMEntity.config.silent properties default to those of the parent object.

    Properties
    NameTypeDescription
    behaviorNumber

    The behavior pattern that determines how the balloon responds to UI events. This may be any meaningful combination of the static behavior flags on the MapLayers.Balloon object.

    contentString

    The HTML or text to display in the balloon.

    contentFuncFunction

    A function to provide the content of the balloon, which will be re-evaluated each time the balloon is shown. This should take no arguments, and return an HTML string. Either content or contentFunc should be provided, not both.

    Returns

    String - The HTML string to populate the balloon with.

    hAlignNumber

    The horizontal alignment of the balloon relative to its target element. Valid values for this are MapLayers.Balloon.ALIGN_LEFT and MapLayers.Balloon.ALIGN_RIGHT.

    locationLatLon

    The location on the map that the balloon should originate from. Location must be specified in sub-classes if present (for example in MapLayers.Balloon.config.location).

    showBoolean

    Whether the balloon should be initially shown.

    skinMapLayers.BalloonSkin

    A reference to the skin to use for the balloon. Several of these are pre-defined as static properties of the MapLayers.BalloonSkin object.

    vAlignString

    The vertical alignment of the balloon relative to its target element. Valid values for this are MapLayers.Balloon.ALIGN_TOP and MapLayers.Balloon.ALIGN_BOTTOM.

    dragEnabledBoolean

    Whether the object can be dragged by the mouse. Defaults to false.

    layerString

    The string identifier of the MapLayers.ObjectLayer to add the object to. Alternatively, a reference to the layer itself can be passed. If you don't want to explicitly use a MapLayers.ObjectLayer, pass a map ID or reference here and the object will be added to a base layer implicitly created with the map.

    This property may also be referenced by the name: parent or map.
    locationLatLon

    The latitude-longitude coordinates to create the object at.

    mapString

    The map on which to create the layer, or its ID.

    This property may also be referenced by the name: parent or layer.
    sizeSize

    The dimensions to display the object with. Defaults to 24x24.

  • (Optional)beforeAttach (Function) - An optional callback to be executed (in arbitrary scope) after the object's element is created, but before it is attached to the document's DOM tree. Appropriate specification of this function can avoid unnecessary DOM reflows. Defaults to function () {}.

Functions
NameDescription
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.

Returns

Point - 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.

Returns

Point - 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.

Returns

MapLayers.Balloon - The balloon belonging to the map object.

getHeading ()

Finds the fixed heading of an object on the map.

Returns

Number - The fixed heading of the object.

getLocation ()

Finds the location in latitude-longitude coordinates of the object on the map.

Returns

LatLon - The location of the object.

getScale ()

Returns the current scale of the object.

Returns

Number - The scale of the object.

getSize ()

Finds the size of the object on the map.

Returns

Size - 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.

Returns

Boolean - True if the object is drag-enabled; false otherwise.

moveBy (Point delta)

Moves the object relative to its previous location.

Arguments
  • delta (Point) - The offset to move the object by, in pixels.

setAnchorPoint (Point newAnchorPoint)

Changes the point on the object that should align with its designated map location.

Arguments
  • newAnchorPoint (Point) - The point on the element to use. The coordinates of this point are proportions of the object's width and height, relative to its top-left corner.

setDragCursor (String css)

Sets the CSS cursor attribute used by MapLayers.AbstractObject elements when they are drag-enabled.

Arguments
  • (Optional) css (String) - The CSS string to set the cursor attribute to. Defaults to 'pointer'.

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
  • value (Boolean) - True if the object should be drag-enabled; false otherwise.

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
  • newHeading (Number) - The heading to fix the object at, in degrees.

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
  • (Optional) newPos (Point or LatLon) - The location to place the object at. This may be specified as a pair of x-y pixel coordinates on the map, or as a latitude-longitude location. Defaults to this.getLocation().

  • (Optional) newLoc (LatLon) - the pre-calculated latitude-longitude location of the object, if a pre-calculated pixel position is also being used. Defaults to this.getLocation().

setScale (Number newScale)

Changes the scale of the object on the map.

Arguments
  • newScale (Number) - The scale of the object. A scale of 1 represents the objects original size.

setSize (Size newSize)

Changes the size of the object on the map. The anchor-point is scaled appropriately along with the size.

Arguments
  • newSize (Size) - The dimensions of the object, in pixels.

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
  • updateType (Number) - The flag or combination of flags specifying the type of update that has occurred. Each of these may be any of the static Map.UPDATE_* values.

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
  • callback (Function) - The function to execute (in the scope of the object) when the object has been added to a layer.

Properties
NameTypeDescription
AddedEventHandler

Triggered when the object is added to the map.

DragEventHandler

Triggered when the object is picked up to be dragged to a new location on the map.

EndDragEventHandler

Triggered when the dragged object is dropped in its new location on the map.

EVENT_ADDEDNumber

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_DRAGNumber

A flag that enables or disables the MapLayers.AbstractObject.Drag event handler.

EVENT_END_DRAGNumber

A flag that enables or disables the MapLayers.AbstractObject.EndDrag event handler.

EVENT_MOVENumber

A flag that enables or disables the MapLayers.AbstractObject.Move event handler.

EVENT_REMOVEDNumber

A flag that enables or disables the MapLayers.AbstractObject.Removed event handler.

layerMapLayers.ObjectLayer

The map layer to which the object is currently attached.

MoveEventHandler

Triggered when the object is moved by dragging, or using the MapLayers.AbstractObject.SetLocation method.

RemovedEventHandler

Triggered when the object is removed or deleted from the map.