Click or drag to resize

Telogis.GeoBase.MapLayers.BalloonSkin

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

MapLayers.BalloonSkin inherits from Skin.

A simple class that combines all the information describing the appearance of a balloon. Several predefined instances are available as static properties of the MapLayers.BalloonSkin class, and can be used to theme balloons reasonably painlessly.

JavaScript
var myBalloonSkin = new Telogis.GeoBase.MapLayers.BalloonSkin({
    bodyStyle: { // specify the style of the balloon and its text
        backgroundColor: "#ffffff",
        border:          "1px solid black",
        color:           "#000000",
        fontFamily:      "sans-serif",
        fontSize:        "20px",
        fontWeight:      "normal",
        padding:         "10px",
        textAlign:       "center",
        verticalAlign:   "middle",
        width:           "150px"
    },
    folder: "images/skins/balloon/directedwhite", // specify the default images folder
    tagAnchorPoint: new GeoBase.Point(0.0, 1.0), // specify the bottom-left image position
    tagOverlap: 1, // adjust the vertical position of the balloon tag (move bottom-left image and tag closer/further apart)
    bottomLeftTagSrc: 'tag-bottom-left.png', // image used for bottom-left balloon tag corner (relative to 'folder')
    bottomRightTagSrc: 'tag-bottom-right.png', // image used for bottom-right balloon tag corner
    topLeftTagSrc: 'tag-top-left.png', // image used for top-left balloon tag corner
    topRightTagSrc: 'tag-top-right.png' // image used for top-right balloon tag corner
});
Constructor
NameDescription
MapLayers.BalloonSkin(config)

Arguments

  • config (Object) - The configuration options for the balloon skin.

    Properties
    NameTypeDescription
    bodyStyleObject

    The collection of CSS/JavaScript style properties to apply to the body element of the balloon, which will hold its content. All properties except 'position' are customizable.

    Defaults to {}. Properties
    NameTypeDescription
    backgroundColorString

    The background color of the balloon skin, for example "#ffffff"

    borderString

    The width and color of the balloon skin border, for example "2px solid red"

    colorString

    The color of the balloon skin, for example "#000000"

    fontFamilyString

    The font family used by the balloon skin, for example "sans-serif"

    fontSizeString

    The font size used by the balloon skin, for example "8px"

    fontWeightString

    The font weight used by the balloon skin, for example "bold"

    paddingString

    The size of the padding around the balloon skin, for example "10px"

    textAlignString

    The balloon skin's horizontal text alignment, for example "center"

    verticalAlignString

    The balloon skin's vertical text alignment, for example "middle"

    widthString

    The balloon skin's width, for example "200px"

    bottomLeftTagSrcString

    The image path (relative to MapLayers.BalloonSkin.config.folder) to load the balloon's tag image from when the balloon is bottom-left aligned. All tag images should be the same size.

    Defaults to 'tag-bottom-left.png'.
    bottomRightTagSrcString

    The image path (relative to MapLayers.BalloonSkin.config.folder) to load the balloon's tag image from when the balloon is bottom-right aligned. All tag images should be the same size.

    Defaults to 'tag-bottom-right.png'.
    folderString

    An optional folder path to prepend to each tag image URLs (saving repetitive directory specification).

    Defaults to ''.
    tagAnchorPointPoint

    The offset within the tag image for top-right alignment of the point that corresponds to the location on the map marked by the balloon. This is transformed appropriately for other alignments. The coordinates of this point are proportions of the tag image's width and height, relative to its top-left corner.

    Defaults to new Point (0.0, 1.0).
    tagOverlapNumber

    The number of pixels by which the tag should overlap the bottom of the balloon's content area (hiding its border, if applicable).

    Defaults to 1.
    topLeftTagSrcString

    The image path (relative to MapLayers.BalloonSkin.config.folder) to load the balloon's tag image from when the balloon is top-left aligned. All tag images should be the same size.

    Defaults to 'tag-top-left.png'.
    topRightTagSrcString

    The image path (relative to MapLayers.BalloonSkin.config.folder) to load the balloon's tag image from when the balloon is top-right aligned. All tag images should be the same size.

    Defaults to 'tag-top-right.png'.
Functions
NameDescription
applyBodyStyle (Element elem)

Applies each of the skin's body styles (specified at construction with the MapLayers.BalloonSkin.config.bodyStyle property) to a given DOM element. These will override any existing style information.

Arguments
  • elem (Element) - The DOM element to apply the skin's body style to.

getTagAnchorPixels (Number hAlign, Number vAlign, Boolean horizontal)

