Summary
Methods:
| activate |
激活控件。 |
| deactivate |
禁用控件,禁用后不响应地图事件,不可互操作 |
| destroy |
销毁控件,释放占用的内存。 |
| getControlType |
返回控件的类型 |
| setPosition |
设置控件位置 |
| setStyle |
设置控件样式 |
| updateStyle |
颜色样式更新 |
Constructor
new Compass(options)
Parameters:
| Name | Type | Description | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | 初始化可选项
|
Example
let compass = new hmap.control.Compass({
position:"topleft",
outColor: {
background: "red",
button: "blue"
},
innerColor: {
background: "green",
north: "blue",
south: "white"
}
});
Methods
-
activate()
-
激活控件。
Example
compass.activate(); -
deactivate()
-
禁用控件,禁用后不响应地图事件,不可互操作
Example
compass.deactivate(); -
destroy()
-
销毁控件,释放占用的内存。
Example
compass.destroy(); -
getControlType() → {String}
-
返回控件的类型
Returns:
String -控件类型的名称
-
setPosition(pixel)
-
设置控件位置
Parameters:
Name Type Description pixelmodule:basetype~Pixel 指北针的像素坐标
Example
compass.setPosition(new hmap.basetype.Pixel(200,200)) -
setStyle(options)
-
设置控件样式
Parameters:
Name Type Description optionsObject 样式对象
Name Type Description outColor.backgroundString 外圈背景色
outColor.buttonString 外圈按钮颜色
innerColor.backgroundString 内圈背景色
innerColor.northString 内圈指北针颜色
innerColor.southString 内圈指南针颜色
Example
compass.setStyle({ outColor: { background: "red", button: "blue" }, innerColor: { background: "green", north: "blue", south: "white" } }) -
updateStyle(options) -
颜色样式更新
Parameters:
Name Type Description optionsObject 样式对象
Name Type Description positionString 控件位置,支持"topleft","topright"(默认),"bottomleft","bottomright"
outColor.backgroundString 外圈背景色
outColor.buttonString 外圈按钮颜色
innerColor.backgroundString 内圈背景色
innerColor.northString 内圈指北针颜色
innerColor.southString 内圈指南针颜色
Example
compass.updateStyle({ position:"topleft", outColor: { background: "red", button: "blue" }, innerColor: { background: "green", north: "blue", south: "white" } }) - Deprecated:
- Yes