除了支持 通用属性 以外,还支持如下属性。
名称 | 类型 | 默认值 | 是否必填 | 描述 |
|---|---|---|---|---|
latitude | number | 默认为当前位置,否则为北京 | 否 | 中心纬度。 |
longitude | number | 默认为当前位置,否则为北京 | 否 | 中心经度。 |
coordtype | string | gcj02 | 否 | 中心坐标的坐标系。可选值为:wgs84,gcj02。 |
scale | number | 11 | 否 | 缩放级别,4-20。 |
rotate | number | 0 | 否 | 逆时针旋转角度。 |
markers | array | 0 | 否 | 用于标记地图上的点。支持子属性,详细请参见“markers子属性”。 |
showmylocation | boolean | false | 否 | 显示带有方向的当前定位点。 |
polylines | array | - | 否 | 路线。支持子属性,详细请参见“polylines子属性”。 |
polygons(1050+) | array | - | 否 | 多边形。支持子属性,详细请参见“polygons子属性”。 |
circles | array | - | 否 | 地图上显示圆。支持子属性,详细请参见“circles子属性”。 |
controls | array | - | 否 | 控件。支持子属性,详细请参见“controls子属性”。 |
groundoverlays | array | - | 否 | 贴图。支持子属性,详细请参见“groundoverlays 子属性”。 |
includepoints | array | - | 否 | 缩放视野以包含所有给定的坐标点。 |
showcompass(1040+) | boolean | true | 否 | 是否显示指南针,设置为true时,旋转地图后指南针出现。 |
showscale(1070+) | boolean | false | 否 | 是否展示默认比例尺控件。 |
showzoom(1070+) | boolean | false | 否 | 是否展示放大缩小功能控件。 |
enableoverlooking(1040+) | boolean | false | 否 | 控制启用或禁用俯视(3D)功能,默认关闭。如果启用,则用户可使用双指向下或向上滑动到俯视图。 |
enablezoom(1040+) | boolean | true | 否 | 是否支持缩放。 |
enablescroll(1040+) | boolean | true | 否 | 是否支持拖动。 |
enablerotate(1040+) | boolean | true | 否 | 是否支持旋转。 |
markers子属性:
名称 | 类型 | 默认值 | 是否必填 | 描述 |
|---|---|---|---|---|
id | number | -1 | 否 | 每个标记点的唯一标识。 |
latitude | number | - | 是 | 标记点纬度。 |
longitude | number | - | 是 | 标记点经度。 |
offsetX | number | - | 否 | 标记点固定位置,屏幕的X坐标。设置了offsetX,offsetY后,marker的坐标位置将不再生效。 |
offsetY | number | - | 否 | 标记点固定位置,屏幕的Y坐标。设置了offsetX,offsetY后,marker的坐标位置将不再生效。 |
coordType | string | gcj02 | 否 | 标记点坐标坐标系。可选值为:wgs84,gcj02。 |
title | string | - | 否 | 标记点名称。 |
iconPath | uri | - | 是 | 标记图标资源路径,支持本地图片以及http和https协议的网络图片。 |
opacity | number | 1 | 否 | 标记透明度,0 ~ 1。 |
rotate | number | 0 | 否 | 逆时针旋转角度。 |
width | length | 标记图实际宽度 | 否 | 标记图宽度。 |
height | length | 标记图实际高度 | 否 | 标记图高度。 |
anchor | object | {x:0.5,y:1} | 否 | 标记点在标记图标的位置。
|
callout | object | - | 否 | 标记点上方的文本弹窗。支持子属性,详细请参见“markers-callout子属性”。 |
label(1040+) | object | - | 否 | 标记点周边展示文本。支持子属性,详细请参见“markers-label子属性”。 |
zIndex | number | - | 否 | z轴坐标。 |
markers-callout子属性:
名称 | 类型 | 默认值 | 是否必填 | 描述 |
|---|---|---|---|---|
content | string | - | 是 | 文本内容。 |
color | color | #000000 | 否 | 字体颜色。 |
fontSize | number | 30px | 否 | 文本字号。 |
borderRadius | length | 0px | 否 | 边框圆角。 |
padding | length | 0px | 否 | 文本边缘留白,支持1 ~ 4个参数。 |
backgroundColor | color | #ffffff | 否 | 背景色。 |
display | byclick | always | byclick | 否 | 点击触发显示还是常显。 |
textAlign | left | right | center | center | 否 | 文本对齐方式。 |
convertHtml(1040+) | boolean | false | 否 | content内容是否以html格式展示。 |
markers-label子属性(1040+):
名称 | 类型 | 默认值 | 是否必填 | 描述 |
|---|---|---|---|---|
content | string | - | 是 | 文本内容。 |
color | color | #000000 | 否 | 字体颜色。 |
fontSize | number | 30px | 否 | 文本字号。 |
anchorX | number | 0 | 否 | label的坐标,原点是 marker 对应的经纬度,对应水平偏移。 |
anchorY | number | 0 | 否 | label的坐标,原点是 marker 对应的经纬度,对应垂直偏移。 |
borderRadius | length | 0px | 否 | 边框圆角。 |
padding | length | 0px | 否 | 文本边缘留白,支持1 ~ 4个参数。 |
backgroundColor | color | #00ffffff | 否 | 背景色。 |
textAlign | left | right | center | center | 否 | 文本对齐方式。 |
polylines子属性:
名称 | 类型 | 默认值 | 是否必填 | 描述 |
|---|---|---|---|---|
points | array | - | 是 | 路线上点的数组[\{latitude, longitude, coordType}]。coordType为可选字段,不填缺省为gcj02。 |
color | color | #666666 | 否 | 路线颜色。 |
width | length | 10px | 否 | 路线宽度。 |
dotted | boolean | false | 否 | 是否为虚线。 |
zIndex | number | - | 否 | z轴坐标。 |
arrowLine(1050+) | boolean | false | 否 | 是否展示带箭头纹理的线。 |
arrowIconPath(1050+) | string | - | 否 | 更换纹理的图片的路径,在arrowLine为true时生效。 |
polygons子属性:
名称 | 类型 | 默认值 | 是否必填 | 描述 |
|---|---|---|---|---|
points | array | - | 是 | 经纬度数组,[{latitude, longitude, coordType}]。最少需要3个不同的地点。 |
strokeWidth | length | 5px | 否 | 描边的宽度。 |
strokeColor | color | #666666 | 否 | 描边的颜色。 |
fillColor | color | #666666 | 否 | 填充的颜色。 |
zIndex | number | - | 否 | 多边形Z轴坐标。 |
circles子属性:
名称 | 类型 | 默认值 | 是否必填 | 描述 |
|---|---|---|---|---|
latitude | number | - | 是 | 圆心的纬度。 |
longitude | number | - | 是 | 圆心的经度。 |
coordType | string | gcj02 | 否 | 圆心坐标坐标系。可选值为:wgs84,gcj02。 |
radius | number | - | 是 | 半径(单位:米) |
fillColor | color | #666666 | 否 | 填充颜色。 |
borderWidth | length | 5px | 否 | 描边的宽度。 |
borderColor | color | #666666 | 否 | 描边的颜色。 |
zIndex | number | - | 否 | z轴坐标。 |
groundoverlays子属性:
名称 | 类型 | 默认值 | 是否必填 | 描述 |
|---|---|---|---|---|
id | number | -1 | 否 | 贴图id。 |
northEast | object | - | 是 | 贴图东北角坐标,{latitude, longitude, coordType}。coordType为可选字段,不填缺省为gcj02。 |
southWest | object | - | 是 | 贴图西南角坐标,{latitude, longitude, coordType}。coordType为可选字段,不填缺省为gcj02。 |
iconPath | uri | - | 否 | 图片资源的相对路径。 |
opacity | number | 1 | 否 | 透明度,0 ~ 1。 |
visible | boolean | true | 否 | 可见性。 |
zIndex | number | - | 否 | z轴坐标。 |
controls子属性:
名称 | 类型 | 默认值 | 是否必填 | 描述 |
|---|---|---|---|---|
id | number | -1 | 否 | 控件的id。 |
position | object | - | 否 | 控件相对地图组件的位置。支持子属性,详细请参见“controls-position子属性”。 |
iconPath | string | - | 是 | 控件的图标存放路径。 |
clickable | boolean | true | 否 | 是否可点击。 |
controls-position子属性:
<map> 除了支持 通用样式 以外,还支持如下样式
名称 | 类型 | 默认值 | 是否必填 | 描述 |
|---|---|---|---|---|
mylocation | - | - | - | 简写属性,在一个声明中设置所有的mylocation属性,可以按顺序设置属性mylocation-fill-color mylocation-stroke-color mylocation-icon-path,不设置的值为默认值 |
mylocation-fill-color | color | rgba(135, 206, 235, 0.15) | 否 | 定位精度圈填充颜色。支持透明(rgba(0,0,0,0))。 |
mylocation-stroke-color | color | rgba(135, 206, 235, 0.15) | 否 | 定位精度圈描边颜色。支持透明(rgba(0,0,0,0))。 |
mylocation-icon-path | uri | - | 否 | 标记图标资源的本地绝对路径。 |
<map> 除了支持 通用事件 以外,还支持如下事件。
名称 | 参数 | 描述 |
|---|---|---|
loaded | - | 地图渲染更新完成时触发。 |
regionchange | {southwest,northwest,causeBy(1040+)} | 视野发生变化时触发。causeBy表示视角改变的原因,包括以下四个值:
|
tap | {latitude, longitude} | 点击地图时触发。 |
markertap | {markerId} | 点击地图标记点时触发。 |
callouttap | {markerId} | 点击标记点对应弹窗触发。 |
controltap | {controlId} | 点击控件触发。 |
poitap(1050+) | {OBJECT} | 点击地图poi点时触发。返回值请参见“poitap的OBJECT参数列表”。 |
通过如下方法,可以对 <map> 进行操作。
名称 | 参数 | 描述 |
|---|---|---|
getCenterLocation | OBJECT | 获取地图中心点坐标,方法参数说明请参见“getCenterLocation的OBJECT参数列表”。 |
translateMarker | OBJECT | 在地图上移动marker,方法参数说明请参见“translateMarker的OBJECT参数列表”。 |
moveToMyLocation | - | 将地图中心点移动到当前位置坐标。 |
includePoints | OBJECT | 缩放地图,展示所有给定坐标点,方法参数说明请参见“includePoints的OBJECT参数列表”。 |
getRegion | OBJECT | 获取当前地图视野范围,方法参数说明请参见“getRegion的OBJECT参数列表”。 |
getScale | OBJECT | 获取地图的放大级别,方法参数说明请参见“getScale的OBJECT参数列表”。 |
getCoordType | OBJECT | 获取地图当前使用的坐标系,方法参数说明请参见“getCoordType的OBJECT参数列表”。 |
convertCoord | OBJECT | 对坐标的坐标系进行转换,方法参数说明请参见“convertCoord的OBJECT参数列表”。 |
setScalePosition(1070+) | OBJECT | 设置地图默认比例尺控件相对地图左上角的距离,方法参数说明请参见“setScalePosition的OBJECT参数列表”。 说明: 该方法建议放在loaded事件中调用,或者在loaded事件完成后再调用。 |
setZoomPosition(1070+) | OBJECT | 设置地图默认放大缩小控件相对地图左上角的距离,方法参数说明请参见“setZoomPosition的OBJECT参数列表”。 说明: 该方法建议放在loaded事件中调用,或者在loaded事件完成后再调用。 |
setCompassPosition(1070+) | OBJECT | 设置指南针相对地图左上角的距离,方法参数说明请参见“setCompassPosition的OBJECT参数列表”。 说明: 该方法建议放在loaded事件中调用,或者在loaded事件完成后再调用。 |
setMaxAndMinScaleLevel(1072+) | OBJECT | 自定义缩放级别限制,方法参数说明请参见“setMaxAndMinScaleLevel的OBJECT参数列表”。 |
getCenterLocation的OBJECT参数列表:
名称 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
success | function | 否 | 接口调用成功的回调函数, res = {latitude, longitude}。 |
fail | function | 否 | 接口调用失败的回调函数。 |
complete | function | 否 | 接口调用结束的回调函数。 |
translateMarker的OBJECT参数列表:
名称 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
markerId | number | 是 | 指定marker。 |
destination | object | 是 | 指定marker移动到的目标点(经纬度坐标)。 |
autoRotate | boolean | 否 | 移动过程中是否自动旋转marker。 |
rotate | number | 否 | marker的旋转角度,autoRotate为true,该值无效。 |
duration | number | 否 | 动画持续时长,默认值1000ms。 |
animationEnd | function | 否 | 动画结束回调函数。 |
success | function | 否 | 接口调用成功的回调函数。 |
fail | function | 否 | 接口调用失败的回调函数。 |
complete | function | 否 | 接口调用结束的回调函数。 |
includePoints的OBJECT参数列表:
名称 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
points | array | 是 | 需要显示在可视区域内的坐标点数组,[{latitude, longitude, coordType}]。coordType为可选字段,不填缺省为gcj02。 |
padding | string | 否 | 坐标点形成的最小矩形区域距离边缘的最小距离,支持1 ~ 4个参数,单位:px。 |
success | function | 否 | 接口调用成功的回调函数。 |
fail | function | 否 | 接口调用失败的回调函数。 |
complete | function | 否 | 接口调用结束的回调函数。 |
getRegion的OBJECT参数列表:
名称 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
success | function | 否 | 接口调用成功的回调函数, res = {southwest, northeast},西南角与东北角的经纬度。 |
fail | function | 否 | 接口调用失败的回调函数。 |
complete | function | 否 | 接口调用结束的回调函数。 |
getScale的OBJECT参数列表:
名称 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
success | function | 否 | 接口调用成功的回调函数,res = {scale}。 |
fail | function | 否 | 接口调用失败的回调函数。 |
complete | function | 否 | 接口调用结束的回调函数。 |
getCoordType的OBJECT参数列表:
名称 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
success | function | 否 | 接口调用成功的回调函数,res = {coordType},coordType取值为wgs84、gcj02。 |
fail | function | 否 | 接口调用失败的回调函数。 |
complete | function | 否 | 接口调用结束的回调函数。 |
convertCoord的OBJECT参数列表:
名称 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
from | string | 否 | 输入坐标当前的坐标系,目前只支持wgs84,默认为wgs84。 |
to | string | 否 | 输入坐标需要转换输出的坐标系,当前只支持gcj02,默认为gcj02。 |
latitude | number | 是 | 需要转换的坐标纬度。 |
longitude | number | 是 | 需要转换的坐标经度。 |
success | function | 否 | 接口调用成功的回调函数,res = {latitude, longitude}。 |
fail | function | 否 | 接口调用失败的回调函数。 |
complete | function | 否 | 接口调用结束的回调函数。 |
poitap的OBJECT参数列表:
setScalePosition的OBJECT参数列表(1070+)
setZoomPosition的OBJECT参数列表(1070+)
setCompassPosition的OBJECT参数列表(1070+)
setMaxAndMinScaleLevel的OBJECT参数列表(1072+)
//latitude 中心纬度
//longitude 中心经度
//coordtype 中心坐标的坐标系
//scale 缩放级别
//rotate 逆时针旋转角度
//loaded 地图渲染更新完成时触发
//regionchange 视野发生变化时触发
//tap 点击地图时触发
//getCenterLocation 获取地图中心点坐标
//getRegion 获取当前地图视野范围
//getScale 获取地图的缩放级别
//getCoordType 获取地图当前使用的坐标系
//convertCoord 对坐标的坐标系进行转换
<template>
<div class="item-container">
<map class="map" id = 'mapid' latitude=39.906901 longitude=116.397972 coordtype="gcj02" scale = 11
rotate=0 @loaded="loaded" @regionchange="regionchange" @tap="tap"></map>
<input type="button" class="btn" onclick="gotoGetCenter" value="获取中心点" />
<input type="button" class="btn" onclick="gotoGetRegion" value="获取视野范围" />
<input type="button" class="btn" onclick="gotoGetScale" value="获取地图缩放级别" />
<input type="button" class="btn" onclick="gotoGetCoordType" value="获取当前坐标系" />
<input type="button" class="btn" onclick="gotoConvertCoord" value="转换坐标系" />
</div>
</template>
<style>
.item-container {
flex-direction: column;
}
.btn {
height: 80px;
text-align: center;
border-radius: 5px;
color: #ffffff;
font-size: 30px;
background-color: #0faeff;
}
.map {
background-color: #a9a9a9;
width: 750px;
height: 750px;
}
#mapid {
}
</style>
<script>
module.exports = {
data: {
},
loaded () {
console.log('map has been loaded')
},
regionchange (event) {
console.log('map regionchange' + " northeast latitude " + event.northeast.latitude + " northeast longitude " + event.northeast.longitude + " southwest.latitude " + event.southwest.latitude + " southwest.longitude " + event.southwest.longitude + " causeBy " + event.causeBy)
},
tap (event) {
console.log('map tap' + " latitude " + event.latitude + " longitude " + event.longitude)
},
gotoGetCenter() {
var mapcom = this.$element('mapid')
mapcom.getCenterLocation({
success:function(data) {
console.log("getCenterLocation latitude = " + data.latitude + " longitude = " + data.longitude);
},
fail:function() {
console.log("getCenterLocation fail");
},
complete:function() {
console.log("getCenterLocation complete");
}
})
},
gotoGetRegion() {
var mapcom = this.$element('mapid')
mapcom.getRegion({
success:function(data) {
console.log("getRegion southwest = " + data.southwest + " northeast = " + data.northeast);
},
fail:function() {
console.log("getRegion fail");
},
complete:function() {
console.log("getRegion complete");
}
})
},
gotoGetScale() {
var mapcom = this.$element('mapid')
mapcom.getScale({
success:function(data) {
console.log("getScale scale = " + data.scale);
},
fail:function() {
console.log("getScale fail");
},
complete:function() {
console.log("getScale complete");
}
})
},
gotoGetCoordType() {
var mapcom = this.$element('mapid')
mapcom.getCoordType({
success:function(data) {
console.log("getCoordType coordtype = "+data.coordtype);
},
fail:function() {
console.log("getCoordType fail");
},
complete:function() {
console.log("getCoordType complete");
}
})
},
gotoConvertCoord() {
var mapcom = this.$element('mapid')
mapcom.convertCoord({
from:'wgs84',
to:'gcj02',
latitude:39.747872,
longitude:116.438955,
success:function(data) {
console.log("convertCoord latitude = " + data.latitude + " longitude = " + data.longitude);
},
fail:function() {
console.log("convertCoord fail");
},
complete:function() {
console.log("convertCoord complete");
}
})
}
}
</script> 示例代码效果图:

