多地圖標記點

可同時於地圖上設置多個標記點。

範例展示

原始碼

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>多地圖標記點 - Map8 Platform Documentation</title>
    <link rel="stylesheet" href="https://api.map8.zone/css/gomp.css?key=[YOUR_KEY_HERE]" />
    <style>
        #map{
            height: 400px;
            width: 100%;
        }
    </style>
</head>
<body>
    <div id="map"></div>

    <script type="text/javascript" src="https://api.map8.zone/maps/js/gomp.js?key=[YOUR_KEY_HERE]"></script>
    <script type="text/javascript">
        gomp.accessToken = '[YOUR_KEY_HERE]';
        var pointsSource = {
            "id": "pois",
            "type": "symbol",
            "source": {
                "type": "geojson",
                "data": {
                    "type": "FeatureCollection",
                    "features": [{
                        "type": "Feature",
                        "properties": {
                            "description": "<strong>POST office</strong>",
                        },
                        "geometry": {
                            "type": "Point",
                            "coordinates": [121.520991, 25.046558]
                        }
                    },{
                        "type": "Feature",
                        "properties": {
                            "description": "<strong>Convenience store</strong>",
                        },
                        "geometry": {
                            "type": "Point",
                            "coordinates": [121.525502, 25.045425]
                        }
                    },{
                        "type": "Feature",
                        "properties": {
                            "description": "<strong>MRT station</strong>",
                        },
                        "geometry": {
                            "type": "Point",
                            "coordinates": [121.523707, 25.044451]
                        }
                    },{
                        "type": "Feature",
                        "properties": {
                            "description": "<strong>Pets park</strong>",
                        },
                        "geometry": {
                            "type": "Point",
                            "coordinates": [121.523738, 25.047023]
                        }
                    },{
                        "type": "Feature",
                        "properties": {
                            "description": "<strong>Art gallery</strong>",
                        },
                        "geometry": {
                            "type": "Point",
                            "coordinates": [121.524837, 25.044845]
                        }
                    }]
                }
            },
            "layout": {
                "icon-image": "park",
                "icon-allow-overlap": true
            }
        };

        var map = new gomp.Map({
            container: 'map', // 地圖容器 ID
            style: 'https://api.map8.zone/styles/go-life-maps-tw-style-std/style.json', // 地圖樣式檔案位置
            maxBounds: [[105, 15], [138.45858, 33.4]], // 台灣地圖區域
            center: [121.523366, 25.045826], // 初始中心座標,格式為 [lng, lat]
            zoom: 16, // 初始 ZOOM LEVEL; [0-20, 0 為最小 (遠), 20 ;最大 (近)]
            minZoom: 6, // 限制地圖可縮放之最小等級, 可省略, [0-19.99]
            maxZoom: 19.99, // 限制地圖可縮放之最大等級, 可省略 [0-19.99]
            speedLoad: false,
            attributionControl: false
        }).addControl(new gomp.AttributionControl({
            compact: false
        }));

        map.on('load', function(){
            map.addLayer(pointsSource);
        });
    </script>
</body>
</html>