Difference between revisions of "Linden Lab Official:Map API Reference"

From Second Life Wiki
Jump to navigation Jump to search
Line 45: Line 45:


{{API Constructor|  
{{API Constructor|  
Icon (Img mainImage,  
Icon (
Img shadowImage )
[[#Img|Img]] mainImage,  
[[#Img|Img]] shadowImage )
}}
}}


Line 56: Line 57:


{{API Constructor|  
{{API Constructor|  
Img (String imageSource,  
Img (
String imageSource,  
int width,  
int width,  
int height,  
int height,  
Line 75: Line 77:
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.  
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. They are (defaults are in parenthesis):
The second optional argument is a hash of window options, as described in the following table.


{| border="2" cellspacing="0" cellpadding="3" rules="all" class="apitable"
{| border="2" cellspacing="0" cellpadding="3" rules="all" class="apitable"
Line 123: Line 125:


{{API Constructor|  
{{API Constructor|  
Marker (Array icons,  
Marker (
XYPoint coordinate,  
Array icons,  
MarkerOptions markerOptions )
[[#XYPoint|XYPoint]] coordinate,  
[[#MarkerOptions|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).
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.
The optional markerOptions argument is a [[#MarkerOptions|MarkerOptions]] object that defaults to null.


== MarkerOptions ==
== MarkerOptions ==
Line 156: Line 159:
|null
|null
|sets a handler that gets executed during an onmouseover event.  
|sets a handler that gets executed during an onmouseover event.  
|-
|-
|onMouseOutHandler
|onMouseOutHandler
|null
|null
|sets a handler that gets executed during an onmouseout event.  
|sets a handler that gets executed during an onmouseout event.  
|-
|-
|autopanOnClick
|autopanOnClick
|true
|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.  
|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
|autopanPadding
|45
|45
|this number represents how close the window needs to be to an edge of the map for autopan to trigger.  
|this number represents how close the window needs to be to an edge of the map for autopan to trigger.  
|-
|-
|verticalAlign
|verticalAlign
|"middle"
|"middle"
|also can be set to "top" and "bottom". This specifies how the marker is vertically aligned.  
|also can be set to "top" and "bottom". This specifies how the marker is vertically aligned.  
|-
|-
|horizontalAlign
|horizontalAlign
|"center"
|"center"
|also can be set as "left" or "right". This specifies how the marker is horizontally aligned.  
|also can be set as "left" or "right". This specifies how the marker is horizontally aligned.  
|-
|-
|zLayer
|zLayer
Line 190: Line 199:
SLMap (
SLMap (
HTMLElement container,  
HTMLElement container,  
SLMapOptions options )  
[[#SLMapOptions|SLMapOptions]] options )  
}}
}}


Creates the map. The SLMapOptions argument is optional.
Creates the map. The options argument defaults to null.


=== Methods ===
=== Methods ===

Revision as of 18:33, 22 January 2009

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