//showmylocation 显示带有方向的当前定位点
//mylocation 简写属性,在一个声明中设置所有的mylocation属性,可以按顺序设置属性mylocation-fill-color mylocation-stroke-color mylocation-icon-path
//mylocation-fill-color 定位精度圈填充颜色
//mylocation-stroke-color 定位精度圈描边颜色
//mylocation-icon-path 标记图标资源的本地绝对路径
//moveToMyLocation 将地图中心点移动到当前位置坐标
<template>
<div class="item-container">
<map class="map lc2" id = 'mapid' showmylocation='true'></map>
<input type="button" class="btn" onclick="moveTo" value="移动视角到当前位置" />
</div>
</template>
<style>
.item-container {
flex-direction: column;
}
.btn {
height: 80px;
text-align: center;
border-radius: 5px;
color: #ffffff;
font-size: 30px;
background-color: #0faeff;
}
.map {
background-color: #a9a9a9;
width: 750px;
height: 750px;
}
#mapid {
}
.lc1 {
mylocation:rgba(255, 0, 255, 0.5) rgba(255, 255, 0, 1) url(/Common/logo.png)
}
.lc2 {
mylocation-fill-color:rgba(255, 0, 255, 0.5);
mylocation-stroke-color:rgba(255, 255, 0, 1);
mylocation-icon-path:url(/Common/logo.png);
}
</style>
<script>
module.exports = {
data: {
},
moveTo() {
var mapcom = this.$element('mapid')
mapcom.moveToMyLocation()
}
}
</script> 示例代码效果图:

