gpt4 book ai didi

javascript - jQuery 附加 map 标记

转载 作者:行者123 更新时间:2023-11-28 08:30:47 25 4
gpt4 key购买 nike

我正在尝试制作一张可以附加标记的 map 。图像还可以通过鼠标滚动来放大和缩小。问题是标记不随缩放而流动。此外,单击时标记几乎不会显示。有什么想法吗?

<div class="custom"></div>
<div id="map1"></div>

$(document).ready(function(){

$('#map1').html('<img src="http://www.newlondon-tours.com/public/maps/london-city-map-free-england.jpg" alt="custom" class="custom_img" style="position:absolute;z-index:1" />');
$('.custom_img').wheelzoom();
$(".custom_img").click(function(e){
var offset_t = $(this).offset().top - $(window).scrollTop();
var offset_l = $(this).offset().left - $(window).scrollLeft();
var left = Math.round( (e.clientX - offset_l) );
var top = Math.round( (e.clientY - offset_t) );

$('.custom').append('<p style="z-index:11;font-size:100px;border:1px solid #000;border-radius: 10px;background:red;width:10px;height:10px;position:absolute;left:' + left + 'px;top:'+ top +'px" ></p>');

});

})

Demo

最佳答案

听起来您需要查看您正在使用的提供 wheelzoom() 的库

关于javascript - jQuery 附加 map 标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21888815/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com