<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title> 经纬度地图</title>
<style type="text/css">
body{
margin: 0;
overflow: hidden;
background: #fff;
}
#map{
position: relative;
height: 553px;
border:1px solid #3473b7;
}
</style>
<link href='css/bootstrap.min.css' rel='stylesheet' />
<link href='css/bootstrap-responsive.min.css' rel='stylesheet' />
<script src = 'libs/SuperMap.Include.js'></script>
<script type="text/javascript">
var map, layer,myGeometry,x,y,
//host = document.location.toString().match(/file:\/\//) ? "http://localhost:8090" : 'http://' + document.location.host;
url = "http://localhost:8090/iserver/services/map-china400/rest/maps/China_4326";
var vectorLayer;
function init(){
//初始化地图
map = new SuperMap.Map("map",{controls:[
new SuperMap.Control.Navigation() ,
new SuperMap.Control.Zoom()]});
map.addControl(new SuperMap.Control.MousePosition());
//初始化图层
layer = new SuperMap.Layer.TiledDynamicRESTLayer("World", url, null,{maxResolution:"auto"});
vectorLayer = new SuperMap.Layer.Vector("Vector Layer", {renderers: ["Canvas2"]});
//监听图层信息加载完成事件
layer.events.on({"layerInitialized":addLayer});
}
//异步加载图层
function addLayer(){
map.addLayer(layer);
map.addLayer(vectorLayer);
//显示地图范围
map.setCenter(new SuperMap.LonLat(0, 0), 0);
}
//清空
function clearFeatures(){
vectorLayer.removeAllFeatures();
var container = document.getElementById('container');
container.innerHTML="";
}
function queryByData(){
var commit=new XMLHttpRequest();
var uri="http://localhost:8090/iserver/services/data-China400/rest/data/featureResults.rjson?returnContent=true";
//设置请求体参数
var entry={
getFeatureMode:"SQL",
targetEpsgCode:4326,
datasetNames:["China400:TraStation_A_pt"],
maxFeatures:1000,
queryParameter:{
"sortClause":null,
"ids":null,
"name":"Capital",
"attributeFilter":"SMID=400",
"groupClause":null,
"linkItems":null,
"joinItems":null,
"fields":null
}
};
commit.open("POST",encodeURI(uri),false,"","");
commit.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
commit.send(JSON.stringify(entry));
//解析从服务器端返回的 json 字符串,解析为一个 JavaScript 对象。
var response = JSON.parse(commit.responseText);
//console.log(response);
//获取用作显示的 Div 容器。
var container = document.getElementById('container');
container.innerHTML="";
// //判断查询是否成功
if(response.featureCount<1)
{
//查询失败
container.innerHTML+="<p>查询失败</p>";
}else
{
//查询成功
container.innerHTML+="<p>查询成功</p>";
for(var i=0;i<response.features[0].fieldNames.length;i++){
container.innerHTML+="<p>"+response.features[0].fieldNames[i]+":"+response.features[0].fieldValues[i]+"</p>";
}
}
x = response.features[0].geometry.center.x;
y = response.features[0].geometry.center.y;
}
function addFeature(){
var point= new SuperMap.Geometry.Point(x,y);
var pointVector = new SuperMap.Feature.Vector(point);
pointVector.style={
fillColor:"red",
strokeColor:"yellow",
pointRadius:10
};
map.setCenter(new SuperMap.LonLat(x,y),13);
vectorLayer.addFeatures(pointVector);
}
</script>
</head>
<body onLoad = "init()">
<div id="toolbar">
<input type="button" class="btn" value="根据数据服务查询" onclick="queryByData()"/>
<input type="button" class="btn" value="添加要素到地图" onclick="addFeature()"/>
<input type="button" class="btn" value="清空" onclick="clearFeatures()"/>
</div>
<div id = "map"></div>
<div id="container"></div>
</body>
</html>
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
数据服务查询动态投影.rar (85个子文件)
数据服务查询动态投影
theme
default
google.css 306B
style.css 13KB
images
north-mini.png 6KB
layer-switcher-on.png 467B
point.png 3KB
zoombar_glide.png 3KB
layer-switcher-off.png 333B
tilesversion-bcg-slider1.png 1010B
hide.png 3KB
cluster1.png 4KB
zoom_city.png 3KB
cursors
Pan.cur 326B
PanDown.cur 326B
blank.gif 42B
zoom_province.png 3KB
tilesversion-bcg-reduce.png 1KB
zoombar_center.png 3KB
cluster4.png 1KB
layer-switcher-on_b.png 444B
cluster2.png 4KB
line.png 3KB
region.png 3KB
tilesversion-bcg-inf_bottom.png 277B
radial.png 868B
zoom-maxextent-mini_one.png 3KB
east-mini.png 6KB
close.png 3KB
zoom_street.png 3KB
zoombar.png 3KB
colorbtn.png 3KB
controlSkinWhite
minimize.png 1KB
layer-switcher-maximize.png 2KB
zoom-minus-mini.png 1KB
zoom-plus-mini.png 1KB
overView.png 1KB
tilesversion-bcg-slider2.png 1014B
west-mini.png 6KB
marker-gold.png 5KB
hide_hover.png 3KB
tilesversion-bcg-inf_left.png 1KB
close_hover.png 3KB
tilesversion-bcg-inf_right.png 1KB
south-mini.png 6KB
shadow-popup-corner.png 3KB
slider.png 3KB
layer-switcher-off_b.png 409B
tilesversion-bcg-add.png 1KB
tilesversion-bcg-center.png 1KB
tileservision-bcg-sliderbar.png 2KB
zoom-maxextent-mini.png 6KB
sliderbtn.png 3KB
tilesversion-bcg-inf.png 1KB
cluster3.png 3KB
text.png 3KB
marker.png 5KB
close.gif 193B
sliderbackground.png 3KB
controlSkinBlue
layer-switcher-minimize.png 3KB
minimize.png 3KB
layer-switcher-maximize.png 3KB
zoom-minus-mini.png 3KB
zoom-plus-mini.png 3KB
overView.png 3KB
overview_replacement.gif 79B
cloud-popup-relative.png 6KB
fillStyle
System 5.png 3KB
System 2.png 3KB
System 4.png 3KB
System 7.png 3KB
System 3.png 3KB
System 6.png 3KB
zoom_country.png 3KB
shadow-popup-subject.png 6KB
数据服务查询进行动态投影.html 4KB
libs
SuperMap.Include.js 2KB
SuperMap_Cloud-8.0.2-13626.js 24KB
Lang
en.js 3KB
zh-CN.js 6KB
SuperMap_Basic-8.0.2-13626.js 291KB
SuperMap_Visualization-8.0.2-13626.js 273KB
SuperMap-8.0.2-13626.js 772KB
SuperMap_OGC-8.0.2-13626.js 68KB
SuperMap_IServer-8.0.2-13626.js 84KB
css
bootstrap.min.css 101KB
bootstrap-responsive.min.css 16KB
共 85 条
- 1
资源评论
- qq_362418632016-09-26下载之后看不到效果啊。我点击按钮也没有什么反应啊。我是小白,求大神解答。
supermapsupport
- 粉丝: 5688
- 资源: 668
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功