Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
Loads a map. This class is a core class.
Constructor | Description |
|---|---|
HWMapJsSDK.HWMap(div, mapOptions) |
|
Method | Description | Type | Return Value |
|---|---|---|---|
fitBounds(bounds) | Sets the map display area. | - | |
fromScreenLocation(pixel) | Converts screen coordinates to longitude-latitude coordinates. NOTE This method is used after the map loading is complete. | {x, y}
| |
getBounds() | Obtains the map display area. | - | |
getCenter() | Obtains the coordinates of the map center point. | - | |
getDiv() | Obtains the container for loading a map. | - | Div container. |
getHeading() | Obtains the map heading. | - | Number Angle between the map heading and north direction. |
getMapType() | Obtains the map type. | - | String |
getOpacity() | Obtains the map opacity. | - | Number |
getPoi(pixel) | Obtains the POI data of the current place. | [Number, Number] Pixel coordinates on a map. The first number indicates the X coordinate and the second number indicates the Y coordinate. | POI information about the current place, including the location and attributes. |
getSize() | Obtains the map size. | - | A number-type array in [width, height] format. |
getZoom() | Obtains the zoom level of a map. | - | Number |
panBy(x, y) | Pans the map center point by (x, y). |
| - |
panTo(latLng) | Moves the map center to a specified coordinate point. | - | |
panToBounds(latLngBounds) | Moves a map so that it contains a specified coordinate area. | [lng1, lat1, lng2, lat2] | - |
resize() | Recalculates the size of the map container. | - | - |
setCenter(latlng) | Sets the coordinates of the map center point. | - | |
setCopyrightControl(enabled) | Sets whether to display the copyright information. | Boolean
| - |
setFitView(points, options?) | Sets the optimal view based on the provided array of longitudes and latitudes. |
| - |
setHeading(heading) | Sets the map heading. | Number Angle between the map heading and the north. The value ranges from 0 to 360. | - |
setLocationControl(enabled) | Sets whether to display the current-location icon. | Boolean
| - |
setLogoPosition(logoPosition) | Sets the position of the Petal Maps logo. | String
The default value is BOTTOM_LEFT. | - |
setMapType(mapType) | Sets the map type. | String
| - |
setNavigationControl(enabled) | Sets whether to display the pan button. | Boolean
| - |
setOpacity(opacity) | Sets the map opacity. | Number Value range: [0, 1] | - |
setPinchRotate(disabled) | Sets whether the map can be rotated with two fingers. | Boolean
The default value is true. | - |
setPresetStyleId(presetStyleId) | Sets the preset map style. | String The options are standard, night, and simple. | - |
setPreviewId(previewId) | Sets a preview ID to specify a custom map style. | String Preview ID. | - |
setRotateControl(enabled) | Sets whether to display the compass. | Boolean
| - |
setScaleControl(enabled) | Sets whether to display the scale. | Boolean
| - |
setStyle(styles) | Sets a custom map style using the JSON file. | JSON array | - |
setStyleId(styleId) | Sets a style ID to specify a custom map style. | String Style ID. | - |
setTitle(title) | Sets the prompt information for the container where the map is located. | String | - |
setZoom(zoom) | Sets the zoom level of a map. | Number Value range: [minZoom, maxZoom] | - |
setZoomControl(enabled) | Sets whether to display the zoom button. | Boolean
| - |
setZoomSlider(enabled) | Sets whether to display the zoom slider. | Boolean
| - |
toScreenLocation(latlng) | Converts longitude-latitude coordinates to screen coordinates. NOTE This method is used after the map loading is complete. | {x, y}
| |
zoomIn() | Zooms in on a map by 1 level. | - | - |
zoomOut() | Zooms out on a map by 1 level. | - | - |
on(event, callback) | Sets a custom function to be called when an event is triggered. |
| - |
onCenterChanged(callback) | Sets a custom function called when the map center changes. | Function Custom callback function. | - |
onHeadingChanged(callback) | Sets a custom function called when the map heading changes. | Function Custom callback function. | - |
onZoomChanged(callback) | Sets a custom function called when the map zoom level changes. | Function Custom callback function. | - |
un(event, callback) | Unbinds the event listener. |
| - |
destroy() | Destroys a map instance. | - | - |
Event | Description | Usage | Description |
|---|---|---|---|
click | Click on the left button of the mouse once or more. This event conflicts with the dblclick event. | map.on('click', callback) | In the callback function, the event object includes two important parameters:
|
contextmenu | Click on the right button of the mouse. | map.on('contextmenu', callback) | |
dblclick | Double-click on the left button of the mouse. | map.on('dblclick', callback) | |
singleclick | Click on the left button of the mouse once. This event will be delayed for 250 milliseconds to distinguish it from a double-click. It does not conflict with the dblclick event. | map.on('singleclick', callback) | |
pointermove | Moving of the mouse pointer. | map.on('pointermove', callback) | |
pointerdown | Mouse button press. | map.on('pointerdown', callback) | |
pointerup | Mouse button release. | map.on('pointerup', callback) | |
pointerdrag | Map dragging. | map.on('pointerdrag', callback) | |
movestart | Map moving start. | map.on('movestart', callback) | - |
moveend | Map moving stop. | map.on('moveend', callback) | - |
onCenterChanged | Map center change. | map.onCenterChanged(callback) | - |
onHeadingChanged | Map heading change. | map.onHeadingChanged(callback) | - |
onZoomChanged | Map zoom level change. | map.onZoomChanged(callback) | - |
Parameter | Mandatory | Type | Description |
|---|---|---|---|
accessToken | Yes | String | Access token. |
Parameter | Mandatory | Type | Description |
|---|---|---|---|
value | Yes | String | Currently, DOM elements of the text or HTML format are supported. The DOM elements support the following tags:
|
Parameter | Mandatory | Type | Description |
|---|---|---|---|
authOptions | No | Access token. | |
center | Yes | Central point of a map. | |
copyrightControl | No | Boolean | Indicates whether to display the copyright information on a map. The default value is false. |
copyrightControlOptions | No | Map copyright information. | |
language | No | String | Map language. For details about the value range, please refer to LanguageCode. NOTE BCP 47 language codes are recommended. |
locationControl | No | Boolean | Indicates whether to display the current-location icon on the map. The default value is false. |
logoPosition | No | String | Sets the position of the Petal Maps logo. The options are as follows:
The default value is BOTTOM_LEFT. |
mapType | No | String | Map type. The options are as follows:
|
maxZoom | No | Number | Maximum zoom level of the map. The value ranges from 2 to 20. The default value is 20. |
minZoom | No | Number | Minimum zoom level of the map. The value ranges from 2 to 20. The default value is 2. |
navigationControl | No | Boolean | Indicates whether to display the pan button on the map. The default value is false. |
presetStyleId | No | String | Sets the preset map style. The options are standard, night, and simple. |
rotateControl | No | Boolean | Indicates whether to display the compass on a map. The default value is false. |
scaleControl | No | Boolean | Indicates whether to display the scale on a map. The default value is false. |
sourceType | No | String | Tile type used for map loading. The value can be vector or raster. The default value is vector. |
zoom | Yes | Number | Zoom level during map initialization. |
zoomSlider | No | Boolean | Indicates whether to display the zoom slider on a map. The default value is false. |
zoomControl | No | Boolean | Indicates whether to display the zoom controls on a map. The default value is true. |
rasterPreload | No | Boolean | Indicates whether the vector map preloads rasters. The default value is true. |
Parameter | Mandatory | Type | Description |
|---|---|---|---|
units | No | String | Scale unit. The options are imperial, nautical, and metric. The default value is metric. |
ISO-639-2 | BCP 47 | Language |
|---|---|---|
AFR | af | Afrikaans |
SQI | sq | Albanian |
AMH | am | Amharic |
AMH | am-Latn | Amharic |
ARA | ar | Arabic |
HYE | hy | Armenian |
HYE | hy-Latn | Armenian |
ASM | as-Latn | Assamese |
ASM | as | Assamese |
AYM | ay | Aymara |
AZE | az | Azerbaijani |
BAQ | eu | Basque |
BEL | be-Latn | Belarusian |
BEL | be | Belarusian |
BEN | bn-Latn | Bengali |
BEN | bn | Bengali |
BIS | bi | Bislama |
BOS | bs | Bosnian |
BRE | br | Breton |
BUL | bg-Latn | Bulgarian |
BUL | bg | Bulgarian |
BUR | my | Burmese |
CAT | ca | Catalan; Valencian |
CHI | zh | Chinese |
ZHO | zh-Hant | Traditional Chinese |
CES | cs | Czech |
DAN | da | Danish |
DIV | dv | Divehi; Dhivehi; Maldivian |
NLD | nl | Dutch; Flemish |
DZO | dz | Dzongkha |
ENG | en | English |
EST | et | Estonian |
FAO | fo | Faroese |
FIJ | fj | Fijian |
FIL | tl | Tagalog |
FIN | fi | Finnish |
FRA | fr | French |
FRY | fy | Western Frisian |
KAT | ka | Georgian |
KAT | ka-Latn | Georgian |
DEU | de | German |
GLA | gd | Gaelic; Scottish Gaelic |
GLE | ga | Irish |
GLG | gl | Galician |
ELL | el | Greek, Modern (1453-) |
ELL | el-Latn | Greek, Modern (1453-) |
GRN | gn | Guarani |
GUJ | gu-Latn | Gujarati |
GUJ | gu | Gujarati |
HAT | ht | Haitian; Haitian Creole |
HAU | ha | Hausa |
HEB | he-Latn | Hebrew |
HEB | he | Hebrew |
HIN | hi-Latn | Hindi |
HIN | hi | Hindi |
HMO | ho | Hiri Motu |
HUN | hu | Hungarian |
IBO | ig | Igbo |
ISL | is | Icelandic |
IKU | iu | Inuktitut |
IND | id | Indonesian |
ITA | it | Italian |
JPN | ja-Latn | Japanese |
JPN | ja | Japanese |
KAL | kl | Kalaallisut; Greenlandic |
KAN | kn-Latn | Kannada |
KAN | kn | Kannada |
KAS | ks | Kashmiri |
KAZ | kk-Latn | Kazakh |
KAZ | kk | Kazakh |
KHM | km-Latn | Central Khmer |
KHM | km | Central Khmer |
KIN | rw | Kinyarwanda |
KIR | ky-Latn | Kirghiz; Kyrgyz |
KIR | ky | Kirghiz; Kyrgyz |
KOR | ko-Latn | Korean |
KOR | ko | Korean |
KUR | ku-Latn | Kurdish |
KUR | ku | Kurdish |
LAO | lo | Lao |
LAT | la | Latin |
LAV | lv | Latvian |
LIT | lt | Lithuanian |
LTZ | lb | Luxembourgish; Letzeburgesch |
MKD | mk-Latn | Macedonian |
MKD | mk | Macedonian |
MAH | mh | Marshallese |
MAL | ml | Malayalam |
MAL | ml-Latn | Malayalam |
MRI | mi | Maori |
MAR | mr-Latn | Marathi |
MAR | mr | Marathi |
MSA | ms | Malay |
MLG | mg | Malagasy |
MLT | mt | Maltese |
MON | mn-Latn | Mongolian |
MON | mn | Mongolian |
NAU | na | Nauru |
NDE | nd | Ndebele, North; North Ndebele |
NEP | ne-Latn | Nepali |
NEP | ne | Nepali |
NOR | no | Norwegian |
NYA | ny | Chichewa; Chewa; Nyanja |
OCI | oc | Occitan (post 1500) |
ORI | or-Latn | Oriya |
ORI | or | Oriya |
ORM | om | Oromo |
PAN | pa | Punjabi, Panjabi |
PAN | pa-Latn | Punjabi, Panjabi |
PAN | pa-Arab | Punjabi, Panjabi |
PAN | pa-Guru | Punjabi, Panjabi |
FAS | fa-Latn | Persian |
FAS | fa | Persian |
POL | pl | Polish |
POR | pt | Portuguese |
PUS | ps | Pushto; Pashto |
QUE | qu | Quechua |
ROH | rm | Romansh |
RON | ro | Romanian; Moldavian; Moldovan |
RUN | rn | Rundi |
RUS | ru-Latn | Russian |
RUS | ru | Russian |
SAG | sg | Sango |
SAN | sa | Sanskrit |
HRV | hr | Croatian |
SRP | sr-Latn | Serbian |
SRP | sr | Serbian |
SIN | si-Latn | Sinhala; Sinhalese |
SIN | si | Sinhala; Sinhalese |
SLK | sk | Slovak |
SLV | sl | Slovenian |
SMO | sm | Samoan |
SNA | sn | Shona |
SND | sd-Latn | Sindhi |
SND | sd | Sindhi |
SOM | so | Somali |
SOT | st | Sotho, Southern |
SPA | es | Spanish; Castilian |
SRD | sc | Sardinian |
SSW | ss | Swati |
SWA | sw | Swahili |
SWE | sv | Swedish |
TAH | ty | Tahitian |
TAM | ta-Latn | Tamil |
TAM | ta | Tamil |
TAT | tt-Latn | Tatar |
TAT | tt | Tatar |
TEL | te-Latn | Telugu |
TEL | te | Telugu |
TGK | tg-Latn | Tajik |
TGK | tg | Tajik |
THA | th-Latn | Thai |
THA | th | Thai |
TIR | ti-Latn | Tigrinya |
TIR | ti | Tigrinya |
TON | to | Tonga (Tonga Islands) |
TSN | tn | Tswana |
TUK | tk | Turkmen |
TUR | tr | Turkish |
UIG | ug-Latn | Uighur; Uyghur |
UIG | ug | Uighur; Uyghur |
UKR | uk-Latn | Ukrainian |
UKR | uk | Ukrainian |
URD | ur-Latn | Urdu |
URD | ur | Urdu |
UZB | uz-Latn | Uzbek |
UZB | uz | Uzbek |
VIE | vi | Vietnamese |
CYM | cy | Welsh |
WOL | wo | Wolof |
XHO | xh | Xhosa |
YOR | yo | Yoruba |
ZUL | zu | Zulu |