2014-02-19 61 views
1

我想製作一個地圖,我可以附上標記。圖像還可以放大和縮小鼠標滾動。問題在於標記不會隨着縮放而流動。此外,標記點擊時幾乎沒有顯示。任何想法?jQuery附加地圖標記

<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

+1

聽起來像是你需要看看你使用任何庫,它提供'wheelzoom()'。 – Palpatim

+1

有道理!我找到了... – Grasper

回答

0

聽起來像是你需要看看你使用任何庫,提供wheelzoom()