(转)Arcgis API常用接口调用方法
var map, navToolbar, editToolbar, tileLayer, toolbar;
//var mapBaseUrl = "http://localhost:8399/arcgis/rest/services/pdsTile/MapServer";
//var mapDyUrl = "http://localhost:8399/arcgis/rest/services/pds/MapServer";
//var mapDyUrl = "http://10.19.110.130:8080/arcgis/rest/services/BaseMAP/MapServer";
var mapDyUrl = "http://10.19.110.130:8080/arcgis/rest/services/baseMAP/MapServer";
var mapBjUrl = "http://10.19.110.130:8080/arcgis/rest/services/YCBJ/MapServer";
var dynamicMapServiceLayerBj;
function init() {
try{
map = new esri.Map("map");
//tileLayer = new esri.layers.ArcGISTiledMapServiceLayer(mapBaseUrl);
//map.addLayer(tileLayer);
var dynamicMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer(mapDyUrl);
map.addLayer(dynamicMapServiceLayer);
dynamicMapServiceLayerBj = new esri.layers.ArcGISDynamicMapServiceLayer(mapBjUrl);
map.addLayer(dynamicMapServiceLayerBj);
//初始化
dojo.connect(map, "onLoad", dxInit);
}catch(e){alert("地图初始化失败:"+e.message);}
}
function dxInit()
{
try{
//alert(map.isDoubleClickZoom);
//map.disableDoubleClickZoom();
//比例尺显示
//window.setTimeout("queryMapScale.init(map);", 1000);
//禁止双击放大
map.disableDoubleClickZoom();
//初始化导航工具条
navToolbar = new esri.toolbars.Navigation(map);
dojo.connect(navToolbar, "onExtentHistoryChange", extentHistoryChangeHandler);
//初始化在线编辑工具条
editToolbar = new esri.toolbars.Edit(map);
dojo.connect(map.graphics, "onClick", function(evt) {
dojo.stopEvent(evt);
activateToolbar(evt.graphic);
});
//初始化绘制工具条
toolbar = new esri.toolbars.Draw(map);
//dojo.connect(toolbar, "onDrawEnd", addToMap);
//显示坐标
dojo.connect(map, "onMouseMove", showCoordinates);
dojo.connect(map, "onMouseOut", hideCoordinates);
//加载鹰眼图、加载图层列表
dojo.connect(map, "onLayerAdd", showLayers);
//加载之前记录标注
//window.setTimeout("getBz();", 1000);------------------------------
//地图窗口更新
//alert(document.getElementById('map1'));
resizeMap();
dojo.connect(document.getElementById('map1'), 'resize', resizeMap);
//双击map,定位街景
dojo.connect(map, 'onDblClick', zoomTo3D);
//图层控制
layersCotrol([0]);
}catch(e){
alert("地图初始化失败:"+e.message);
}
}
//图层控制
function layersCotrol(visible){
try{
dynamicMapServiceLayerBj.setVisibleLayers(visible);
}catch(e){
alert(e.message);
}
}
//显示图层列表
function showLayers(){
try{
//在下拉框中显示所有图层名称
var layers = dynamicMapServiceLayerBj.layerInfos;
var obj1 = new Option("", -1);
for(var i=0; i<layers.length; i++){
var obj = new Option(layers[i].name, i);
dojo.byId("layers").add(obj);
}
}catch(e){
alert(e.message);
}
}
//选择图层
function selectLayer(){
try{
layersCotrol([dojo.byId("layers").value]);
}catch(e){
alert(e.message);
}
}
//刷新map
function resizeMap(){
map.resize();
map.reposition();
}
//定位街景
function zoomTo3D(evt)
{
var point = evt.mapPoint;
var x = point.x.toFixed(4);
var y = point.y.toFixed(4);
//window.top.addmark(x, y);
//alert(x + '|' + y);
// 定位街景
LocationTrueMap(x, y);
}
// 根据坐标加载街景
function LocationTrueMap(x, y) {
window.top.frames["mapframe"].frames["ldframe"].showVisionByLngLat(x, y); //定位到街景
}
//鹰眼图
function showOverview() {
var layer = new esri.layers.ArcGISDynamicMapServiceLayer(mapDyUrl);
layer.setImageFormat("png24");
try{
var createOverviewMap = function() {
overviewMapDijit = new dijits.overview.OverviewMap({
map: map,
baseLayer: layer,
width: 150,
height: 150,
attachTo: "bottom-right",
expandFactor: 1.42,
color: "#80A8C1",
opacity: 0.5
});
overviewMapDijit.startup();
};
}catch(e){
alert("加载鹰眼图失败:"+e.message);
}
if (layer.loaded) {
createOverviewMap();
}
else {
dojo.connect(layer, "onLoad", createOverviewMap);
}
}
//前一视图、后一视图
function extentHistoryChangeHandler() {
dijit.byId("zoomprev").disabled = navToolbar.isFirstExtent();
dijit.byId("zoomnext").disabled = navToolbar.isLastExtent();
}
//显示坐标值
function showCoordinates(evt)
{
try{
var mp = evt.mapPoint;
dojo.byId("info").innerHTML = mp.x.toFixed(4) +","+ mp.y.toFixed(4);
}catch(e){
alert("显示坐标值错误:"+e.message);
}
}
//隐藏坐标
function hideCoordinates(evt){
dojo.byId("info").innerHTML = "";
}
//平移
function pan(){
try{
toolbar.deactivate();
map.setMapCursor('default');
navToolbar.activate(esri.toolbars.Navigation.PAN);
}catch(e){
alert(e.message);
}
}
//清空地图
function clearMap(){
navToolbar.deactivate();
toolbar.deactivate();
map.graphics.clear();
map.setMapCursor('default');
}
//添加标注到地图方法1
var handler;
function addBzToMap1(){
toolbar.deactivate();
map.setMapCursor('crosshair');
handler = dojo.connect(map, "onClick", addPoint);
}
function add(x, y) {
window.parent.showdialog('add','', x,y);
}
function modify(id, x, y) {
window.parent.showdialog('modify', id, x, y);
}
function del(id, x, y) {
//alert(x + "--" + y);
window.parent.showdialog('del', id, x, y);
}
function addPoint(evt) {
try{
var symbol = new esri.symbol.PictureMarkerSymbol('images/nav/bz.png', 25, 25);
var point = new esri.geometry.Point(evt.mapPoint, new esri.SpatialReference({ wkid: 4326 }));
var graphic = new esri.Graphic(point, symbol);
map.graphics.add(graphic);
map.infoWindow.setTitle("新标注");
var geoPt = evt.mapPoint;
map.infoWindow.setContent("<b>X坐标: </b>" + geoPt.y.toFixed(4)
+ "<br><b>Y坐标: </b>" + geoPt.x.toFixed(4)
+ "<table></table>"
+ "<br><input type='button' value='添加属性' onclick='window.top.addmark(" + geoPt.x.toFixed(4) + "," + geoPt.y.toFixed(4) + ")'>"
);
map.infoWindow.show(evt.mapPoint,map.getInfoWindowAnchor(evt.screenPoint));
map.setMapCursor('default');
dojo.disconnect(handler);
window.top.frames["mapframe"].frames["ldframe"].showVisionByLngLat(geoPt.x.toFixed(4), geoPt.y.toFixed(4)); //定位到街景
}catch(e){
alert("添加标注出错:"+e.message);
}
}
//定位
function zoomToPoint(x, y){
var geoPoint = new esri.geometry.Point({"x":x,"y":y}, map.spatialReference);
map.centerAndZoom(geoPoint, 3);
}
//小汽车定位
//zoomCar(113.32,23.12);
function zoomCar(x, y) {
navToolbar.deactivate();
map.graphics.clear();
try{
var geoPoint = new esri.geometry.Point({"x":x,"y":y}, map.spatialReference);
map.centerAndZoom(geoPoint);
var symbol = new esri.symbol.PictureMarkerSymbol('images/nav/car.png', 24,24);
var graphic = new esri.Graphic(geoPoint, symbol);
map.graphics.add(graphic);
}catch(e){
alert("小汽车定位" + e.message);
}
}
var url = "http://192.168.1.11:8080";
//接收主题名称、坐标值
function getBz(aa) {
var graphicsLayer = new esri.layers.GraphicsLayer();
try {
for (var i = 0; i < aa.length; i++) {
a_x = aa[i][1];
a_y = aa[i][2];
// alert(a_x+"---"+a_y);
var point = new esri.geometry.Point(a_x, a_y, map.spatialReference);
var symbol = new esri.symbol.PictureMarkerSymbol('images/nav/bz.png', 25, 25);
var textSym = new esri.symbol.TextSymbol(aa[i][0]);
textSym.setAlign(esri.symbol.TextSymbol.ALIGN_END);
var graphic = new esri.Graphic(point, symbol);
var infoTemplate = new esri.InfoTemplate();
infoTemplate.setTitle("广告信息");
infoTemplate.setContent(
// "<div style='text-align:center;'><img src='" + url + aa[i][5] + "' alt='" + url + aa[i][5] + "' style='width:100px;height:42px;'/></div>" +
// "<b>广告名称: </b>" + aa[i][3] + "<br/>" +
// "<b>广告位置: </b>" + aa[i][4] + "<br/>" +
// "<br><input type='button' value='修改广告' onclick='map.infoWindow.hide();modify(" + aa[i][0] + "," + a_x + "," + a_y + ")'>" +
// " <input type='button' value='删除广告' onclick='map.infoWindow.hide();del(" + aa[i][0] + "," + a_x + "," + a_y + ")'>"
);
graphic.setInfoTemplate(infoTemplate);
var graphicText = new esri.Graphic(point, textSym);
graphicsLayer.add(graphic);
graphicsLayer.add(graphicText);
if (aa.length == 1) {
// zoomToPoint(a_x, a_y);
}
}
} catch (e) {
alert("获取坐标点数组出错:" + e.message + "---aa:" + aa);
}
map.addLayer(graphicsLayer);
}
//在线编辑--移动要素
function activateToolbar(graphic) {
try{
var tool = 0;
tool = tool | esri.toolbars.Edit.MOVE;
//tool = tool | esri.toolbars.Edit.EDIT_VERTICES;
//tool = tool | esri.toolbars.Edit.SCALE;
//tool = tool | esri.toolbars.Edit.ROTATE;
var options = {
allowAddVertices: true,
allowDeleteVertices: true
};
editToolbar.activate(tool, graphic, options);
dojo.connect(map.graphics, "onDblClick", showInfoWindow);
}catch(e){
alert("移动要素问题:"+e.message);
}
}
function showInfoWindow(evt){
evt.stopPropagation();
map.infoWindow.setTitle("新标注");
var geoPt = evt.mapPoint;
map.infoWindow.setContent("<b>X坐标: </b>" + geoPt.y.toFixed(4)
+ "<br><b>Y坐标: </b>" + geoPt.x.toFixed(4)
+ "<table></table>"
+ "<br><input type='button' value='添加广告' onclick='map.infoWindow.hide();add(" + geoPt.x + "," + geoPt.y + ")'>"
);
map.infoWindow.show(evt.mapPoint,map.getInfoWindowAnchor(evt.screenPoint));
}
//框选
function queryBz()
{
map.setMapCursor('crosshair');
navToolbar.deactivate();
toolbar.activate(esri.toolbars.Draw.EXTENT);
toolbar.onDrawEnd = function doQueryExtent(extent) {
window.parent.stat(extent.xmin, extent.ymin, extent.xmax, extent.ymax);
// //获取框选区域的坐标范围
// alert("xmax:"+extent.xmax+",xmin:"+extent.xmin+", ymax:"+extent.ymax+",ymin:"+extent.ymin);
};
}
(转)Arcgis API常用接口调用方法的更多相关文章
- 基于apache httpclient的常用接口调用方法
现在的接口开发,大部分是基于http的请求和处理,现在整理了一份常用的调用方式工具类 package com.xh.oms.common.util; import java.io.BufferedRe ...
- phpcms常用接口调用方法
常用函数 , 打开include/global.func.php,下面存放一些公共函数 view plaincopy to clipboardprint?function str_charset($i ...
- ArcGIS API for Silverlight 调用WebService出现跨域访问报错的解决方法
原文:ArcGIS API for Silverlight 调用WebService出现跨域访问报错的解决方法 群里好几个朋友都提到过这样的问题,说他们在Silverlight中调用了WebServi ...
- ArcGIS API for Silverlight 调用GP服务准备---GP模型建立、发布、测试
原文:ArcGIS API for Silverlight 调用GP服务准备---GP模型建立.发布.测试 第一篇.GP降雨量等值线建模.发布及测试 在水利.气象等行业中,要在WebGIS中实现空间分 ...
- SERVLET类常用接口及方法
SERVLET类常用接口及方法 2011-09-09 16:14:43 [size=xx-small]SERVLET类常用接口及方法2007年04月05日 星期四 04:46 P.M.基本类和接 ...
- ArcGIS API for Silverlight 调用GP服务绘制等值面
原文:ArcGIS API for Silverlight 调用GP服务绘制等值面 GP服务模型如下图: 示例效果图片如下:
- ArcGIS API for Silverlight 调用GP服务加载等值线图层
原文:ArcGIS API for Silverlight 调用GP服务加载等值线图层 第二篇.Silverlight客户端调用GP服务 利用ArcGIS API for Silverlight实现G ...
- 新浪网易淘宝等IP地区信息查询开放API接口调用方法
通过IP地址获取对应的地区信息通常有两种方法:1)自己写程序,解析IP对应的地区信息,需要数据库.2)根据第三方提供的API查询获取地区信息. 第一种方法,参见文本<通过纯真IP数据库获取IP地 ...
- 云极知客开放平台接口调用方法(C#)
云极知客为企业提供基于SAAS的智能问答服务.支持企业个性化知识库的快速导入,借助语义模型的理解和分析,使企业客户立即就拥有本行业的24小时客服小专家.其SAAS模式实现零成本投入下的实时客服数据的可 ...
随机推荐
- Codeforces 633D
题意: 给定n,和一个长度为n的序列. 让你在这n个数中找长度尽可能长的fib数列. 思路: 这题的数字是在1e9范围内的,所以最长的可能存在的fib数列官方的解释是90左右.有一种情况除外,就是0的 ...
- NYOJ 49-开心的小明:01背包
点击打开链接 开心的小明 时间限制:1000 ms | 内存限制:65535 KB 难度:4 描述 小明今天很开心,家里购置的新房就要领钥匙了,新房里有一间他自己专用的很宽敞的房间.更让他高兴的是 ...
- (easy)LeetCode 263.Ugly Number
Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers ...
- JAVA设计模式之单一职责原则
概念: 就一个类而言应该只有一个因其他变化的原因. 流程: 问题由来:设类或接口类C负责两个不同不同的职责:职责T1,职责T2.当由于职责T1需求改变进而需要修改类C时,可能导致职责T2收到不可预知的 ...
- 《Code Complete》ch.18 表驱动法
是什么 一种scheme,用表来做信息存取,代替逻辑语句(if/else) 为什么 简化逻辑语句,避免大量嵌套的 if/else 或者 switch/case 怎么用 三种访问表的方式 直接访问:将源 ...
- HDU 4770 Lights Against Dudely
Lights Against Dudely Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- DP走方格型
Hrbust 1812 http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=1812 有 ...
- [HTML5] document.hidden
特殊说明: 通过document.hidden属性,可判断页面是否可见. 如果不可见,则document.hidden为true. 如果可见, 则为false. 但是, 如果该页面只是被其它窗口挡住, ...
- SICP 换零钱的迭代版本
看到换零钱方式统计这里, 书中给出了递归的实现但没有给出迭代版本说要留给读者作为挑战, 既然说是作为挑战那肯定是能解决的,在想了一天无果之后最终在别人博客的帮助下终于实现了迭代的版本...也算是经历坎 ...
- 慕课网-安卓工程师初养成-1-5 使用Eclipse开发Java程序
来源: http://www.imooc.com/video/1412 eclipse --- IDE 集成开发环境(IDE)是一类软件 将程序开发环境和程序调试环境集合在一起,提高开发效率 其他ID ...