惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
博客园 - 聂微东
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
美团技术团队
The Cloudflare Blog
云风的 BLOG
云风的 BLOG
WordPress大学
WordPress大学
A
About on SuperTechFans
D
DataBreaches.Net
博客园_首页
月光博客
月光博客
MongoDB | Blog
MongoDB | Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
酷 壳 – CoolShell
酷 壳 – CoolShell
P
Proofpoint News Feed
博客园 - 三生石上(FineUI控件)
小众软件
小众软件
B
Blog
腾讯CDC
Microsoft Security Blog
Microsoft Security Blog
T
Tailwind CSS Blog
雷峰网
雷峰网
T
The Blog of Author Tim Ferriss
宝玉的分享
宝玉的分享

博客园 - ^Mao^

不同缩放下适配 vxe-table 3D饼图 openlayer实现给线的附近添加点,点支持移动 element-plus el-select html导出pdf openlayers增加移动功能 适配 部分页面统计用户访问时长 openlayers基本使用(街景+标注+绘制) 正则表达式--取对应表达式的值 vue2实现el-table-column多级效果 echarts-雷达图 echarts--地图 散点图效果 echarts散点图区域设置 vant 的vant-uploader组件问题 Threejs学习 Echarts-普通地图和3D地图实现 test
使用openlayer绘制街景地图
^Mao^ · 2025-10-09 · via 博客园 - ^Mao^

相关资料

实现效果

示例代码

<template>
  <div class="app">
    <div class="map-container" ref="map_ref"></div>
  </div>
</template>

<script>
import Map from "ol/Map.js";
import OSM from "ol/source/OSM.js";
import TileLayer from "ol/layer/Tile.js";
import View from "ol/View.js";
import XYZ from "ol/source/XYZ.js";

export default {
  data() {
    return {};
  },
  mounted() {
    this.initMap();
  },
  methods: {
    initMap() {
      // const map = new Map({
      //   target: this.$refs.map_ref,
      //   layers: [
      //     new TileLayer({
      //       source: new XYZ({
      //         url: "https://webst0{1-4}.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}",
      //       }),
      //     }),
      //   ],
      //   view: new View({
      //     center: [0, 0],
      //     zoom: 2,
      //   }),
      // });

      // 创建卫星图层
      const satelliteLayer = new TileLayer({
        source: new XYZ({
          url: "https://webst0{1-4}.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}",
          maxZoom: 18,
        }),
        opacity: 0.9,
        zIndex: 1,
      });

      // 创建街道图层作为备用
      const streetLayer = new TileLayer({
        source: new XYZ({
          url: "https://webst0{1-4}.is.autonavi.com/appmaptile?style=7&x={x}&y={y}&z={z}",
          maxZoom: 18,
        }),
        zIndex: 0,
        visible: false,
      });
      const map = new Map({
        target: this.$refs.map_ref,
        layers: [satelliteLayer, streetLayer],
        view: new View({
          center: [0, 0],
          zoom: 2,
        }),
      });
    },
  },
};
</script>

<style lang="less" scoped>
.map-container {
  height: 500px;
  // background-color: orange;
}
</style>