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

From Second Life Wiki
Jump to navigation Jump to search
(New page: == SLMap == This class represents the map. === Constructor === <div style="font: 10pt courier; white-space: pre; color: black; background: #F9F9F9; border:solid 1px #AAAAAA; padding: 0 0...)
 
(Updated for version 2 of API)
 
(88 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== SLMap ==
{{Supported API}}
This class represents the map.
{{:API Portal/navigation|map}}
'''NOTE:''' See the [[Linden Lab Official:Map API Introduction#Release notes|Release Notes]] for information on new features and known issues.
__TOC__
<br clear="all"/>
== Global functions ==


=== Constructor ===
{| border="1" cellspacing="0" cellpadding="3" rules="all" class="apitable"
|- bgcolor="#A7C1F2"
!valign="top"| Function
!valign="top"| Return Value
!valign="top"| Description


<div style="font: 10pt courier; white-space: pre; color: black; background: #F9F9F9; border:solid 1px #AAAAAA; padding: 0 0 10px 10px"><nowiki>
|-
SLMap (HTMLElement container,  
|valign="top" class="signature"|
      SLMapOptions options)
SLMap(
</nowiki></div>
[https://developer.mozilla.org/en/DOM/element HTMLElement] element)
|[[#Map|Map]]
|Creates a new map inside the specified DOM element.
|-
|valign="top" class="signature"|
gotoSLURL(
x Number,
y Number,
[[#Map|Map]] lmap)
|None
|Pans the map to display the specified inworld location.
|}


Creates the map. The SLMapOptions argument is optional.
== Objects ==


=== Methods ===
=== Map ===
This class is the Leaflet class that represents the map. For more information, see [http://leafletjs.com/reference-1.0.2.html#map the Leaflet Map reference].


{| {{Prettytable}}
{{API Constructor|  
|- {{Hl2}}
[http://leafletjs.com/reference-1.0.2.html#map Map] SLMap([https://developer.mozilla.org/en/DOM/element HTMLElement] container)
! Method
}}
! Return Value
 
! Description
Creates a Leaflet map configured to display a map of Second Life.
 
The map is generated with a click event handler that calls '''gotoSLURL()''' to display a popup with a “Visit this location” link.
 
==== Useful Methods ====
 
For other methods, see [http://leafletjs.com/reference-1.0.2.html#map-method the Leaflet Map methods reference].
 
{| border="1" cellspacing="0" cellpadding="3" rules="all" class="apitable"
|- bgcolor="#A7C1F2"
!valign="top"| Method
!valign="top"| Return Value
!valign="top"| Description


|-
|-
|style="font: 10pt courier; padding: 0 10px 0 10px"|  
|valign="top" class="signature"|
centerAndZoomAtSLCoord(  
[http://leafletjs.com/reference-1.0.2.html#map-setview setView](
<br>&nbsp;&nbsp;[[Main Page|XYPoint]] coordinate,
[http://leafletjs.com/reference-1.0.2.html#latlng LatLng] center,
<br>&nbsp;&nbsp;int zoom)
Number zoom)
|valign="top"| [http://leafletjs.com/reference-1.0.2.html#map Map]
|valign="top"| Centers and zooms the map to the specified location.  Argument zoom must be an integer value. Note that [http://leafletjs.com/examples/crs-simple/crs-simple.html#this-is-not-the-latlng-youre-looking-for a LatLng is a (Y, X) coordinate], so coordinates passed as ''center'' should be in (Y, X) order.
|}
 
== Utility URLs ==
These map helper functions are available from the caps server. The JSON-like results return text that Javascript could eval(), but scripts coming from outside should parse them the "hard" way for safety.
 
=== Region name from global coordinates ===
https<nowiki></nowiki>://cap.secondlife.com/cap/0/'''b713fe80-283b-4585-af4d-a3b7d9a32492'''?'''var'''=''varName''&'''grid_x'''=''xcoord''&'''grid_y'''=''ycoord''
* '''var''' is arbitrary, for output formatting.
* '''grid_x''' is the region's global x coordinate as an integer.
* '''grid_y''' is the region's global y coordinate as an integer.


|valign="top"|
'''Example'''
None
https://cap.secondlife.com/cap/0/b713fe80-283b-4585-af4d-a3b7d9a32492?var=region&grid_x=1000&grid_y=1000
|valign="top"|
:Returns: <pre>var region='Da Boom';</pre>
Centers and zooms the map to the specified location.


|}
=== Global coordinates from region name ===
https<nowiki></nowiki>://cap.secondlife.com/cap/0/'''d661249b-2b5a-4436-966a-3d3b8d7a574f'''?'''var'''=''varName''&'''sim_name'''=''RegionName''
* '''var''' is arbitrary, for output formatting.
* '''sim_name''' is a region on the Second Life map.
 
'''Example'''
https://cap.secondlife.com/cap/0/d661249b-2b5a-4436-966a-3d3b8d7a574f?var=coords&sim_name=Da%20Boom
:Returns: <pre>var coords = {'x' : 1000, 'y' : 1000 };</pre>

Latest revision as of 18:23, 13 December 2016

NOTE: This is an official Second Life API provided and documented by Linden Lab. Its use is subject to the API Terms of Use.

NOTE: See the Release Notes for information on new features and known issues.


Global functions

Function Return Value Description

SLMap( HTMLElement element)

Map Creates a new map inside the specified DOM element.

gotoSLURL( x Number, y Number, Map lmap)

None Pans the map to display the specified inworld location.

Objects

Map

This class is the Leaflet class that represents the map. For more information, see the Leaflet Map reference.

Constructor

Map SLMap(HTMLElement container)

Creates a Leaflet map configured to display a map of Second Life.

The map is generated with a click event handler that calls gotoSLURL() to display a popup with a “Visit this location” link.

Useful Methods

For other methods, see the Leaflet Map methods reference.

Method Return Value Description

setView( LatLng center, Number zoom)

Map Centers and zooms the map to the specified location. Argument zoom must be an integer value. Note that a LatLng is a (Y, X) coordinate, so coordinates passed as center should be in (Y, X) order.

Utility URLs

These map helper functions are available from the caps server. The JSON-like results return text that Javascript could eval(), but scripts coming from outside should parse them the "hard" way for safety.

Region name from global coordinates

https://cap.secondlife.com/cap/0/b713fe80-283b-4585-af4d-a3b7d9a32492?var=varName&grid_x=xcoord&grid_y=ycoord

  • var is arbitrary, for output formatting.
  • grid_x is the region's global x coordinate as an integer.
  • grid_y is the region's global y coordinate as an integer.

Example

https://cap.secondlife.com/cap/0/b713fe80-283b-4585-af4d-a3b7d9a32492?var=region&grid_x=1000&grid_y=1000
Returns:
var region='Da Boom';

Global coordinates from region name

https://cap.secondlife.com/cap/0/d661249b-2b5a-4436-966a-3d3b8d7a574f?var=varName&sim_name=RegionName

  • var is arbitrary, for output formatting.
  • sim_name is a region on the Second Life map.

Example

https://cap.secondlife.com/cap/0/d661249b-2b5a-4436-966a-3d3b8d7a574f?var=coords&sim_name=Da%20Boom
Returns:
var coords = {'x' : 1000, 'y' : 1000 };