|
|
@@ -6,6 +6,7 @@ var imgSvgMap = new Map([
|
|
|
{
|
|
|
width: '19px',
|
|
|
height: '23px',
|
|
|
+ trueHeight: 23,
|
|
|
innerHTML: `
|
|
|
<path fill-rule="evenodd" opacity="0.502" fill="rgb(0, 0, 0)"
|
|
|
d="M31.000,50.787 C47.016,50.787 60.000,55.715 60.000,61.793 C60.000,67.872 47.016,72.799 31.000,72.799 C14.984,72.799 2.000,67.872 2.000,61.793 C2.000,55.715 14.984,50.787 31.000,50.787 Z"/>
|
|
|
@@ -16,10 +17,11 @@ var imgSvgMap = new Map([
|
|
|
},
|
|
|
],
|
|
|
[
|
|
|
- 'merchat',
|
|
|
+ 'merchant',
|
|
|
{
|
|
|
width: '23px',
|
|
|
height: '26px',
|
|
|
+ trueHeight: 26,
|
|
|
innerHTML: `
|
|
|
<path fill-rule="evenodd" opacity="0.502" fill="rgb(0, 0, 0)"
|
|
|
d="M35.000,55.988 C51.016,55.988 64.000,60.916 64.000,66.994 C64.000,73.072 51.016,78.000 35.000,78.000 C18.984,78.000 6.000,73.072 6.000,66.994 C6.000,60.916 18.984,55.988 35.000,55.988 Z"/>
|
|
|
@@ -34,6 +36,7 @@ var imgSvgMap = new Map([
|
|
|
{
|
|
|
width: '40px',
|
|
|
height: '38px',
|
|
|
+ trueHeight: 38,
|
|
|
innerHTML: `
|
|
|
<path fill-rule="evenodd" opacity="0.502" fill="rgb(0, 0, 0)"
|
|
|
d="M62.000,94.921 C78.016,94.921 91.000,99.849 91.000,105.927 C91.000,112.006 78.016,116.933 62.000,116.933 C45.984,116.933 33.000,112.006 33.000,105.927 C33.000,99.849 45.984,94.921 62.000,94.921 Z"/>
|
|
|
@@ -55,6 +58,7 @@ Marker.prototype = new TMap.DOMOverlay();
|
|
|
Marker.prototype.onInit = function(options) {
|
|
|
this.position = options.position;
|
|
|
this.type = options.type;
|
|
|
+ this.nowStatus = options.nowStatus;
|
|
|
};
|
|
|
|
|
|
// 销毁时需解绑事件监听
|
|
|
@@ -66,24 +70,69 @@ Marker.prototype.onDestroy = function() {
|
|
|
|
|
|
// 创建DOM元素,返回一个DOMElement,使用this.dom可以获取到这个元素
|
|
|
Marker.prototype.createDOM = function() {
|
|
|
- let svg = document.createElementNS(SVG_NS, 'svg');
|
|
|
+ if (this.markerType === 'text') {
|
|
|
+ let div = document.createElement('div');
|
|
|
+ div.style.display = 'flex';
|
|
|
+ div.style.flexDirection = 'column';
|
|
|
+ div.style.alignItems = 'center';
|
|
|
+ let innerDiv = document.createElement('div');
|
|
|
+ innerDiv.style.backgroundColor = 'rgb(255,255,255)';
|
|
|
+ innerDiv.style.padding = '5px 10px';
|
|
|
+ innerDiv.style.fontSize = '14px';
|
|
|
+ innerDiv.style.color = '#FFB11E';
|
|
|
+ let svgInfo = imgSvgMap.get(this.type);
|
|
|
+ innerDiv.style.transform =
|
|
|
+ 'translateY(-' + (svgInfo.trueHeight + 10) + 'px)';
|
|
|
+ innerDiv.innerHTML = this.title;
|
|
|
+ div.appendChild(innerDiv);
|
|
|
+ div.addEventListener(
|
|
|
+ 'touchend',
|
|
|
+ () => {
|
|
|
+ this.emit('click');
|
|
|
+ },
|
|
|
+ false,
|
|
|
+ );
|
|
|
+ return div;
|
|
|
+ } else {
|
|
|
+ let div = document.createElement('div');
|
|
|
+ div.style.display = 'flex';
|
|
|
+ div.style.flexDirection = 'column';
|
|
|
+ div.style.alignItems = 'center';
|
|
|
+ div.style.position = 'absolute';
|
|
|
+ div.style.left = '0px';
|
|
|
+ div.style.top = '0px';
|
|
|
|
|
|
- let svgInfo = imgSvgMap.get(this.type);
|
|
|
- svg.setAttribute('viewBox', svgInfo.viewBox);
|
|
|
- svg.setAttribute('width', svgInfo.width);
|
|
|
- svg.setAttribute('height', svgInfo.height);
|
|
|
- svg.style.cssText = 'position:absolute;top:0px;left:0px;';
|
|
|
- svg.innerHTML = svgInfo.innerHTML;
|
|
|
+ let svg = document.createElementNS(SVG_NS, 'svg');
|
|
|
+ let svgInfo = imgSvgMap.get(this.type);
|
|
|
+ svg.setAttribute('viewBox', svgInfo.viewBox);
|
|
|
+ svg.setAttribute('width', svgInfo.width);
|
|
|
+ svg.setAttribute('height', svgInfo.height);
|
|
|
+ svg.innerHTML = svgInfo.innerHTML;
|
|
|
+ div.appendChild(svg);
|
|
|
+ if (this.nowStatus.nowImgType === this.type) {
|
|
|
+ let innerDiv = document.createElement('div');
|
|
|
+ innerDiv.style.backgroundColor = 'rgb(255,255,255)';
|
|
|
+ innerDiv.style.padding = '5px 10px';
|
|
|
+ innerDiv.style.fontSize = '14px';
|
|
|
+ innerDiv.style.color = '#FFB11E';
|
|
|
+ innerDiv.style.position = 'absolute';
|
|
|
+ innerDiv.style.left = '50%';
|
|
|
+ innerDiv.style.top = '-' + (svgInfo.trueHeight + 10) + 'px';
|
|
|
+ innerDiv.style.transform = 'translateX(-50%)';
|
|
|
+ innerDiv.style.whiteSpace = 'nowrap';
|
|
|
+ innerDiv.innerHTML = this.nowStatus.name;
|
|
|
+ div.appendChild(innerDiv);
|
|
|
+ }
|
|
|
|
|
|
- svg.addEventListener(
|
|
|
- 'touchend',
|
|
|
- () => {
|
|
|
- this.emit('click');
|
|
|
- },
|
|
|
- false,
|
|
|
- );
|
|
|
-
|
|
|
- return svg;
|
|
|
+ div.addEventListener(
|
|
|
+ 'touchend',
|
|
|
+ () => {
|
|
|
+ this.emit('click');
|
|
|
+ },
|
|
|
+ false,
|
|
|
+ );
|
|
|
+ return div;
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
// 更新DOM元素,在地图移动/缩放后执行
|