텐 센트 클 라 우 드 지 도 를 통합 하여 기하학 적 도형 을 그립 니 다.
공식 편집 사례:https://lbs.qq.com/webApi/javascriptV2/jsGuide/jsCover
통합 그리 기 및 편집 코드 는 다음 과 같 습 니 다.
코드 에 있 는 키 를 자기 것 으로 바 꾸 세 요!
:
: ctrl
: delete
: , ,
: ,
: ,
: esc , ,
var map, editor, shape;
function drawShape(e) {
console.log("drawPolygon!!: ", e)
shape = e
document.getElementById(shape).className = "toolItem active";
editor.setActiveOverlay(shape)
editor.setActionMode(TMap.tools.constants.EDITOR_ACTION.DRAW);
};
function initMap() {
//
map = new TMap.Map("map-container", {
zoom: 17, //
center: new TMap.LatLng(40.04019000341765, 116.27446815226199) //
});
//
editor = new TMap.tools.GeometryEditor({
map, //
overlayList: [ //
{
overlay: new TMap.MultiPolygon({
map,
styles: {
highlight: new TMap.PolygonStyle({
color: 'rgba(255, 255, 0, 0.6)'
}),
highlight2: new TMap.PolygonStyle({
color: 'rgba(255, 0, 0, 0.6)'
})
}
}),
id: 'polygon',
selectedStyleId: 'highlight'
}, {
overlay: new TMap.MultiCircle({
map,
styles: {
highlight2: new TMap.CircleStyle({
color: 'rgba(255, 0, 0, 0.6)'
})
}
}),
id: 'circle',
selectedStyleId: 'highlight2'
}
],
actionMode: TMap.tools.constants.EDITOR_ACTION.INTERACT, //
activeOverlayId: 'polygon', //
selectable: true, //
snappable: true //
});
// 、 、 、
let evtList = ['delete', 'adjust'];
evtList.forEach(evtName => {
editor.on(evtName + '_complete', evtResult => {
console.log(evtName, evtResult);
});
});
// ,
editor.on('draw_complete', (geometry) => {
document.getElementById(shape).className = "toolItem";
editor.setActionMode(TMap.tools.constants.EDITOR_ACTION.INTERACT);
});
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
vue 통합 텐 센트 맵 구현 api(DEMO 첨부).이전 프로젝트 는 텐 센트 지 도 를 사 용 했 기 때문에 사용 하기 좋 은 것 같 습 니 다.그러나 공식 적 인 demo 는 대부분이 원생 js 이 고 기초 가 있 으 며 많은 고급 Api 분포 가 분산 되 어 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.