html接入腾讯地图

1.申请key

key申请地址:https://lbs.qq.com/dev/console/application/mine

官方文档

https://lbs.qq.com/webApi/javascriptGL/glGuide/glBasic

2.html接入示例

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>腾讯地图demo</title>
</head>
<script charset="utf-8" src="https://map.qq.com/api/gljs?v=1.exp&key=YOUR_KEY"></script>
<style type="text/css">
    html, body {
        height: 100%;
        margin: 0px;
        padding: 0px;
    }

    #container {
        width: 100%;
        height: 100%;
    }
</style>

<body onload="initMap()">
<div id="container"></div>
<script type="text/javascript">
    function initMap() {
        var center = new TMap.LatLng(29.421945, 104.69849);
        // 初始化地图
        var map = new TMap.Map("container", {
            rotation: 0, // 设置地图旋转角度
            pitch: 0, // 设置俯仰角度(0~45)
            zoom: 16, // 设置地图缩放级别
            center: center // 设置地图中心点坐标
        });

        // 创建并初始化MultiMarker
        var markerLayer = new TMap.MultiMarker({
            map: map,
            // 样式定义
            styles: {
                "myStyle": new TMap.MarkerStyle({
                    "width": 35,
                    "height": 50,
                    // "src": 'C:/Users/16/Desktop/demo.jpeg',
                    // 焦点在图片中的像素位置
                    "anchor": {x: 0, y: 50}
                })
            },
            // 点标记数据数组
            geometries: [{
                "id": "1", // 点标记唯一标识
                "styleId": 'myStyle', // 指定样式id
                "position": center,
                "properties": {
                    "title": "世界无花果博览园"
                }
            }]
        });
    }
</script>
</body>

</html>
相关推荐
恋猫de小郭7 小时前
Flutter Zero 是什么?它的出现有什么意义?为什么你需要了解下?
android·前端·flutter
崔庆才丨静觅13 小时前
hCaptcha 验证码图像识别 API 对接教程
前端
passerby606114 小时前
完成前端时间处理的另一块版图
前端·github·web components
掘了14 小时前
「2025 年终总结」在所有失去的人中,我最怀念我自己
前端·后端·年终总结
崔庆才丨静觅14 小时前
实用免费的 Short URL 短链接 API 对接说明
前端
崔庆才丨静觅15 小时前
5分钟快速搭建 AI 平台并用它赚钱!
前端
崔庆才丨静觅15 小时前
比官方便宜一半以上!Midjourney API 申请及使用
前端
Moment15 小时前
富文本编辑器在 AI 时代为什么这么受欢迎
前端·javascript·后端
崔庆才丨静觅16 小时前
刷屏全网的“nano-banana”API接入指南!0.1元/张量产高清创意图,开发者必藏
前端
剪刀石头布啊16 小时前
jwt介绍
前端