功能核心: 地理坐标转屏幕坐标
用到的插件:jquery animo动画插件
核心代码:
var point = new Point(lon, lat, map.spatialReference); var screenPnt = map.toScreen(point);功能代码:
for (var i = 0; i < json.length; i++) {
var title = json[i].title; var lon = json[i].lon; var lat = json[i].lat; var value = json[i].value; var code = json[i].code;
//自己定义标签 var html = ""; html += " "; html += " "; lve = coustomTool.getLveAndColor(value);html += " " + title + " "; html += " " + value + " "; html += "
"; html += " ";
//地理坐标转屏幕坐标并设置点位div的位置 var point = new Point(lon, lat, map.spatialReference); var screenPnt = map.toScreen(point);
$("#ring" + i).css({ "left": screenPnt.x - 19 + "px", "top": screenPnt.y + 25 + "px", "position": "absolute", "z-index": "10", "cursor": "pointer" });
$("body").append(html); }
//点位动画效果
$(".class_mapIcoDiv").animo({ animation: ["rollIn"], duration: 0.5 }); $(".class_mapIcoDiv").bind("mouseover", function () { $(this).animo({ animation: ["pulse"], duration: 0.5 }); });
var panStart = dojo.connect(map, "onPanStart", function () { $(".ring").css("display", "none"); $(".esriPopup").css("display", "none"); }); var panEnd = dojo.connect(map, "onPanEnd", function () { for (var i = 0; i < json.length; i++) { var x = json[i].lon; var y = json[i].lat; var point = new Point(x, y, map.spatialReference); screenPnt = map.toScreen(point); $("#ring" + i).css({ "left": screenPnt.x - 19 + "px", "top": screenPnt.y + 25 + "px", "position": "absolute", "display": "block", "z-index": "1" }); } $(".esriPopup").css("display", "block"); }); var zoomStart = dojo.connect(map, "onZoomStart", function () { $(".ring").css("display", "none"); $(".esriPopup").css("display", "none"); }); var zoomEnd = dojo.connect(map, "onZoomEnd", function () { for (var i = 0; i < json.length; i++) { var x = json[i].lon; var y = json[i].lat; var point = new Point(x, y, map.spatialReference); screenPnt = map.toScreen(point); $("#ring" + i).css({ "left": screenPnt.x - 19 + "px", "top": screenPnt.y + 25 + "px", "position": "absolute", "display": "block", "z-index": "1" }); } $(".esriPopup").css("display", "block"); }); //将地图事件的句柄加入到句柄集合中。 config._eventHandlers.push(panStart); config._eventHandlers.push(panEnd); config._eventHandlers.push(zoomStart); config._eventHandlers.push(zoomEnd);