Calls MapLayers.BalloonSkin.getTagAnchorPixels and converts the result to a pixel offset from the tag image's top-left corner.

Arguments
  • hAlign (Number) - The enumerated value specifying the horizontal positioning of the balloon for which the tag anchor point is being calculated.

  • vAlign (Number) - The enumerated value specifying the vertical positioning of the balloon for which the tag anchor point is being calculated.

  • horizontal (Boolean) - True if the balloon has horizontal alignment, false if it has vertical alignment

Returns

Point - The offset of the point in the tag image for the given alignment that should align to the balloon's target element. The coordinates of this point are pixel offsets relative to the image's top-left corner.

getTagAnchorPoint (Number hAlign, Number vAlign, Boolean horizontal)

Transforms the tag anchor point -- specified at skin construction -- to be representative of the tag image at the given alignment (the original specification is for the top-right-aligned tag).

Arguments
  • hAlign (Number) - The enumerated value specifying the horizontal positioning of the balloon for which the tag anchor point is being calculated.

  • vAlign (Number) - The enumerated value specifying the vertical positioning of the balloon for which the tag anchor point is being calculated.

  • horizontal (Boolean) - True if the balloon has horizontal alignment, false if it has vertical alignment

Returns

Point - The offset of the point in the tag image for the given alignment that should align to the balloon's target element. The coordinates of this point are proportions of the tag image's width and height, relative to its top-left corner.

getTagOverlap ()

Finds the number of pixels by which the tag should overlap the content area of the balloon, hiding its border (if applicable).

JavaScript
var myBalloonSkin = new Telogis.GeoBase.MapLayers.BalloonSkin({
    tagOverlap: 1, // adjust the vertical position of the balloon tag (move bottom-left image and tag closer/further apart)
});

// Get the tag overlap
alert('Tag overlap is '+ myBalloonSkin.getTagOverlap()+' pixel(s)');
// 'Tag overlap is 1 pixel(s)'
Returns

Number - The pixel overlap of the top of the tag image over the bottom of the content element.

getTagSize (Boolean horizontal)

Finds the pixel dimensions of the tag image described by the skin. These are taken from the top-right tag image, and are assumed to be the same for all other alignments.

JavaScript
var myBalloonSkin = new Telogis.GeoBase.MapLayers.BalloonSkin({
    bodyStyle: { // specify the style of the balloon and its text
        backgroundColor: "#ffffff",
        border:          "1px solid black",
        color:           "#000000",
        fontFamily:      "sans-serif",
        fontSize:        "20px",
        fontWeight:      "normal",
        padding:         "10px",
        textAlign:       "center",
        verticalAlign:   "middle",
        width:           "150px"
    },
    folder: "images/skins/balloon/directedwhite" // specify the default images folder
});

alert('Tag size is '+ myBalloonSkin.getTagSize(true)+' pixels');
// 'Tag size is 8x8 pixels'
// Note that this is using the default images included in the 'directedwhite' folder
// of a standard SDK installation
Arguments
  • horizontal (Boolean) - True if the balloon has horizontal alignment, false if it has vertical alignment

Returns

Size - The width and height of the tag image.

getTagSrc (Number hAlign, Number vAlign, Boolean horizontal)

Finds the appropriate tag image to use with a given balloon alignment.

JavaScript
var myBalloonSkin = new Telogis.GeoBase.MapLayers.BalloonSkin({
    // Set the image folder location
    folder: "myImageFolder/skins/balloon", // specify the default images folder
    // Specify a tag corner image
    bottomLeftTagSrc: 'myBottomLeftImage.png', // image used for bottom-left balloon tag corner (relative to 'folder')
});

var Balloon    = Telogis.GeoBase.MapLayers.Balloon;

// Call getTagSrc function for bottom-left tag image
alert('Tag source of the bottom-left tag image (horizontal alignment) is '+
    // Accepts 'ALIGN_LEFT', 'ALIGN_RIGHT', 'ALIGN_TOP', 'ALIGN_BOTTOM'
    myBalloonSkin.getTagSrc(Balloon.ALIGN_LEFT, Balloon.ALIGN_BOTTOM, true));
    // 'Tag source of the bottom-left tag image (horizontal alignment)
    // is myImageFolder/skins/balloon/myBottomLeftImage.png'
Arguments
  • hAlign (Number) - The enumerated value specifying the alignment of the balloon in the horizontal direction.

  • vAlign (Number) - The enumerated value specifying the alignment of the balloon in the vertical direction.

  • horizontal (Boolean) - True if the balloon has horizontal alignment, false if it has vertical alignment

Returns

String - The URL of the tag image file to be used with the specified balloon alignment.