日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

SuperMap webGIS 简易提示框示例

發(fā)布時間:2025/4/14 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SuperMap webGIS 简易提示框示例 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

先看一下效果;服務要先啟動;

圖上兩個圖標是自己添加的marker;

marker是SuperMap.Marker類的對象;

彈出提示框;里面可以帶圖片;

說明一下代碼;

<link href='./css/bootstrap.min.css' rel='stylesheet' />
<link href='./css/bootstrap-responsive.min.css' rel='stylesheet' />
<script src='../libs/SuperMap.Include.js'></script>
這段是包含超圖的庫,和看你要用哪個前端框架來實現(xiàn)頁面效果;

var host = document.location.toString().match(/file:\/\//)?"http://localhost:8090":'http://' + document.location.host;
var map, layerWorld,marker,markers;
var url=host+"/iserver/services/map-world/rest/maps/World";
function init(){
map = new SuperMap.Map("map",{controls: [
new SuperMap.Control.ScaleLine(),
new SuperMap.Control.Zoom(),
new SuperMap.Control.LayerSwitcher(),
new SuperMap.Control.Navigation({
dragPanOptions: {
enableKinetic: true
}
})]
});
這段是加載地圖底圖和地圖控件;控件包含導航、縮放、圖層切換等控件;

var host = document.location.toString().match(/file:\/\//)?"http://localhost:8090":'http://' + document.location.host;
var url=host+"/iserver/services/map-world/rest/maps/World";
這個是地圖服務地址;不用動態(tài)編碼,直接寫 url=地圖服務地址 也行;

layerWorld = new SuperMap.Layer.TiledDynamicRESTLayer("World", url);
layerWorld.events.on({"layerInitialized": addLayer});
markers = new SuperMap.Layer.Markers("Markers");
layerWorld.events.on({"layerInitialized": addMarker});
這段是加載圖層;

彈出提示框的代碼說明如下;
popup = new SuperMap.Popup(
"chicken",
marker.getLonLat(),
new SuperMap.Size(220,140),
'<img src="images/xila.jpg">',
true,
null
);
要new一個SuperMap.Popup類的對象,在此定義提示框的圖片;
定義大小使用SuperMap.Size類;
提示框的彈出位置是在一個Marker上,marker.getLonLat()獲取marker的經(jīng)緯度;
然后
? ? map.addPopup(popup);
把提示框添加到地圖上;

添加一個marker的代碼說明如下;
首先要new一個Marker層;
markers = new SuperMap.Layer.Markers("Markers");
然后
? ? map.addLayers([layerWorld,markers]);
把Marker層添加到地圖,此語句添加了2個圖層,layerWorld和markers;

添加一個具體的marker;
size = new SuperMap.Size(21,25);
offset = new SuperMap.Pixel(-(size.w/2), -size.h);
icon = new SuperMap.Icon('images/markerbig_select.png', size, offset);
marker = new SuperMap.Marker(new SuperMap.LonLat(23.6530190,37.9439259),icon);
markers.addMarker(marker);
定義marker的大小、位置、圖標,然后new出marker對象,然后把marker對象添加到Marker層;

?

再看一個提示框示例;

提示框里面可以是文字,或者一些html/css的東西;上圖是一個html表格;

提示框代碼如下;

var contentHTML2 = "<div>";
contentHTML2 += "<table border='1'>";
contentHTML2 += "<tr>";
contentHTML2 += " ?<td>100</td>";
contentHTML2 += " ?<td>200</td>";
contentHTML2 += " ?<td>300</td>";
contentHTML2 += "</tr>";
contentHTML2 += "<tr>";
contentHTML2 += " ?<td>400</td>";
contentHTML2 += " ?<td>500</td>";
contentHTML2 += " ?<td>600</td>";
contentHTML2 += "</tr>";
contentHTML2 += "</table>";?
contentHTML2 += "</div>";?

framedCloud2 = new SuperMap.Popup.FramedCloud(
"chicken",?
marker.getLonLat(),
null,
contentHTML2,
icon,
true,
null,
true
);

此提示框使用?SuperMap.Popup.FramedCloud 類;

?

要用哪個類自己看幫助;要有一定前端調(diào)試能力,否則效果出不來;具體看超圖幫助和示例;

總結(jié)

以上是生活随笔為你收集整理的SuperMap webGIS 简易提示框示例的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。