Reference Source
public class | source

MapMarker

Extends:

L~L.Marker → MapMarker

它用于显示地图上的可点击/拖拽的图标。 它支持这三种图标:Bootstrap 3 icons, Font Awesome 4.0, Semantic UI 0.9.8 icons, Ion Icons 2.0.1.

See:

Example:

// example 1:
var myIcon = new KQ.Struct.Icon({
  iconUrl: '../../images/custom-marker.png',
  iconSize: [ 25, 41 ],
  iconAnchor: [ 13, 40 ],
  shadowUrl: '../../images/marker-shadow.png',
  shadowSize: [ 25, 41 ],
  shadowAnchor: [ 8, 40 ],
});

var marker = new KQ.Map.MapMarker([ 30, 104 ], { icon: myIcon });
marker.addToMapView(mapView);

// example 2:
var iconOptions = {
  icon: 'fa-number',
  markerColor: 'blue',
  shape: 'square',
  prefix: 'fa',
  number: '3',
};

var marker = new KQ.Map.MapMarker([ 30.56, 113.66 ], {
  extraIcon: iconOptions,
});

marker.addToMapView(mapView);

Constructor Summary

Public Constructor
public

constructor(latlng: LatLng, options: Object)

构造函数

Method Summary

Public Methods
public

addToMapView(mapview: Object, isAddDraw: Boolean): Null

添加标记到mapview

public

bindPopup(content: String | HTML, options: Object): MapMarker

绑定弹出框

public

bindTooltip(content: String | HTML, options: Object): MapMarker

绑定提示信息

public

closePopup(): Null

关闭信息框

public

getBounds(): *

public

openPopup(latlng: LatLng): Null

弹出信息框

public

remove(): Null

移除标记

public

slideTo(latlng: LatLng, options: Object): Null

平滑移动标记

public

unbindPopup(): Null

移除弹出框.

public

unbindTooltip(): Null

移除提示信息

Public Constructors

public constructor(latlng: LatLng, options: Object) source

构造函数

Params:

NameTypeAttributeDescription
latlng LatLng

地理坐标点

options Object

设置参数

options.icon String

用于渲染标记的icon的类名

options.extraIcon Object

用于生成新的图标。如果设置,options.icon将不会被使用了。

options.extraIcon.extraClasses String

在创建的<i>标签中额外增加的类 (fa-rotate90 myclass; space delimited classes to add)

options.extraIcon.icon String

带有前缀的图标的名称 (fa-coffee or see icon library's documentation)

options.extraIcon.unicode String

图标的unicode (fa-coffee or see icon library's documentation)

options.extraIcon.iconColor String

Icon的颜色 ('white', 'black' or css code, hex, rgba etc)

options.extraIcon.innerHTML String

定制HTML (<svg>, images, or other HTML; a truthy assignment will override the default html icon creation behavior)

options.extraIcon.markerColor String

标记的颜色 ('red', 'orange-dark', 'orange', 'yellow', 'blue-dark', 'cyan', 'purple', 'violet', 'pink', 'green-dark', 'green', 'green-light', 'black', or 'white')

options.extraIcon.number String

不使用图标,而定义数字或字母 ('1' or 'A', must set icon: 'fa-number')

options.extraIcon.prefix String

icon库的基础类 (fa or see icon library's documentation)

options.extraIcon.shape String

标记的形状 ('circle', 'square', 'star', or 'penta')

options.extraIcon.zoomRate String

缩放比例 (建议:0.3~3.0)

options.draggable Boolean

标记是否支持拖动

options.keyboard Boolean

标记是否支持键盘操作

options.title String

悬浮在标记上时的提示信息

options.alt String

icon没有图像时的占位信息

options.opacity String

标记的透明度

options.label String

标签,支持html

Emit:

click

当用于单击时触发

dblclick

当用于双击时触发

Public Methods

public addToMapView(mapview: Object, isAddDraw: Boolean): Null source

添加标记到mapview

Params:

NameTypeAttributeDescription
mapview Object

mapview对象

isAddDraw Boolean

是否添加到Draw中,默认为true

Return:

Null

public bindPopup(content: String | HTML, options: Object): MapMarker source

绑定弹出框

Params:

NameTypeAttributeDescription
content String | HTML

弹出框内容

options Object

设置参数

options.offset Point

弹出框的偏移

options.maxWidth Number

弹出框的最大宽度,单位像素

options.minWidth Number

弹出框的最小宽度

options.maxHeight Number

如果窗口的内容超过了它,在弹出窗口中将会出现滚动条

Return:

MapMarker

public bindTooltip(content: String | HTML, options: Object): MapMarker source

绑定提示信息

Params:

NameTypeAttributeDescription
content String | HTML

提示信息内容

options Object

设置参数

options.offset Point

提示信息的偏移

options.opacity Number

提示信息的透明度

Return:

MapMarker

public closePopup(): Null source

关闭信息框

Return:

Null

public getBounds(): * source

Return:

*

public openPopup(latlng: LatLng): Null source

弹出信息框

Params:

NameTypeAttributeDescription
latlng LatLng

目标位置(可选)

Return:

Null

public remove(): Null source

移除标记

Return:

Null

public slideTo(latlng: LatLng, options: Object): Null source

平滑移动标记

Params:

NameTypeAttributeDescription
latlng LatLng

目标位置

options Object

设置选项

options.duration Number

移动动画的持续时间,毫秒

options.keepAtCenter Boolean

是否保持标记在地图中心点

Return:

Null

public unbindPopup(): Null source

移除弹出框.

Return:

Null

public unbindTooltip(): Null source

移除提示信息

Return:

Null