包含特定点的属性和方法
//includepoints 缩放视野以包含所有给定的坐标点
//includePoints 改变地图视角,展示所有给定坐标点
<template>
<div class="item-container">
<map class="map" id = 'mapid' latitude=39.906901 longitude=116.397972 includepoints={{tincludepoints}}></map>
<input type="button" class="btn" onclick="gotoInclude" value="包含某个地点" />
</div>
</template>
<style>
.item-container {
flex-direction: column;
}
.btn {
height: 80px;
text-align: center;
border-radius: 5px;
color: #ffffff;
font-size: 30px;
background-color: #0faeff;
}
.map {
background-color: #a9a9a9;
width: 750px;
height: 750px;
}
#mapid {
}
</style>
<script>
module.exports = {
data: {
tincludepoints:[{latitude: 39.074112, longitude: 116.686649}]
},
gotoInclude() {
var mapcom = this.$element('mapid')
mapcom.includePoints({
points:[{latitude:38.406665,longitude:116.995047,coordType:'gcj02'}],padding:"10px 0px 0px 10px",
success:function() {
console.log("includePoints success");
},
fail:function() {
console.log("includePoints fail");
},
complete:function() {
console.log("includePoints complete");
}
})
}
}
</script> 示例代码效果图:

//groundoverlays 贴图
<template>
<div class="item-container">
<map class="map" latitude=39.906901 longitude=116.397972 groundoverlays={{tgroundlay}}></map>
</div>
</template>
<style>
.item-container {
flex-direction: column;
}
.map {
background-color: #a9a9a9;
width: 750px;
height: 750px;
}
</style>
<script>
module.exports = {
data: {
tgroundlay: [{ 'id': 1, southWest: { latitude: 39.906901, longitude: 116.397972, coordType:'gcj02'},
northEast: { latitude: 39.776909, longitude: 116.596205, coordType:'gcj02'},
iconPath: '/Common/logo.png', visible: true, zIndex: 3, opacity: 1}]
}
}
</script> 示例代码效果图:

//circles 地图上显示圆
<template>
<div class="item-container">
<map class="map" latitude=39.906901 longitude=116.397972 circles={{tcircles}}></map>
</div>
</template>
<style>
.item-container {
flex-direction: column;
}
.map {
background-color: #a9a9a9;
width: 750px;
height: 750px;
}
</style>
<script>
module.exports = {
data: {
tcircles: [{ latitude: 39.806901, longitude: 116.597972, borderColor: '#ff0000', borderWidth: '15px',zIndex:20,
fillColor: '#EE7AE9', radius: 3500, strokeWidth: 15 }]
}
}
</script> 示例代码效果图:

// polylines 路线
<template>
<div class="item-container">
<map class="map" latitude=39.906901 longitude=116.397972 polylines={{tpolylines}}></map>
</div>
</template>
<style>
.item-container {
flex-direction: column;
}
.map {
background-color: #a9a9a9;
width: 750px;
height: 750px;
}
</style>
<script>
module.exports = {
data: {
tpolylines:[{
points:[{latitude:39.906901,longitude:116.397972,coordType:'gcj02'},
{latitude:39.074112,longitude:116.686649,coordType:'gcj02'},
{latitude:38.406665,longitude:116.995047,coordType:'gcj02'},
{latitude:38.406665,longitude:116.995047,coordType:'gcj02'}],
color:'#EE7AE9',dotted:true,width:'15px'
}]
}
}
</script> 示例代码效果图:

<template>
<div class="item-container">
<map class="map" latitude=39.906901 longitude=116.397972 polylines={{tpolylines}}></map>
</div>
</template>
<style>
.item-container {
flex-direction: column;
}
.map {
background-color: #a9a9a9;
width: 750px;
flex: 1;
}
</style>
<script>
module.exports = {
data: {
tpolylines:[{
points:[{latitude:39.906901,longitude:116.397972,coordType:'gcj02'},
{latitude:39.504112,longitude:116.686649,coordType:'gcj02'}],
color:'#EE7AE9',dotted:true,width:'15px',
arrowLine:true,arrowIconPath:'/Common/logo.png'
},
{
points:[{latitude:39.504112,longitude:116.686649,coordType:'gcj02'},
{latitude:39.206665,longitude:116.595047,coordType:'gcj02'}],
color:'#EE7AE9',dotted:false,width:'15px',
arrowLine:true
}]
}
}
</script> 示例代码效果图:

<template>
<div class="item-container">
<map class="map" latitude=39.906901 longitude=116.397972 polygons={{tpolygones}}></map>
</div>
</template>
<style>
.item-container {
flex-direction: column;
}
.map {
background-color: #a9a9a9;
width: 750px;
flex: 1;
}
</style>
<script>
module.exports = {
data: {
tpolygones:[{
points:[{latitude:39.906901,longitude:116.397972,coordType:'gcj02'},
{latitude:39.506901,longitude:116.097972,coordType:'gcj02'},
{latitude:39.006901,longitude:115.597972,coordType:'gcj02'}],
strokeWidth:'5px',strokeColor:'red',fillColor:'yellow'
}]
}
}
</script> 示例代码效果图:

//controls 控件
//controltap 点击控件触发
<template>
<div class="item-container">
<map class="map" id = 'mapid' latitude=39.906901 longitude=116.397972 controls={{tcontrols}} @controltap="controltap"></map>
</div>
</template>
<style>
.item-container {
flex-direction: column;
}
.btn {
height: 80px;
text-align: center;
border-radius: 5px;
color: #ffffff;
font-size: 30px;
background-color: #0faeff;
}
.map {
background-color: #a9a9a9;
width: 750px;
height: 750px;
}
#mapid {
}
</style>
<script>
module.exports = {
data: {
tcontrols:[{id: 1,position: {left:'20px',top:'20px',width:'150px',height:'150px'},iconPath:'/Common/logo.png',clickable:true},
{id: 2,position: {left:'20px',bottom:'20px',width:'150px',height:'150px'},iconPath:'/Common/logo.png',clickable:true},
{id: 3,position: {right:'20px',top:'20px',width:'150px',height:'150px'},iconPath:'/Common/logo.png',clickable:true},
{id: 4,position: {right:'20px',bottom:'20px',width:'150px',height:'150px'},iconPath:'/Common/logo.png',clickable:true}]
},
controltap (event) {
console.log('controltap id:' + event.id)
}
}
</script> 示例代码效果图:

//markers 用于标记地图上的点
//markertap 点击地图标记点时触发
//callouttap 点击标记点对应弹窗触发
//translateMarker 在地图上移动marker
<template>
<div class="item-container">
<map class="map" id = 'mapid' latitude=39.906901 longitude=116.397972 markers={{tmarkers}} @markertap="markertap"
@callouttap="callouttap"></map>
<input type="button" class="btn" onclick="translate" value="移动Marker" />
</div>
</template>
<style>
.item-container {
flex-direction: column;
}
.btn {
height: 80px;
text-align: center;
border-radius: 5px;
color: #ffffff;
font-size: 30px;
background-color: #0faeff;
}
.map {
background-color: #a9a9a9;
width: 750px;
height: 750px;
}
#mapid {
}
</style>
<script>
module.exports = {
data: {
tmarkers:[{id: 1,latitude: 39.906901,longitude: 116.397972,coordtype: "gcj02",title: "marker1",iconPath: "/Common/logo.png",opacity: 1,rotate: 90,width: '100px',height: '100px',
anchor:{x: 0.5,y: 0.5},callout: {content: "hello world",color: '#EE7AE9',fontSize: 50,borderRadius: '10px',padding: '5px',backgroundColor: '#a9a9a9',display: "byclick",textAlign: "left"}
},{id: 2,latitude: 39.074112,longitude: 116.686649,coordtype: "gcj02",title: "marker1",
iconPath: "/Common/logo.png",opacity: 1,rotate: 90,width: '200px',height: '200px',anchor:{x: 0.5,y: 0.5},callout: {content: "hello cbg",color: '#EE7AE9',fontSize: 50,borderRadius: '10px',padding: '5px',backgroundColor: '#a9a9a9',display: "byclick",textAlign: "left"}
}]
},
markertap (event) {
console.log('markertap id:' + event.id)
this.markerid = event.id
},
callouttap (event) {
console.log('callouttap id:' + event.id)
this.calloutid = event.id
},
translate() {
var mapcom = this.$element('mapid')
mapcom.translateMarker({
markerId: 2,
destination: {latitude:39.490833,longitude:116.255255},
autoRotate: true,
rotate: 180,
duration: 10000,
animationend() {
console.log("animationEnd");
},
success:function() {
console.log("translateMarker success");
},
fail:function() {
console.log("translateMarker fail");
},
complete:function() {
console.log("translateMarker complete");
}
})
}
}
</script> 示例代码效果图:

