我目前是打开图层的新手。而且我在使用 jquery 使用 mouseover 事件时遇到了麻烦。我使用 jquery 创建了一个工具提示,这个工具提示将输出地图中的坐标。这是我的例子。
<?php
$init = "
map.events.register('mouseover', map, function (e) {
var lonlat = map.getLonLatFromViewPortPx(e.xy);
var selMinX=lonlat.lon-sizeSelection;
var selMaxX=lonlat.lon+sizeSelection;
var selMinY=lonlat.lat-sizeSelection;
var selMaxY=lonlat.lat+sizeSelection;
alert(e.pageX); // Showing the event.pageX isn't working.
alert(selMinX); // Showing also one of the variables above isn't working.
alert('hello'); // This msgbox works.
$(document).ready( function() {
// Obviously I need to comment the mouseover function here
// since I am already using the mouseover event.
// $('#map').mouseover(function(e) {
$('<div id='tooltip'><input type='text' id='coor'/></div>').appendTo('body');
// });
});
});
";
?>
现在,我的地图没有显示,因为我认为将工具提示附加到正文部分的代码有问题。我在这里要实现的是在文档上显示带有输入框的div。
谢谢。