I am using am_map.js from https://www.jqueryscript.net/other/leaflet-map-interactive-layer.html. But my map picker icon not work

huangapple go评论51阅读模式
英文:

I am using am_map.js from https://www.jqueryscript.net/other/leaflet-map-interactive-layer.html. But my map picker icon not work

问题

抱歉,以下是您要翻译的内容:

>! 这是脚本
>! 我尝试了来自cdnjs和图像地址的图标但没有起作用其他的都正常

$(document).ready(function() {
    let lati = Number($('.lat').val());
    let long = Number($('.long').val());

    let map = $("#myMap").am_map({
        // 地图中心
        center: [lati, long],
        // 地图高度
        height: '400px',
        background: 'osm',
    });

>! 这是关于图标缩放和点的部分

    $("#myMap").am_map('addLayer', {
        // 唯一名称
        name: 'iconLayer',
        // 标记点
        points: [lati, long],
        // 自定义图标HTML
        icon: '<img src="https://imgv3.fotor.com/images/blog-cover-image/part-blurry-image.jpg">',
        // 初始缩放级别
        zoom: 15,
        // 图层可见的缩放级别
        limitZoom: 18,
    });

});
英文:

>! This is script.
>! I tried icons from cdnjs and image address but no work. Others work fine.

  $(document).ready(function() {
        let lati = Number($(&#39;.lat&#39;).val());
        let long = Number($(&#39;.long&#39;).val());

        let map = $(&quot;#myMap&quot;).am_map({
            // center of the map
            center: [lati, long],
            // map height
            height: &#39;400px&#39;,
            background: &#39;osm&#39;,
        });

>! This is for icon, zoom and points

        $(&quot;#myMap&quot;).am_map(&#39;addLayer&#39;, {
            // unique name
            name: &#39;iconLayer&#39;,
            // marker point
            points: [lati, long],
            // custom icon HTML
            icon: &#39;&lt;img src=&quot;https://imgv3.fotor.com/images/blog-cover-image/part-blurry- 
            image.jpg&quot;&gt;&#39;,
            // initial zoom level
            zoom: 15,
            // zoom level at which the layer is visible
            limitZoom: 18,
        });

    });

答案1

得分: 1

现在,我知道我忘记阅读那条评论 "// 图层可见的缩放级别"。哈哈

英文:

Now, I knew I forgot to read that comment "// zoom level at which the layer is visible". Haha

huangapple
  • 本文由 发表于 2023年6月9日 09:43:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/76436685.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定