arcgis for javascriptAPI常用接口.docx
- 文档编号:10404285
- 上传时间:2023-02-11
- 格式:DOCX
- 页数:11
- 大小:17.64KB
arcgis for javascriptAPI常用接口.docx
《arcgis for javascriptAPI常用接口.docx》由会员分享,可在线阅读,更多相关《arcgis for javascriptAPI常用接口.docx(11页珍藏版)》请在冰豆网上搜索。
arcgisforjavascriptAPI常用接口
arcgisforjavascriptAPI常用接口
分类:
ArcGISJavascriptAPI2013-10-0813:
17 1736人阅读 评论
(1) 收藏 举报
varmap,navToolbar,editToolbar,tileLayer,toolbar;
//varmapBaseUrl="http:
//localhost:
8399/arcgis/rest/services/pdsTile/MapServer";
//varmapDyUrl="http:
//localhost:
8399/arcgis/rest/services/pds/MapServer";
//varmapDyUrl="http:
//10.19.110.130:
8080/arcgis/rest/services/BaseMAP/MapServer";
varmapDyUrl="http:
//10.19.110.130:
8080/arcgis/rest/services/baseMAP/MapServer";
varmapBjUrl="http:
//10.19.110.130:
8080/arcgis/rest/services/YCBJ/MapServer";
vardynamicMapServiceLayerBj;
functioninit(){
try{
map=newesri.Map("map");
//tileLayer=newesri.layers.ArcGISTiledMapServiceLayer(mapBaseUrl);
//map.addLayer(tileLayer);
vardynamicMapServiceLayer=newesri.layers.ArcGISDynamicMapServiceLayer(mapDyUrl);
map.addLayer(dynamicMapServiceLayer);
dynamicMapServiceLayerBj=newesri.layers.ArcGISDynamicMapServiceLayer(mapBjUrl);
map.addLayer(dynamicMapServiceLayerBj);
//初始化
dojo.connect(map,"onLoad",dxInit);
}catch(e){alert("地图初始化失败:
"+e.message);}
}
functiondxInit()
{
try{
//alert(map.isDoubleClickZoom);
//map.disableDoubleClickZoom();
//比例尺显示
//window.setTimeout("queryMapScale.init(map);",1000);
//禁止双击放大
map.disableDoubleClickZoom();
//初始化导航工具条
navToolbar=newesri.toolbars.Navigation(map);
dojo.connect(navToolbar,"onExtentHistoryChange",extentHistoryChangeHandler);
//初始化在线编辑工具条
editToolbar=newesri.toolbars.Edit(map);
dojo.connect(map.graphics,"onClick",function(evt){
dojo.stopEvent(evt);
activateToolbar(evt.graphic);
});
//初始化绘制工具条
toolbar=newesri.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);
}
}
//图层控制
functionlayersCotrol(visible){
try{
dynamicMapServiceLayerBj.setVisibleLayers(visible);
}catch(e){
alert(e.message);
}
}
//显示图层列表
functionshowLayers(){
try{
//在下拉框中显示所有图层名称
varlayers=dynamicMapServiceLayerBj.layerInfos;
varobj1=newOption("",-1);
for(vari=0;i varobj=newOption(layers[i].name,i); dojo.byId("layers").add(obj); } }catch(e){ alert(e.message); } } //选择图层 functionselectLayer(){ try{ layersCotrol([dojo.byId("layers").value]); }catch(e){ alert(e.message); } } //刷新map functionresizeMap(){ map.resize(); map.reposition(); } //定位街景 functionzoomTo3D(evt) { varpoint=evt.mapPoint; varx=point.x.toFixed(4); vary=point.y.toFixed(4); //window.top.addmark(x,y); //alert(x+'|'+y); //定位街景 LocationTrueMap(x,y); } //根据坐标加载街景 functionLocationTrueMap(x,y){ window.top.frames["mapframe"].frames["ldframe"].showVisionByLngLat(x,y);//定位到街景 } //鹰眼图 functionshowOverview(){ varlayer=newesri.layers.ArcGISDynamicMapServiceLayer(mapDyUrl); layer.setImageFormat("png24"); try{ varcreateOverviewMap=function(){ overviewMapDijit=newdijits.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); } } //前一视图、后一视图 functionextentHistoryChangeHandler(){ dijit.byId("zoomprev").disabled=navToolbar.isFirstExtent(); dijit.byId("zoomnext").disabled=navToolbar.isLastExtent(); } //显示坐标值 functionshowCoordinates(evt) { try{ varmp=evt.mapPoint; dojo.byId("info").innerHTML=mp.x.toFixed(4)+","+mp.y.toFixed(4); }catch(e){ alert("显示坐标值错误: "+e.message); } } //隐藏坐标 functionhideCoordinates(evt){ dojo.byId("info").innerHTML=""; } //平移 functionpan(){ try{ toolbar.deactivate(); map.setMapCursor('default'); navToolbar.activate(esri.toolbars.Navigation.PAN); }catch(e){ alert(e.message); } } //清空地图 functionclearMap(){ navToolbar.deactivate(); toolbar.deactivate(); map.graphics.clear(); map.setMapCursor('default'); } //添加标注到地图方法1 varhandler; functionaddBzToMap1(){ toolbar.deactivate(); map.setMapCursor('crosshair'); handler=dojo.connect(map,"onClick",addPoint); } functionadd(x,y){ window.parent.showdialog('add','',x,y); } functionmodify(id,x,y){ window.parent.showdialog('modify',id,x,y); } functiondel(id,x,y){ //alert(x+"--"+y); window.parent.showdialog('del',id,x,y); } functionaddPoint(evt){ try{ varsymbol=newesri.symbol.PictureMarkerSymbol('images/nav/bz.png',25,25); varpoint=newesri.geometry.Point(evt.mapPoint,newesri.SpatialReference({wkid: 4326})); vargraphic=newesri.Graphic(point,symbol); map.graphics.add(graphic); map.infoWindow.setTitle("新标注"); vargeoPt=evt.mapPoint; map.infoWindow.setContent("X坐标: "+geoPt.y.toFixed(4) +" "+geoPt.x.toFixed(4) +"
Y坐标:"
+"
);
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);
}
}
//定位
functionzoomToPoint(x,y){
vargeoPoint=newesri.geometry.Point({"x":
x,"y":
y},map.spatialReference);
map.centerAndZoom(geoPoint,3);
}
//小汽车定位
//zoomCar(113.32,23.12);
functionzoomCar(x,y){
navToolbar.deactivate();
map.graphics.clear();
try{
vargeoPoint=newesri.geometry.Point({"x":
x,"y":
y},map.spatialReference);
map.centerAndZoom(geoPoint);
varsymbol=newesri.symbol.PictureMarkerSymbol('images/nav/car.png',24,24);
vargraphic=newesri.Graphic(geoPoint,symbol);
map.graphics.add(graphic);
}catch(e){
alert("小汽车定位"+e.message);
}
}
varurl="http:
//192.168.1.11:
8080";
//接收主题名称、坐标值
functiongetBz(aa){
vargraphicsLayer=newesri.layers.GraphicsLayer();
try{
for(vari=0;i a_x=aa[i][1]; a_y=aa[i][2]; //alert(a_x+"---"+a_y); varpoint=newesri.geometry.Point(a_x,a_y,map.spatialReference); varsymbol=newesri.symbol.PictureMarkerSymbol('images/nav/bz.png',25,25); vartextSym=newesri.symbol.TextSymbol(aa[i][0]); textSym.setAlign(esri.symbol.TextSymbol.ALIGN_END); vargraphic=newesri.Graphic(point,symbol); varinfoTemplate=newesri.InfoTemplate(); infoTemplate.setTitle("广告信息"); infoTemplate.setContent( // " center;'> 100px;height: 42px;'/>
// "广告名称:
"+aa[i][3]+"
"+
// "广告位置:
"+aa[i][4]+"
"+
// "
// "
);
graphic.setInfoTemplate(infoTemplate);
vargraphicText=newesri.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);
}
//在线编辑--移动要素
functionactivateToolbar(graphic){
try{
vartool=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;
varoptions={
allowAddVertices:
true,
allowDeleteVertices:
true
};
editToolbar.activate(tool,graphic,options);
dojo.connect(map.graphics,"onDblClick",showInfoWindow);
}cat
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- arcgis for javascriptAPI常用接口 javascriptAPI 常用 接口