当前位置:   article > 正文

Echarts绘制地图带标记tooltip_echarts地图标记点 tooltip

echarts地图标记点 tooltip

全国各地区JSON文件网址

.agency_information {
  width: 250px;
  padding: 5px 0;
  background: transparent;
  border-radius: 5px;
}
.agency_title {
  min-width: 150px;
  height: auto;
  margin-bottom: 6px;
  font-size: 14px;
  color: #ffffff;
  font-weight: normal;
  text-align: center;
}
.agency_type {
  color: #fe0101;
}
.agency_info_row {
  box-sizing: border-box;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  width: 100%;
  height: auto;
  padding-left: 10px;
  background: #ffffff33;
  margin-bottom: 4px;
  font-size: 12px;
  color: #ffffff;
  font-weight: normal;
}
.agency_info_row > label:first-child {
  width: 60px;
  height: auto;
  margin-right: 20px;
  text-align: left;
}


<div class="map" id="map" style="width:900px;height:900px;"></div>


function ecMapServicer(name) {
  var uploadedDataURL = "json/wuhan.json";
  // 基于准备好的dom,初始化echarts实例
  const myChart = echarts.init(document.getElementById(name));

  /*  {name:'武汉', geoCoord:[114.31, 30.52]}, x-y坐标轴起点[113.45, 29.95] */
  var data_type_1 = [{
      type: "一类",
      name: "五零四文化广场",
      value: [114.31, 30.1222, 120]
    },
    {
      type: "一类",
      name: "五零四文化广场",
      value: [114.41, 30.32, 120]
    },
    {
      type: "一类",
      name: "五零四文化广场",
      value: [114.39, 30.52, 120]
    },
    {
      type: "一类",
      name: "五零四文化广场",
      value: [114.73, 30.72, 120]
    }
  ];
  var data_type_2 = [{
      type: "二类",
      name: "五零四文化广场",
      value: [114.2133, 30.1222, 120]
    },
    {
      type: "二类",
      name: "五零四文化广场",
      value: [114.01, 30.3222, 120]
    },
    {
      type: "二类",
      name: "五零四文化广场",
      value: [114.59, 30.82, 120]
    },
    {
      type: "二类",
      name: "五零四文化广场",
      value: [114.73, 30.72, 120]
    }
  ];
  var data_type_3 = [{
      type: "三类",
      name: "五零四文化广场",
      value: [114.27, 31.292, 120]
    },
    {
      type: "三类",
      name: "五零四文化广场",
      value: [114.21, 30.72, 120]
    },
    {
      type: "三类",
      name: "五零四文化广场",
      value: [114.429, 30.12, 120]
    },
    {
      type: "三类",
      name: "五零四文化广场",
      value: [114.73, 30.62, 120]
    }
  ];

  // 显示加载动画
  myChart.showLoading();
  $.getJSON(uploadedDataURL, null, function (data) {
    echarts.registerMap("mapData", data);
    myChart.hideLoading();

    option = {
      color: ["#91c7ae", "#749f83", "#ca8622"], //颜色组
      tooltip: {
        trigger: "item",
        show: true,
        padding: 0,
        backgroundColor: "#ffffff33",
        formatter: function (params) {
          var str = `
          <div class="agency_information">
          <div class="agency_title">
            ${params.name}
            <label class="agency_type">(${params.data.type})</label>
          </div>
          <div class="agency_info_row">
            <label>建立时间:</label><label> 2007(使用)</label>
          </div>
          <div class="agency_info_row">
            <label>负责人:</label><label> 张建华 </label>
          </div>
          <div class="agency_info_row">
            <label>床位数: </label><label> 200 </label>
          </div>
          <div class="agency_info_row">
            <label>联系方式:</label><label> 125697415266</label>
          </div>
          <div class="agency_info_row">
            <label>地址:</label><label> 武汉市xxxxxxxx</label>
          </div>
        </div>
          `;
          return str;
          /* if (typeof params.value[2] == "undefined") {
            return params.name + " : " + params.value;
          } else {
            return params.name + " : " + params.value[2];
          } */
        }
      },
      grid: {
        top: 100
      },
      legend: {
        orient: "vertical",
        icon: "pain",
        right: '10%',
        bottom: '10%',
        itemWidth: 20,
        itemHeight: 12,
        align: "left",
        textStyle: {
          color: "#fff",
          fontSize: 12
        },
        data: ["一类", "二类", "三类"]
      },
      xAxis: {
        show: false
      },
      yAxis: {
        show: false
      },
      geo: {
        show: true,
        map: "mapData",
        label: {
          normal: {
            show: false
          },
          emphasis: {
            show: false
          }
        },
        zoom: 1.2,
        roam: true,
        itemStyle: {
          areaColor: "#1A2B75",
          borderColor: "#3fdaff",
          borderWidth: 1
        },
        emphasis: {
          itemStyle: {
            areaColor: "#2B91B7"
          }
        }
      },
      series: [
        // 一类
        {
          name: "一类",
          type: "scatter",
          coordinateSystem: "geo",
          symbol: "image://img/icon_location_1.png",//自行找图标
          symbolSize: [14, 16],
          label: {
            normal: {
              show: false,
              backgroundColor: "#0D1151",
              position: "right",
              color: "#ffffff",
              fontSize: "14",
              padding: 20
            },
            emphasis: {
              show: false
            }
          },
          itemStyle: {
            normal: {
              color: "#00A0E9", //控制图例和地图标记点的颜色
              borderWidth: 2
            }
          },
          data: data_type_1
        },
        // 二类
        {
          name: "二类",
          type: "scatter",
          coordinateSystem: "geo",
          symbol: "image://img/icon_location_2.png",
          symbolSize: [14, 16],
          label: {
            normal: {
              show: false,
              backgroundColor: "#2B91B7",
              position: "right",
              color: "#ffffff",
              fontSize: "14",
              padding: 20
            },
            emphasis: {
              show: false
            }
          },
          itemStyle: {
            normal: {
              color: "#11D53F", //控制图例和地图标记点的颜色
              borderWidth: 2
            }
          },
          data: data_type_2
        },
        // 三类
        {
          name: "三类",
          type: "scatter",
          coordinateSystem: "geo",
          symbol: "image://img/icon_location_3.png",
          symbolSize: [14, 16],
          label: {
            normal: {
              show: false,
              backgroundColor: "#2B91B7",
              position: "right",
              color: "#ffffff",
              fontSize: "14",
              padding: 20
            },
            emphasis: {
              show: false
            }
          },
          itemStyle: {
            normal: {
              color: "#E39F28",
              borderWidth: 2
            }
          },
          data: data_type_3
        }
      ]
    };
    myChart.setOption(option);
  });
  myChart.setOption(option);
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/308623
推荐阅读
相关标签
  

闽ICP备14008679号