L.Wrld.map(element, apiKey, options)
Extends: L.Map
// Create a map inside the "map" element, centered over San Francisco
var map = L.Wrld.map("map", "your_api_key_here", {
center: [37.7858, -122.401],
zoom: 16
});
Argument | Type | Description |
---|---|---|
element | HTMLElement | string | The DOM element, or id of the DOM element, to create a map inside |
apiKey | string | A valid WRLD API key which is required to initialize the map |
options | object | These are the same options you would pass to L.map with some extensions described below |
Options
Options | Type | Default | Description |
---|---|---|---|
canvasId | string | “canvas” | The id to give to the generated canvas HTML element that the map is rendered on |
width | number | * | The initial width of the canvas. Defaults to the width of the element passed to the constructor |
height | number | * | The initial height of the canvas. Defaults to the height of the element passed to the constructor |
indoorsEnabled | boolean | false | Whether or not IndoorMap objects and their IndoorMapEntrance objects can be loaded by the map |
displayEntranceMarkers | boolean | true | Whether or not to automatically represent IndoorMapEntrance objects as interactive markers on the map |
coverageTreeManifest | string | ”” | The coverage tree manifest url for the map |
environmentThemesManifest | string | ”” | The environment themes manifest for the map |
headingDegrees | number | 0 | The initial heading of the map in degrees |
Methods
map.getAltitudeAtLatLng(latLng)
Returns the altitude of the terrain in meters above sea level at a given LatLng.
Argument | Type | Description |
---|---|---|
latLng | L.LatLng | The LatLng where the altitude will be returned from |
map.getCameraDistanceToInterest()
Returns the distance between the camera and the geographical center of the map view in meters.
map.getCameraPitchDegrees()
Returns the pitch of the camera in degrees, where 0 is the horizontal and 90 is the downward vertical.
map.getCameraTiltDegrees()
Returns camera’s tilt. This is the offset from the normal to the earth’s surface. 0 is looking vertically down.
map.setCameraTiltDegrees(tilt)
Sets the camera’s tilt to a new value.
Argument | Type | Description |
---|---|---|
Tilt | number | The new tilt in degrees. The offset from a normal to the earth’s surface. 0 is looking vertically down onto the map. |
map.getCameraHeadingDegrees()
Returns the heading of the camera in degrees, where 0 is North and increases clockwise.
map.setCameraHeadingDegrees(heading)
Sets the camera’s heading to a new value.
Argument | Type | Description |
---|---|---|
heading | number | The new heading in degrees. Clockwise with 0 pointing north. |
map.precache(center, radius, callback)
Begin an operation to precache a spherical area of the map. This allows that area to load faster in future.
This function returns an object with a cancel()
method to allow you to cancel the precache operation.
Argument | Type | Description |
---|---|---|
center | L.LatLng | The center of the area to precache |
radius | number | The radius of the area to precache |
callback | function | The function to call when the precache operation completes. The function will be passed a boolean indicating whether the precache completed successfully. |
map.setView
Move the map to a new view.
Argument | Type | Description |
---|---|---|
center | L.LatLng | The center of the new view |
zoom | number | The zoom of the new view |
options | function | Optional parameters for the new view |
Options | Type | Description |
---|---|---|
headingDegrees | number | Angle in degrees clockwise from north |
tiltDegrees | number | Camera tilt in degrees. The offset from the earth’s normal, with a tilt of 0 looking vertically down at the earth |
animate | boolean | Flag on whether to animate transition or not. |
durationSeconds | number | Time in seconds for the duration of the animation. |
map.layerPointToLatLng(point)
Converts point on screen to a L.LatLng
Argument | Type | Description |
---|---|---|
point | L.Point | The pixel point on map layer to convert to a latlng. |
map.latLngToLayerPoint(latLng)
Converts a latlng to a L.Point pixel position relative to the top left of the map layer.
Argument | Type | Description |
---|---|---|
latLng | L.LatLng | The latLng to covert to a point. |
Events
In addition to the standard Leaflet events, L.Wrld.map
supports the following events.
The following events are supported.
Event | Data | Description |
---|---|---|
update | Event | Fired every frame. |
zoom | Event | Fired repeatedly while the user zooms the map. |
pan | Event | Fired repeatedly while the map is panning (e.g. while the user is dragging the map or while the map is still moving after the user stops dragging the map). |
panstart | Event | Fired when the user starts dragging the map. |
panend | Event | Fired when the map stops moving after the user stops dragging the map. |
rotate | Event | Fired repeatedly while the user rotates the map. |
rotatestart | Event | Fired when the user starts rotating the map. |
rotateend | Event | Fired when the user stops rotating the map. |
tilt | Event | Fired repeatedly while the user tilts the map. |
tiltstart | Event | Fired when the user starts tilting the map. |
tiltend | Event | Fired when the user stops tilting the map. |
transitionstart | Event | Fired when the user calls SetView() . |
transitionend | Event | Fired when the camera stops transitioning after SetView() has been called. |