Marker

概述

绘制Marker

用法示例

// 在地图设置一个marker
FMap.marker([50.5, 30.5]).addTo(map);

创建(Creation)

创建:

创建 描述
FMap.marker( <LatLng> latlng, <Marker options> options? ) 实例化一个marker对象,给定坐标点与配置项

选项(Options)

选项:

选项 类型 默认值 描述
icon FMap.Icon * (图标):图标类用来表达注记,参加Icon documentation以了解自定义注记图标的详细信息,默认设置为new FMap.Icon.Default()
clickable Boolean TRUE (可点击):如果是false,注记则不产生鼠标事件并表现为底层地图的一部分
draggable Boolean FALSE (可拖动):决定注记是否可被鼠标或触摸拖动
keyboard Boolean TRUE 键盘enter键是否可以在marker间进行切换
title String '' 最低地图的缩放级别,覆盖任何minZoom映射层
alt String '' 设置图标或图像的alt属性文本
zIndexOffset Number 0 默认情况下,注记图片的叠置顺序由纬度自动设置,如果你想将某一注记放置于其他之上可用这个选项,设置一个较大的值即可,比如1000(或是相反地设置一个较大的负值)
opacity Number 1 (不透明度):决定注记的不透明度
riseOnHover Boolean FALSE (凸显):如果此值为true,则当把鼠标放置于注记之上时,注记会显示与其他注记之上
riseOffset Number 250 (凸显补偿):riseOnHover要素凸显时高度的补偿值

事件(Events)

事件:

事件 类型(Data) 描述
click MouseEvent (点击):当鼠标点击注记时触发
dblclick MouseEvent (双击):当鼠标双击注记时触发
mousedown MouseEvent (鼠标按下):当鼠标按下鼠标键时触发
mouseover MouseEvent (鼠标经过):当鼠标在注记上时触发
mouseout MouseEvent (鼠标移出):当鼠标离开注记时触发
contextmenu MouseEvent (文本菜单):当鼠标右击注记时触发
dragstart Event (拖动开始):当用户拖动注记时触发
drag Event (拖动):当用户拖动注记时不断触发
dragend DragEndEvent (拖动结束):当用户停止拖动注记时触发
move Event (移动):当注记通过定义经纬度而移动时触发,新的坐标包含事件参数
add Event 添加marker到地图上时触发
remove Event (删除):当注记在地图上被删除时触发
popupopen PopupEvent 当marker上的popup打开时触发
popupclose PopupEvent 当marker上的popup关闭时触发

方法(Methods)

方法:

方法 参数 返回值 描述
addTo() <Map> map this 在地图上添加注记
getLatLng() LatLng 返回当前注记的地理位置
setLatLng() <LatLng> latlng this 将注记位置更改到给定点
setIcon() <Icon> icon this 更改注记的图标
setZIndexOffset() <Number> offset this 更改注记的zIndex offset
setOpacity() <Number> opacity this 更改注记的透明度
update() this 更新注记的位置,在直接更改经纬度对象的坐标时比较有用
bindPopup() <String> html |<HTMLElement> el |<Popup> popup,<Popup options> options? this 当点击一个注记时绑定一个特定的HTML内容的弹出窗口,你也可以用Marker中的openPopup方法打开绑定的弹出窗口
unbindPopup() this 将先前用bindPopup方法绑定的注记取消
openPopup() this 打开先前用bindPopup方法绑定的弹出框
getPopup() Popup 返回之前由bindPopup()方法绑定的popup
closePopup() this 关闭已打开的注记的弹出框
togglePopup() this 切换之前由bindPopup()方法绑定的popup
setPopupContent() <String> html |<HTMLElement> el this 设置此标记下弹出框的HTML内容
toGeoJSON() Object 返回marker的GeoJSON表示(GeoJSON Point 功能)

属性(Interaction handlers)

//在marker进行互动时,启用或禁用某些功能如拖动(详见IHandler方法)的属性,示例:            
marker.dragging.disable();

属性:

属性 类型 描述
dragging IHandler Marker dragging handler (by both mouse and touch).

results matching ""

    No results matching ""