vue接入高德地图

使用 JSAPI 安全模式,代理服务请以_AMapService 作为一级路由

index.html

html 复制代码
  <script type="text/javascript">
    window._AMapSecurityConfig = {
      serviceHost: "http://xx.xx.xx.xx:8223/_AMapService"
    };
  </script>
  <script type="text/javascript" src="https://webapi.amap.com/maps?v=2.0&key=你的高德key"></script>

nginx配置

Nginx 复制代码
	# 前端服务
     server {
         listen       8223;
         server_name  8223;
         charset utf-8;
 
		  location / {
                 root   /root/qianduan/前端代码;
                 try_files $uri $uri/ /index.html;
                 index  index.html index.htm;
                 add_header Access-Control-Allow-Origin *;
         }

        location /_AMapService/v4/map/styles {
             set $args "$args&jscode=你自己的安全密钥";
             proxy_pass http://webapi.amap.com/v4/map/styles;
         }
 
         # 海外地图服务代理
         location /_AMapService/v3/vectormap {
             set $args "$args&jscode=你自己的安全密钥";
             proxy_pass http://fmap01.amap.com/v3/vectormap;
         }
 
         # Web服务API 代理
         location /_AMapService/ {
             set $args "$args&jscode=你自己的安全密钥";
             proxy_pass http://restapi.amap.com/;
         }
   }

使用

js 复制代码
	new AMap.Map('mapContainer', {
      zoom: 10,
      center: [108.931284, 34.382289]
    })
相关推荐
linweidong2 小时前
C++ 模块化编程(Modules)在大规模系统中的实践难点?
linux·前端·c++
leobertlan5 小时前
2025年终总结
前端·后端·程序员
子兮曰6 小时前
OpenClaw架构揭秘:178k stars的个人AI助手如何用Gateway模式统一控制12+通讯频道
前端·javascript·github
Howrun7776 小时前
VSCode烦人的远程交互UI讲解
ide·vue.js·vscode
百锦再6 小时前
Reactive编程入门:Project Reactor 深度指南
前端·javascript·python·react.js·django·前端框架·reactjs
莲华君6 小时前
React快速上手:从零到项目实战
前端·reactjs教程
百锦再6 小时前
React编程高级主题:测试代码
android·前端·javascript·react.js·前端框架·reactjs
易安说AI7 小时前
Ralph Loop 让Claude无止尽干活的牛马...
前端·后端
颜酱8 小时前
图结构完全解析:从基础概念到遍历实现
javascript·后端·算法
失忆爆表症8 小时前
05_UI 组件库集成指南:Shadcn/ui + Tailwind CSS v4
前端·css·ui