Click or drag to resize

Telogis.GeoBase.MapLayers.ImageObject

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

MapLayers.ImageObject inherits from MapLayers.AbstractObject.

A class for displaying images on a map via an MapLayers.ObjectLayer.

JavaScript
// Render an image on the map ('map') with a balloon containing text
var myImageObject = new Telogis.GeoBase.MapLayers.ImageObject({
    scalable: true, // true to allow the image size to be changed, false to lock size
    src: 'images/pin-red.png', // The path to the image file used
    balloonConfig: { // Configuration options for the balloon
        content: 'Balloon Text', // text to display in the balloon
        show: true // true to display the balloon on load
    },
    anchorPoint: new Telogis.GeoBase.Point(0.5,0.0),
    map: map,
    location: new Telogis.GeoBase.LatLon(33.587137,-117.742878), // Where the image will be drawn
});
Constructor
NameDescription
MapLayers.ImageObject(config, beforeAttach)

Arguments

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

    Properties
    NameTypeDescription
    scalableBoolean

    Whether to allow the MapLayers.ImageObject to have its dimensions specified arbitrarily (for example, using MapLayers.AbstractObject.config.size or MapLayers.AbstractObject.setSize). Setting this to true allows more flexibility in how the image is displayed, but requires a more complex DOM structure for the object which can slow the page down if many are required.

    Defaults to true.
    srcString

    A path to the image file to use for the image object. If not supplied, it can be set later by calling MapLayers.ImageObject.setImage. If this is specified, but MapLayers.AbstractObject.config.size is not, the natural dimensions of this image override the default size.

    This property may also be referenced by the name: image.
  • (Optional)beforeAttach (Function) - An optional callback to be executed (in arbitrary scope) after the object's element is created, but before it and its container element are attached to the document's DOM tree. Appropriate specification of this function can avoid unnecessary DOM reflows. Defaults to function () {}.

Functions
NameDescription
destroy ()

Frees resources used by the MapLayers.ImageObject.

JavaScript
// Render an image on the map ('map') at a specified location
var myImageObject = new Telogis.GeoBase.MapLayers.ImageObject({
    scalable: true,
    src: 'images/pin-red.png',
    anchorPoint: new Telogis.GeoBase.Point(0.5,0.0),
    map: map,
    location: new Telogis.GeoBase.LatLon(33.587137,-117.742878),
});

// Click the canvas to destroy the ImageObject
document.onclick = myTestFunction;
function myTestFunction() {
    myImageObject.destroy();
};
getImage ()

Finds the URI of the image used as the icon to represent the object.

JavaScript
// Render an image on the map ('map') at a specified location
var myImageObject = new Telogis.GeoBase.MapLayers.ImageObject({
    scalable: true,
    src: 'http://localhost/GeoStream/scripts/images/pin-red.png',
    anchorPoint: new Telogis.GeoBase.Point(0.5,0.0),
    map: map,
    location: new Telogis.GeoBase.LatLon(33.587137,-117.742878),
});

// Get the URI of the object image
alert('URI of the image file used for this object is '+myImageObject.getImage());
// 'URI of the image file used for this object is http://localhost/GeoStream/scripts/images/pin-red.png'
Returns

String - The image source.

preloadImages (Array sources, Function callback)

Preloads the images from a list of sources so that MapLayers.ImageObjects constructed using them will be guaranteed to initialize in a synchronous manner, rather than waiting for the image to load. This is particularly useful when displaying many markers with the same icon.

Arguments
  • sources (Array) - The list of source URIs for the images to preload.

  • callback (Function) - A function to execute (in arbitrary scope) once all the images have been preloaded.

setAnchorPoint (Point anchorPoint)

Changes the point on the object that should align with its designated map location. In addition to performing the MapLayers.AbstractObject alignment adjustments, this realigns the object's background image if it is not scalable.

JavaScript
// Render an image on the map ('map') at a specified location
var myImageObject = new Telogis.GeoBase.MapLayers.ImageObject({
    scalable: true,
    src: 'http://localhost/GeoStream/scripts/images/pin-red.png',
    anchorPoint: new Telogis.GeoBase.Point(0.5,0.0),
    map: map,
    location: new Telogis.GeoBase.LatLon(33.587137,-117.742878),
});

// Click the canvas to change the anchor point of the ImageObject
document.onclick = myTestFunction;
function myTestFunction() {
    // Move the anchor point up and to the left
    myImageObject.setAnchorPoint(new Telogis.GeoBase.Point(1.5,1.0));
};
Arguments
  • anchorPoint (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.

setImage (String src)

Changes the image displayed as the pushpin. If no other size has been specified, the natural dimensions of the image are calculated and used as the dimensions for the marker.

JavaScript
// Render an image on the map ('map') at a specified location
var myImageObject = new Telogis.GeoBase.MapLayers.ImageObject({
    scalable: true,
    src: 'http://localhost/GeoStream/scripts/images/pin-red.png',
    anchorPoint: new Telogis.GeoBase.Point(0.5,0.0),
    map: map,
    location: new Telogis.GeoBase.LatLon(33.587137,-117.742878),
});

// Click the canvas to change the image used for the ImageObject
document.onclick = myTestFunction;
function myTestFunction() {
    // Change from a red icon to a green icon
    myImageObject.setImage('http://localhost/GeoStream/scripts/images/pin-green.png');
};
Arguments
  • src (String) - The filesystem path to the browser-compatible image file.