<template>
<div class="item-container">
<map class="map" latitude=39.906901 longitude=116.397972 showcompass={{tshowcompass}}
enableoverlooking={{tenableoverlooking}} enablezoom={{tenablezoom}}
enablescroll={{tenablescroll}} enablerotate={{tenablerotate}}></map>
<input type="button" class="btn" value="showcompass" onclick="changeshowcompass"/>
<input type="button" class="btn" value="enableoverlooking" onclick="changeenableoverlooking"/>
<input type="button" class="btn" value="enablezoom" onclick="changeenablezoom"/>
<input type="button" class="btn" value="enablescroll" onclick="changeenablescroll"/>
<input type="button" class="btn" value="enablerotate" onclick="changeenablerotate"/>
</div>
</template>
<style>
.item-container {
flex-direction: column;
}
.btn {
height: 80px;
text-align: center;
border-radius: 5px;
color: #ffffff;
font-size: 30px;
background-color: #0faeff;
}
.map {
background-color: #a9a9a9;
width: 750px;
height: 750px;
}
</style>
<script>
module.exports = {
data: {
tshowcompass:true,
tenableoverlooking:false,
tenablezoom:true,
tenablescroll:true,
tenablerotate:true
},
changeshowcompass() {
if (this.tshowcompass) {
this.tshowcompass = false
} else {
this.tshowcompass = true
}
},
changeenableoverlooking() {
if (this.tenableoverlooking) {
this.tenableoverlooking = false
} else {
this.tenableoverlooking = true
}
},
changeenablezoom() {
if (this.tenablezoom) {
this.tenablezoom = false
} else {
this.tenablezoom = true
}
},
changeenablescroll() {
if (this.tenablescroll) {
this.tenablescroll = false
} else {
this.tenablescroll = true
}
},
changeenablerotate() {
if (this.tenablerotate) {
this.tenablerotate = false
} else {
this.tenablerotate = true
}
}
}
</script> 示例代码效果图:

记点文本弹窗以html展示和在标记点周边展示文本
<template>
<div class="item-container">
<map class="map" id = 'mapid' latitude=39.906901 longitude=116.397972 markers={{tmarkers}} @markertap="markertap"
@callouttap="callouttap"></map>
<input type="button" class="btn" onclick="translate" value="移动Marker" />
</div>
</template>
<style>
.item-container {
flex-direction: column;
}
.btn {
height: 80px;
text-align: center;
border-radius: 5px;
color: #ffffff;
font-size: 30px;
background-color: #0faeff;
}
.map {
background-color: #a9a9a9;
width: 750px;
height: 1000px;
}
#mapid {
}
.t1 {
font-size: 25px;
}
</style>
<script>
module.exports = {
data: {
tmarkers:[{id: 1, latitude: 39.806901,longitude: 116.367972,coordtype: "gcj02",title: "marker1",
iconPath: "/Common/logo.png",opacity: 1,rotate: 90,width: '100px',height: '100px',
anchor:{x: 0.5,y: 0.5},
callout: {content: "<html><body>这是<font color=\"#ff0000\"><strong>html格式</strong></font>的文本弹框</body></html>",
color: '#000000',fontSize: "20px",borderRadius: "15px",
backgroundColor: '#dcdcdc',display: "byclick",textAlign: "left",
convertHtml:true},
label: {
content:"快餐店",color:'#ff0000',fontSize: '20px'}
},
{id: 2,latitude: 39.570112,longitude: 116.37666,coordtype: "gcj02",title: "marker1",
iconPath: "/Common/logo.png",opacity: 1,rotate: 90,width: '100px',height: '100px',
anchor:{x: 0.5,y: 0.5},
callout: {content: "这是普通格式的文本弹框",
color: '#000000',fontSize: "20px",borderRadius: "15px",
backgroundColor: '#dcdcdc',display: "byclick",textAlign: "left"},
label: {
content:"饮品店",color:'#ff0000',fontSize: '20px'}
}]
},
markertap (event) {
console.log('markertap id:' + event.markerId)
this.markerid = event.markerId
},
callouttap (event) {
console.log('callouttap id:' + event.markerId)
this.calloutid = event.markerId
},
translate() {
var mapcom = this.$element('mapid')
mapcom.translateMarker({
markerId: 2,
destination: {latitude:39.490833,longitude:116.255255},
autoRotate: true,
rotate: 180,
duration: 10000,
animationend() {
console.log("animationEnd");
},
success:function() {
console.log("translateMarker success");
},
fail:function() {
console.log("translateMarker fail");
},
complete:function() {
console.log("translateMarker complete");
}
})
}
}
</script> 示例代码效果图:


版本 | 发布日期 | 描述 |
|---|---|---|
1070 | 2020-05-19 |
|
1050 | 2019-09-20 |
|
1040 | 2019-06-24 |
|
1030 | 2018-10-31 | 第一次正式发布。 |