五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

mapbox-gl開發(fā):動態(tài)畫線標(biāo)繪

2022-07-19 08:56 作者:地理信息技術(shù)雜談  | 我要投稿

在mapbox-gl地圖上,實現(xiàn)動態(tài)畫線的效果,點(diǎn)擊左鍵增加畫線的點(diǎn),鼠標(biāo)移動,實現(xiàn)線隨著鼠標(biāo)移動位置的效果,點(diǎn)擊右鍵結(jié)束畫線。

mapbox-gl接口實現(xiàn)標(biāo)繪數(shù)據(jù)存儲在geojson數(shù)據(jù)中,通過添加數(shù)據(jù)源、修改數(shù)據(jù)源,實現(xiàn)地圖上的標(biāo)繪數(shù)據(jù)實時更新。

添加geojson數(shù)據(jù)源:

? ? ??this.map.addSource(this.sourceid,?{

? ? ? ? ? ??type:?'geojson',

? ? ? ? ???data:?this.geojsondata

? ?????})

添加線標(biāo)繪圖層,設(shè)置線標(biāo)繪的屬性信息:

? ???this.map.addLayer({

? ? ? ?id:?this.linelayerid,

? ? ? ?type:?'line',

? ? ? ?source:?this.sourceid,

? ? ????layout:?{

? ? ? ? ?'line-cap':?'round',

? ? ? ? ??'line-join':?'round'

? ? ? ?},

? ? ? ? paint:?{

? ? ? ? ?'line-color':?'#f00',

? ? ? ? ?'line-width':?2

? ? ? ?},

? ?????filter:?['in',?'$type',?'LineString']

? ? })

鼠標(biāo)動態(tài)移動事件,線的終點(diǎn)隨著鼠標(biāo)移動

this.mapmousemovefunc?=?function?(e)?{

????const?_editfeature?=?scope.geojsondata.features[scope.getEditFeatureid()]

????_editfeature.geometry.coordinates.splice(_editfeature.geometry.coordinates.length?-?1,?1,?[e.lngLat.lng,?e.lngLat.lat])

????scope.map.getSource(scope.sourceid).setData(scope.geojsondata)

??}

鼠標(biāo)點(diǎn)擊事件,分為初次點(diǎn)擊和之后點(diǎn)擊的事件

??this.mapclickfunc?=?function?(e)?{

????if?(_isfirst)?{

再次點(diǎn)擊鼠標(biāo),修改最后一個點(diǎn),并新增點(diǎn)

??????const?_editfeature?=?scope.geojsondata.features[scope.getEditFeatureid()]

??????_editfeature.geometry.coordinates.splice(_editfeature.geometry.coordinates.length?-?1,?1,?[e.lngLat.lng,?e.lngLat.lat])

??????_editfeature.geometry.coordinates.push([e.lngLat.lng,?e.lngLat.lat])

??????let?_centerpos?=?turf.centroid(scope.geojsondata)?

??????_editfeature.properties.centerpos?=??_centerpos.geometry.coordinates

??????scope.map.getSource(scope.sourceid).setData(scope.geojsondata)

????}?else?{

? ?初次點(diǎn)擊鼠標(biāo),創(chuàng)建線數(shù)據(jù)

??????_isfirst?=?true

??????scope.editfeatureid?=?scope.createuuid()

??????scope.geojsondata.features.push({

????????type:?'Feature',

????????geometry:?{

??????????type:?'LineString',

??????????coordinates:?[

????????????[e.lngLat.lng,?e.lngLat.lat],

????????????[e.lngLat.lng?+?0.000001,?e.lngLat.lat]

??????????]

????????},

????????properties:?{

??????????id:?scope.editfeatureid,

??????????sourceid:?scope.sourceid,

??????????isdraw:?true,

??????????centerpos:?[e.lngLat.lng,?e.lngLat.lat],?

??????????color:?'#f00',

??????????opacity:?0.7

????????}

??????})

??????scope.map.on('mousemove',?scope.mapmousemovefunc)

????}

??}

//增加鼠標(biāo)點(diǎn)擊,右鍵結(jié)束標(biāo)繪事件

this.map.on('click',?this.mapclickfunc)

this.maprightclickfunc?=?function?()?{

????scope.stop()

??}

??this.map.on('contextmenu',?this.maprightclickfunc)



mapbox-gl開發(fā):動態(tài)畫線標(biāo)繪的評論 (共 條)

分享到微博請遵守國家法律
乌兰察布市| 教育| 正安县| 清水县| 钦州市| 定边县| 阳原县| 绥棱县| 洛南县| 银川市| 互助| 阳城县| 佛学| 游戏| 台南县| 江华| 托里县| 紫阳县| 全椒县| 哈尔滨市| 望江县| 呼玛县| 左贡县| 库尔勒市| 晋江市| 达拉特旗| 北辰区| 城固县| 扶绥县| 长汀县| 龙胜| 大渡口区| 禹州市| 清水河县| 乐都县| 光山县| 汾阳市| 仪陇县| 富阳市| 喜德县| 巴彦淖尔市|