# 二.BingMaps

# 1.瓦片图

  • 必应地图,双地图同时缩放

查看代码详情
<template>
  <div>
    <div ref="map1" class="map" style="height: 300px"></div>
    <div ref="map2" class="map" style="margin-top: 10px; height: 300px"></div>
  </div>
</template>
  
  <script>
export default {
  mounted() {
    let {
      Map,
      View,
      layer: { Tile: TileLayer },
      source: { BingMaps },
    } = ol;
    const view = new View({
      center: [-4808600, -2620936],
      zoom: 8,
    });
    const map1 = new Map({
      layers: [
        new TileLayer({
          preload: Infinity,
          source: new BingMaps({
            key: mapkeys.BingMaps,
            imagerySet: "Aerial",
          }),
        }),
      ],
      target: this.$refs.map1,
      view: view,
    });
    const map2 = new Map({
      layers: [
        new TileLayer({
          preload: 0,
          source: new BingMaps({
            key: mapkeys.BingMaps,
            imagerySet: "AerialWithLabelsOnDemand",
          }),
        }),
      ],
      target: this.$refs.map2,
      view: view,
    });
  },
};
</script>
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