The Map
object represents the Mini Tokyo 3D map on your page. You create a Map
by specifying a container
and other options. Then Mini Tokyo 3D initializes the map on the page and returns your Map
object.
Extends Evented.
new Map(options: Object)
options
(Object
)
Name | Description |
---|---|
options.accessToken string |
Access token for Mapbox. If you don't specify this token, an error will occur when loading the map, so make sure to get an access token specific to your web site. |
options.bearing number default: 0 |
The initial bearing (rotation) of the map, measured in degrees counter-clockwise from north. If not specified, it will default to 0 . |
options.center LngLatLike default: [139.7670, 35.6814] |
The initial geographical centerpoint of the map. If not specified, it will default to around Tokyo station ([139.7670, 35.6814] ). Note: Mini Tokyo 3D uses longitude, latitude coordinate order to match GeoJSON. |
options.clockControl boolean default: true |
If true , the date and time display will be added to the map. |
options.configControl boolean default: true |
If true , the configuration buttons will be added to the map. |
options.container string |
The id of the HTML element in which Mini Tokyo 3D will render the map. The specified element must have no children. |
options.dataSources Array < DataSource > default: [] |
An array of additional data sources for Mini Tokyo 3D. Note that this is an experimental feature which is under development and is prone to change. |
options.dataUrl string |
Mini Tokyo 3D data URL. If not specified, 'https://minitokyo3d.com/data' will be used. |
options.ecoFrameRate number default: 1 |
Frame rate for train and airplane animations (frames per second) when Eco Mode is on. Specify on a scale of 1 to 60. Lower values result in less smoother animations and lower CPU resource usage, thus reducing battery consumption on mobile devices. If not specified, it will default to 1 . |
options.ecoMode string default: 'normal' |
The initial eco mode. 'normal' and 'eco' are supported. |
options.fullscreenControl boolean default: true |
If true , the fullscreen button will be added to the map. |
options.lang string |
IETF language tag for the language. If not specified, the browser's default language is used. Currently 'ja' , 'en' , 'ko' , 'zh-Hans' , 'zh-Hant' , 'th' , 'ne' , 'pt-BR' , 'fr' , 'es' and 'de' are supported. If an unsupported language is specified, then 'en' is used. |
options.modeControl boolean default: true |
If true , the mode switch buttons will be added to the map. |
options.navigationControl boolean default: true |
If true , the navigation buttons will be added to the map. |
options.pitch number default: 60 |
The initial pitch (tilt) of the map, measured in degrees away from the plane of the screen (0-85). If not specified, it will default to 60 . |
options.plugins Array < PluginInterface > |
An array of plugins to add. Each plugin must implement PluginInterface. |
options.searchControl boolean default: true |
If true , the search button will be added to the map. |
options.secrets Secrets |
An object to store the access tokens used to retrieve data. |
options.selection string |
ID of the train or flight to be tracked, or the station to be selected. The train ID is a string in the form of 'odpt.Train:<operator ID>.<railway ID>.<train number>' . The fright ID is a string in the form of 'odpt.FlightInformationArrival:<operator ID>.<airport ID>.<flight number>' or 'odpt.FlightInformationDeparture:<operator ID>.<airport ID>.<flight number>' . The station ID is a string in the form of 'odpt.Station:<operator ID>.<railway ID>.<station ID>' . The 'odpt.*:' part can be omitted. For details, see the Public Transportation Open Data Center: API Specification. |
options.trackingMode string default: 'position' |
The initial tracking mode. 'position' , 'back' , 'topback' , 'front' , 'topfront' , 'helicopter' , 'drone' and 'bird' are supported. |
options.zoom number default: 14 |
The initial zoom level of the map. If not specified, it will default to 14 . |
Adds a layer to the map.
layer
(Object
| CustomLayerInterface
| GeoJsonLayerInterface
| ThreeLayerInterface
| Tile3DLayerInterface
) The layer to add, conforming to either the Mapbox Style Specification's layer definition, the CustomLayerInterface specification, the GeoJsonLayerInterface specification, the ThreeLayerInterface specification or the Tile3DLayerInterface specification.
Map
: Returns itself to allow for method chaining.
Changes any combination of center
, zoom
, bearing
, pitch
, and padding
with an animated transition between old and new values. The map will retain its current values for any details not specified in options
.
Note: The transition will happen instantly if the user has enabled the reduced motion
accessibility feature enabled in their operating system, unless options
includes essential: true
.
options
(Object
) Options describing the destination and animation of the transition. Accepts CameraOptions and AnimationOptions.
Map
: Returns itself to allow for method chaining.
Changes any combination of center
, zoom
, bearing
, and pitch
, animating the transition along a curve that evokes flight. The animation seamlessly incorporates zooming and panning to help the user maintain their bearings even after traversing a great distance.
If a user has the reduced motion
accessibility feature enabled in their operating system, the animation will be skipped and this will behave equivalently to jumpTo
, unless options
includes essential: true
.
options
(Object
) Options describing the destination and animation of the transition. Accepts CameraOptions, AnimationOptions, and the following additional options.
Name | Description |
---|---|
options.curve number default: 1.42 |
The zooming "curve" that will occur along the flight path. A high value maximizes zooming for an exaggerated animation, while a low value minimizes zooming for an effect closer to Map#easeTo. 1.42 is the average value selected by participants in the user study discussed in van Wijk (2003). A value of Math.pow(6, 0.25) would be equivalent to the root mean squared average velocity. A value of 1 would produce a circular motion. If options.minZoom is specified, this option will be ignored. |
options.maxDuration number |
The animation's maximum duration, measured in milliseconds. If duration exceeds maximum duration, it resets to 0. |
options.minZoom number |
The zero-based zoom level at the peak of the flight path. If this option is specified, options.curve will be ignored. |
options.screenSpeed number |
The average speed of the animation measured in screenfuls per second, assuming a linear timing curve. If options.speed is specified, this option is ignored. |
options.speed number default: 1.2 |
The average speed of the animation defined in relation to options.curve . A speed of 1.2 means that the map appears to move along the flight path by 1.2 times options.curve screenfuls every second. A screenful is the map's visible span. It does not correspond to a fixed physical distance, but varies by zoom level. |
Map
: Returns itself to allow for method chaining.
Returns the map's current bearing. The bearing is the compass direction that is "up"; for example, a bearing of 90° orients the map so that east is up.
number
: The map's current bearing.
Returns the map's geographical centerpoint.
LngLat
: The map's geographical centerpoint.
Returns the current clock mode.
string
: A string representing the current clock mode. Either 'realtime'
or 'playback'
.
Returns the current eco mode.
string
: A string representing the current eco mode. Either 'normal'
or 'eco'
.
Returns the Mapbox's Map
object used in the map.
Map
: The Mapbox's Map.
Projects a LngLat
to a MercatorCoordinate
, and returns the translated mercator coordinates with Tokyo Station as the origin.
lnglat
(LngLatLike
) The location to project.
altitude
(number
) The altitude in meters of the position.
{x: number
, y: number
, z: number
}: The translated mercator coordinates with Tokyo Station as the origin.
Returns the scale to transform into MercatorCoordinate
from coordinates in real world units using meters. This provides the distance of 1 meter in MercatorCoordinate
units at Tokyo Station.
number
: The scale to transform into MercatorCoordinate
from coordinates in real world units using meters.
Returns the map's current pitch (tilt).
number
: The map's current pitch, measured in degrees away from the plane of the screen.
Returns the ID of the train or flight being tracked, or the array of the IDs of the selected stations.
string
| Array
<
string
>
: The ID of the train or flight being tracked, or the array of the IDs of the selected stations. The train ID is a string in the form of '<operator ID>.<line ID>.<train number>'
. The flight ID is a string in the form of '<operator ID>.<airport ID>.<flight number>'
. The station ID is a string in the form of '<operator ID>.<line ID>.<station ID>'
.
Returns the current tracking mode. See here for details of the tracking modes.
string
: A string representing the current tracking mode. Either 'position'
, 'back'
, 'topback'
, 'front'
, 'topfront'
, 'helicopter'
, 'drone'
or 'bird'
.
::: warning
The tracking mode 'heading'
is deprecated and falls back to 'topback'
.
:::
Returns the current view mode.
string
: A string representing the current view mode. Either 'ground'
or 'underground'
.
Returns the map's current zoom level.
number
: The map's current zoom level.
Checks if the background color of the map is dark.
boolean
: true
if the background color of the map is dark, false
otherwise.
Changes any combination of center
, zoom
, bearing
, and pitch
, without an animated transition. The map will retain its current values for any details not specified in options
.
options
(CameraOptions
) Options object.
Map
: Returns itself to allow for method chaining.
Removes an event listener previously added with Map#on
.
type
(string
) The event type previously used to install the listener.
listener
(Function
) The function previously installed as a listener.
Map
: Returns itself to allow for method chaining.
Adds a listener for events of a specified type.
type
(string
) The event type to listen for.
listener
(Function
) The function to be called when the event is fired.
Map
: Returns itself to allow for method chaining.
Adds a listener that will be called only once to a specified event type.
type
(string
) The event type to add a listener for.
listener
(Function
) The function to be called when the event is fired.
Map
: Returns itself to allow for method chaining.
Removes the layer with the given ID from the map.
If no such layer exists, an error
event is fired.
id
(string
) ID of the layer to remove.
Map
: Returns itself to allow for method chaining.
Sets the map's bearing (rotation). The bearing is the compass direction that is "up"; for example, a bearing of 90° orients the map so that east is up.
Equivalent to jumpTo({bearing: bearing})
.
bearing
(number
) The desired bearing.
Map
: Returns itself to allow for method chaining.
Sets the map's geographical centerpoint. Equivalent to jumpTo({center: center})
.
center
(LngLatLike
) The centerpoint to set.
Map
: Returns itself to allow for method chaining.
Sets the clock mode. In the real-time clock mode ('realtime'
), trains and airplanes are displayed on the map according to the actual operation at the current time. In the playback clock mode ('playback'
), you can specify the time and the speed of time passing.
mode
(string
) A string representing the clock mode. Either 'realtime'
or 'playback'
.
Map
: Returns itself to allow for method chaining.
Sets the eco mode. In the normal mode ('normal'
), the frame rate for train and airplane animations will be set to 60. In the eco mode ('eco'
), the frame rate will be set to the Map
constructor option ecoFrameRate
.
mode
(string
) A string representing the eco mode. Either 'normal'
or 'eco'
.
Map
: Returns itself to allow for method chaining.
Sets the visibility of the layer. Specify 'visible'
to make it visible, or 'none'
to make it invisible.
layerId
(string
) The ID of the layer to set the visibility in.
visibility
(string
) Whether this layer is displayed. Either 'visible'
or 'none'
.
Map
: Returns itself to allow for method chaining.
Sets the map's pitch (tilt). Equivalent to jumpTo({pitch: pitch})
.
pitch
(number
) The pitch to set, measured in degrees away from the plane of the screen (0-85).
Map
: Returns itself to allow for method chaining.
Sets the ID of the train or flight you want to track, or the station to select. The train ID is a string in the form of 'odpt.Train:<operator ID>.<railway ID>.<train number>'
. The fright ID is a string in the form of 'odpt.FlightInformationArrival:<operator ID>.<airport ID>.<flight number>'
or 'odpt.FlightInformationDeparture:<operator ID>.<airport ID>.<flight number>'
. The station ID is a string in the form of 'odpt.Station:<operator ID>.<railway ID>.<station ID>'
. The 'odpt.*:'
part can be omitted. For details, see the Public Transportation Open Data Center: API Specification.
id
(string
) ID of the train or flight to be tracked, or the station to be selected.
Map
: Returns itself to allow for method chaining.
Sets the tracking mode. See here for details of the tracking modes.
mode
(string
) A string representing the tracking mode. Either 'position'
, 'back'
, 'topback'
, 'front'
, 'topfront'
, 'helicopter'
, 'drone'
or 'bird'
.
::: warning
The tracking mode 'heading'
is deprecated and falls back to 'topback'
.
:::
Map
: Returns itself to allow for method chaining.
Sets the view mode. In the ground view mode (ground'
), ground railways, stations, trains and airplanes will be displayed brightly, and underground railways, stations and trains will be translucent. In the underground view mode ('underground'
), the map will turn dark and ground railways, stations, trains and airplanes will be translucent, while underground railways, stations and trains will appear brighter.
mode
(string
) A string representing the view mode. Either 'ground'
or 'underground'
.
Map
: Returns itself to allow for method chaining.
Sets the map's zoom level. Equivalent to jumpTo({zoom: zoom})
.
zoom
(number
) The zoom level to set (0-22).
Map
: Returns itself to allow for method chaining.
Fired when the user cancels a "box zoom" interaction, or when the bounding box does not meet the minimum size threshold. See BoxZoomHandler.
Type MapBoxZoomEvent
Fired when a "box zoom" interaction ends. See BoxZoomHandler.
Type MapBoxZoomEvent
Fired when a "box zoom" interaction starts. See BoxZoomHandler.
Type MapBoxZoomEvent
Fired when a pointing device (usually a mouse) is pressed and released at the same point on the map.
Type MapMouseEvent
Fired when the clock mode is changed.
Type Object
mode
(string
): A string representing the clock mode. Either 'realtime'
or 'playback'
.
Fired when the right button of the mouse is clicked or the context menu key is pressed within the map.
Type MapMouseEvent
Fired when a pointing device (usually a mouse) is pressed and released twice at the same point on the map in rapid succession.
Type MapMouseEvent
Fired when a train or airplane tracking is canceled, or stations are deselected.
Type Object
deselection
(string
| Array
<
string
>
): The ID of the train or flight whose tracking is canceled, or the array of the IDs of the deselected stations. The train ID is a string in the form of '<operator ID>.<line ID>.<train number>'
. The flight ID is a string in the form of '<operator ID>.<airport ID>.<flight number>'
. The station ID is a string in the form of '<operator ID>.<line ID>.<station ID>'
.
Fired repeatedly during a "drag to pan" interaction. See DragPanHandler.
Type (MapMouseEvent
| MapTouchEvent
)
Fired when a "drag to pan" interaction ends. See DragPanHandler.
Type (MapMouseEvent
| MapTouchEvent
)
Fired when a "drag to pan" interaction starts. See DragPanHandler.
Type (MapMouseEvent
| MapTouchEvent
)
Fired when the eco mode is changed.
Type Object
mode
(string
): A string representing the eco mode. Either 'normal'
or 'eco'
.
Fired when an error occurs. This is Mini Tokyo 3D's primary error reporting mechanism. We use an event instead of throw
to better accommodate asynchronous operations. If no listeners are bound to the error
event, the error will be printed to the console.
Type Object
message
(string
): Error message.
Fired immediately after all necessary resources have been downloaded and the first visually complete rendering of the map has occurred.
Type Object
Fired when a pointing device (usually a mouse) is pressed within the map.
Type MapMouseEvent
Fired when a pointing device (usually a mouse) is moved while the cursor is inside the map. As you move the cursor across the map, the event will fire every time the cursor changes position within the map.
Type MapMouseEvent
Fired when a pointing device (usually a mouse) is moved within the map. As you move the cursor across a web page containing a map, the event will fire each time it enters the map or any child elements.
Type MapMouseEvent
Fired when a pointing device (usually a mouse) is released within the map.
Type MapMouseEvent
Fired repeatedly during an animated transition from one view to another, as the result of either user interaction or methods such as Map#flyTo.
Type (MapMouseEvent
| MapTouchEvent
)
Fired just after the map completes a transition from one view to another, as the result of either user interaction or methods such as Map#jumpTo.
Type (MapMouseEvent
| MapTouchEvent
)
Fired just before the map begins a transition from one view to another, as the result of either user interaction or methods such as Map#jumpTo.
Type (MapMouseEvent
| MapTouchEvent
)
Fired repeatedly during the map's pitch (tilt) animation between one state and another as the result of either user interaction or methods such as Map#flyTo.
Type (MapMouseEvent
| MapTouchEvent
)
Fired immediately after the map's pitch (tilt) finishes changing as the result of either user interaction or methods such as Map#flyTo.
Type (MapMouseEvent
| MapTouchEvent
)
Fired whenever the map's pitch (tilt) begins a change as the result of either user interaction or methods such as Map#flyTo.
Type (MapMouseEvent
| MapTouchEvent
)
Fired immediately after the map has been resized.
Fired repeatedly during a "drag to rotate" interaction. See DragRotateHandler.
Type (MapMouseEvent
| MapTouchEvent
)
Fired when a "drag to rotate" interaction ends. See DragRotateHandler.
Type (MapMouseEvent
| MapTouchEvent
)
Fired when a "drag to rotate" interaction starts. See DragRotateHandler.
Type (MapMouseEvent
| MapTouchEvent
)
Fired when a train or airplane tracking is initiated, or stations are selected.
Type Object
selection
(string
| Array
<
string
>
): The ID of the train or flight whose tracking is initiated, or the array of the IDs of the selected stations. The train ID is a string in the form of '<operator ID>.<line ID>.<train number>'
. The flight ID is a string in the form of '<operator ID>.<airport ID>.<flight number>'
. The station ID is a string in the form of '<operator ID>.<line ID>.<station ID>'
.
Fired when a touchcancel
event occurs within the map.
Type MapTouchEvent
Fired when a touchend
event occurs within the map.
Type MapTouchEvent
Fired when a touchmove
event occurs within the map.
Type MapTouchEvent
Fired when a touchstart
event occurs within the map.
Type MapTouchEvent
Fired when the tracking mode is changed.
Type Object
mode
(string
): A string representing the tracking mode. Either 'position'
, 'back'
, 'topback'
, 'front'
, 'topfront'
, 'helicopter'
, 'drone'
or 'bird'
.
::: warning
The tracking mode 'heading'
is deprecated and falls back to 'topback'
.
:::
Fired when the view mode is changed.
Type Object
mode
(string
): A string representing the view mode. Either 'ground'
or 'underground'
.
Fired when a wheel
event occurs within the map.
Type MapWheelEvent
Fired repeatedly during an animated transition from one zoom level to another, as the result of either user interaction or methods such as Map#flyTo.
Type (MapMouseEvent
| MapTouchEvent
)
Fired just after the map completes a transition from one zoom level to another, as the result of either user interaction or methods such as Map#flyTo.
Type (MapMouseEvent
| MapTouchEvent
)
Fired just before the map begins a transition from one zoom level to another, as the result of either user interaction or methods such as Map#flyTo.
Type (MapMouseEvent
| MapTouchEvent
)