Linden Lab Official:Map API Reference

From Second Life Wiki
Revision as of 17:33, 22 January 2009 by Rand Linden (talk | contribs)
Jump to navigation Jump to search

Bounds

Represents the bounds for a 2D coordinate space. See the guide for more.

Constructor

Bounds ( xMin, xMax, yMin, yMax)

Properties

Property Default Description
xMin Zero Minimum x coordinate of the bounding window.
xMax Zero Maximum x coordinate of the bounding window.
yMin Zero Minimum y coordinate of the bounding window.
yMax Zero Maximum y coordinate of the bounding window.

NOTE: The default values are applied if any of the properties is not specified in the constructor call.

Icon

Represents an icon to used as a marker.

Constructor

Icon ( Img mainImage, Img shadowImage )

Creates a new icon to be used on the map. The optional second parameter specifies a shadow image. See the guide for more. shadowImage defaults to null.

Img

Represents an image to be used as an icon.

Constructor

Img ( String imageSource, int width, int height, Boolean hasAlphaChannel )

Creates a new image to be used on the map. The optional fourth parameter is for specifying whether you are using a 24-bit PNG image with alpha channel transparency. See the guide for more. hasAlphaChannel defaults to false.

MapWindow

This class represents a window placed over the map.

Constructor

MapWindow ( String windowText, options )

Creates a new map window. The given text will be what is contained in the window. Note, HTML can be used but quotes must be escaped correctly otherwise javascript errors will occur.

The second optional argument is a hash of window options, as described in the following table.

Property Default Description
alwaysOnTop false Whether window is always displayed on top of other windows.
noEffect false Whether window appears with fade-in and fade-out effect.
closeOnMove false Whether window is closed when user drags the map.
bringToTop false Whether window is brought to the top when user clicks other windows.
width 252 Width of the window in pixels.
height 236 Height of the window in pixels.
padding 10 Padding of the window in pixels.

Marker

Represents a marker to be added on the map.

Constructor

Marker ( Array icons, XYPoint coordinate, MarkerOptions markerOptions )

Creates a new marker to be placed on the map at given coordinate. The first parameter is an array of icons of length 6. Each icon in the array corresponds to a zoom level, icons[0] being the icon used at the close zoom (level 0).

The optional markerOptions argument is a MarkerOptions object that defaults to null.

MarkerOptions

Properties

Property Default Description
centerOnClick false centers the map on the marker when clicked.
clickHandler null sets a click handler.
onMouseOverHandler null sets a handler that gets executed during an onmouseover event.
onMouseOutHandler null sets a handler that gets executed during an onmouseout event.
autopanOnClick true the map will automatically pan the map if part of the associated MapWindow would have been clipped by an edge of the map when it was opened.
autopanPadding 45 this number represents how close the window needs to be to an edge of the map for autopan to trigger.
verticalAlign "middle" also can be set to "top" and "bottom". This specifies how the marker is vertically aligned.
horizontalAlign "center" also can be set as "left" or "right". This specifies how the marker is horizontally aligned.
zLayer 0 Specifies the layer the marker will render on. For example, if a marker having zLayer = 1 and another marker having zLayer = 0 overlap, the marker with zLayer = 1 will be on top.

The clickHandler, onMouseOverHandler, and onMouseOutHandler options specify an optional functions that get called when their respective events occur. See the guide for more.

SLMap

This class represents the map.

Constructor

SLMap ( HTMLElement container, SLMapOptions options )

Creates the map. The options argument defaults to null.

Methods

Method Return Value Description

addMapWindow( MapWindow mapWindow, XYPoint coord )

None Adds a MapWindow to the map at specified coordinate.

addMarker( Marker marker, MapWindow mapWindow )

None Adds a marker. If the optional mapWindow argument is null, then clicking on the marker will not open a window.

clickMarker( Marker marker)

None Simulates a clicking a marker. Will recenter the pan if its not currently in the viewport of the map.

disableDragging()

None Disables all dragging on the map. Note: panning controls will still work.

enableDragging()

None Re-enables dragging on the map if it was disabled.

enterAndZoomAtSLCoord( XYPoint coordinate, int zoom)

None Centers and zooms the map to the specified location.

getCurrentZoomLevel()

None Gets the current zoom level (1-6). See about zoom levels.

getMapCenter()

XYPoint Returns the current map center. See about coordinates.

getViewportBounds()

Bounds Gets the viewport bounds. See about coordinates.

panDown()

None Pans the map to the down by half its width.

panLeft()

None Pans the map to the left by 1/2 its width.

panOrRecenterToSLCoord( XYPoint coord, Boolean recenter )

None Pans the map to the given coordinate if it is currently in the viewport (in the user's view). Otherwise, recenters the map to the given coordinate. The optional recenter argument specifies whether to center the given coordinate even it if is currently in the viewport. Its default value is false.

panRight()

None Pans the map to the right by 1/2 its width.

panUp()

None Pans the map to the up by 1/2 its width.

removeAllMarkers()

None Removes all markers.

removeMarker( Marker marker)

None Removes a marker.

setCurrentZoomLevel( int zoom)

None Sets the zoom level to specified zoom.

zoomIn()

None Zooms in on the map if the map is not already all the way zoomed in.

zoomOut()

None Zooms out on the map if the map is not already all the way zoomed out.

SLMapOptions

This class represents optional arguments to the SLMap constructor. It has no constructor, but is instantiated as an object literal.

Properties

Property Default Description
hasZoomControls true Whether the map has zoom controls.
hasPanningControls true Whether the map has pan controls.
doubleClickHandler null Specifies a double click function.
singleClickHandler null Specifies a single click function
onStateChangedHandler null Specifies an onstatechanged handler function
zoomMin 6 Specifies an minimum level a map can be zoomed to. Currently the maximum for this value is 7.
zoomMax 1 Specifies an maximum level a map can be zoomed to. Currently the minimum for this value is 1.

The doubleClickHandler and singleClickHandler option can be assigned to call a function whenever a place on the map is double-clicked or single-clicked respectively. See the guide for more.

The onStateChangedHandler option can be assigned to call a function whenever the "state" of the map changes (i.e. whenever the map bounds change). Likewise, see the guide for more.

SLPoint

Not currently implemented.

XYPoint

Represents a point in 2D coordinate space.

Constructor

XYPoint ( Float x, Float y )

Creates an XYPoint object.

Properties

Property Default Description
x None X coordinate
y None Y coordinate