使用用户的地理定位位置作为从 MapBox 在 GoogleMaps 中打开的固定位置方向链接的起点

问题描述 投票:0回答:0

https://codepen.io/lasconcore/pen/NWBezmw

你好,

在此先感谢您收到的任何帮助

我对 JS 很陌生,我正在尝试添加设备地理定位位置的使用作为地名固定终点的起点(可在左侧栏上单击)——目前我有这个设置来打开一个固定起点和终点的 GoogleMaps 窗口方向仅供试用

// Add geolocate control to the map.
    map.addControl(
        new mapboxgl.GeolocateControl({
            positionOptions: {
                enableHighAccuracy: true
            },
            // When active the map will receive updates to the device's location as it changes.
            trackUserLocation: true,
            // Draw an arrow next to the location dot to indicate which direction the device is heading.
            showUserHeading: true
        })
    );

                const itemLink = document.createElement('a');
        
                const label = 
                `${feature.properties.PlaceName}  
                ${feature.properties.Dog}  
                ${feature.properties.Squirrel}  
                ${feature.properties.Deer}  
                ${feature.properties.Sheep}  
                ${feature.properties.Fox}  
                ${feature.properties.Duck}  
                ${feature.properties.Water}  
                ${feature.properties.Frisbee}  
                ${feature.properties.Wood}  
                ${feature.properties.Hills}  
                ${feature.properties.Refreshments}  
                ${feature.properties.Camping}`;
              
              //Fixed location googlemaps directions link
               itemLink.href = feature.properties.Directions;
              //opens blank webpage from item link
              itemLink.target = '_blank';``

我在 Stack Overflow 上发现了类似的问题,但无法将这些答案转移到我的场景中

javascript html google-maps mapbox-gl-js
© www.soinside.com 2019 - 2024. All rights reserved.