supermap 学习系列(二)——添加标注(鼠标点击弹出窗口)
来源:互联网 发布:网络投资服务产品收益 编辑:程序博客网 时间:2024/05/23 19:19
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <script src="json_parse.js"></script> <script src="toJSON.js"></script> <script src="libs/SuperMap.Include.js"></script> <script type="text/javascript"> var map, layer, vectorLayer, control, selectFeature; // 设置访问的GIS服务地址 var url = "http://localhost:8090/iserver/services/map-ChinaTestWorkPlace/rest/maps/ChinaTest"; function GetMap() { // 创建地图对象 map = new SuperMap.Map("map"); //control = new SuperMap.Control.MousePosition(); //该控件显示鼠标移动时,所在点的地理坐标。 //map.addControl(control); //添加控件 // 创建图层对象 layer = new SuperMap.Layer.TiledDynamicRESTLayer("World", url, { transparent: true, cacheEnabled: true }, { maxResolution: "auto" }); layer.events.on({ "layerInitialized": addLayer }); } // 加载图层 function addLayer() { // 向Map添加图层 map.addLayer(layer); map.setCenter(new SuperMap.LonLat(116.409749, 39.912344), 1);
//添加大头针标记 var markerlayers = new SuperMap.Layer.Markers("Markers"); map.addLayer(markerlayers); var marker = new SuperMap.Marker(new SuperMap.LonLat(116.409749, 39.912344)); markerlayers.addMarker(marker);
//例如点击marker弹出popup marker.events.on({ "mouseover": openInfoWin, "mouseout": closeInfoWin, "click": clickHandler, "scope": marker // 还不清楚这行代码是什么意思! 如果有大神赐教,我不甚感激! }); } var infowin = null; function openInfoWin() { closeInfoWin(); var marker = this; var lonlat = marker.lonlat; var contentHTML = "<div style='font-size:.8em; opacity: 0.8; overflow-y:hidden;'>"; contentHTML += "<div>Hello Word</div></div>"; var popup = new SuperMap.Popup.FramedCloud("popwin", new SuperMap.LonLat(lonlat.lon, lonlat.lat), null, contentHTML, null, true); infowin = popup; map.addPopup(popup); } function closeInfoWin() { if (infowin) { try { infowin.hide(); infowin.destroy(); } catch (e) { } } } function clickHandler() { closeInfoWin(); var marker = this; alert("Hello Word,我被点击了!"); } </script></head><body onload="GetMap()"> <div id="map" style="height: 640px; width: 720px; border: 1px solid red; margin-left: auto; margin-right: auto;"></div></body></html>
效果图如下:
- supermap 学习系列(二)——添加标注(鼠标点击弹出窗口)
- supermap学习系列(七)——用户自己在地图上添加点、线、面标注
- supermap学习系列(五)——上一篇的续集(鼠标单击或者移动,高亮显示并弹出对话框)
- supermap学习系列(六)——上一篇的另一种版本(鼠标单击或者移动,高亮显示并弹出对话框)
- supermap 学习系列(四)——鼠标到哪里亮哪里(高亮显示)
- 百度地图的覆盖物自定义(二)--点击标注物弹出完全自定义的信息提示窗口(不继承百度提供的Infowindow)
- supermap 学习系列(三)——在地图上绘制线段(鼠标放在上面时改变其颜色)
- Openlayers进阶学习——多标注显示/点击弹出框/图层控制/搜索定位/新增标注等
- supermap学习系列之silverlight--添加可拖拽的定位图钉(方法一)
- supermap学习系列之silverlight--添加可拖拽的定位图钉(方法二之超图自带类(Pushpin、InfoWindow))
- supermap学习系列之silverlight--添加可拖拽的定位图钉(方法二之超图自带类(Pushpin、InfoWindow)) 续 解决上一篇的问题
- supermap 学习系列(一)——加载地图(rest方式)
- supermap学习系列(八)——上一篇的另一种实现方式(给要素图层SuperMap.Layer.Vector注册事件)
- WPF——MVVM点击弹出窗口
- SuperMap超图——点位标注和callout
- DataGrid鼠标经过感知以及点击行弹出窗口
- GridView 实现 鼠标经过感知及点击行弹出窗口
- QT笔记(4)——Qt的lineEdit添加鼠标点击事件
- JS Arrary length
- linux上读取apk信息
- 拓扑排序-- 确定比赛名次
- Linux系统下如何查看及修改文件读写权限
- 算法搜集
- supermap 学习系列(二)——添加标注(鼠标点击弹出窗口)
- JS Size 和 Length 的区别
- Java对zip文件的各种操作
- Linux 中 crontab 详解及示例(收藏)
- 用PDMReader工具生成数据库设计文档
- Xcode中other linker flag的设置
- hive 部署需要注意的几点以及Version information not found 错误解决办法
- C语言经典算法100例-008-输出乘法口诀
- 注意访问级别的使用,尤其是不同包的加载时如何调用