Go Arcgis API Common Interface invocation method

Source: Internet
Author: User

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);

Initialization
Dojo.connect (Map, "OnLoad", dxinit);



}catch (e) {alert ("Map initialization failed:" +e.message);}
}

function Dxinit ()
{
try{
alert (map.isdoubleclickzoom);
Map.disabledoubleclickzoom ();

Scale display
Window.settimeout ("Querymapscale.init (map);", 1000);

Disable double-click to enlarge
Map.disabledoubleclickzoom ();

Initializing the navigation toolbar
Navtoolbar = new Esri.toolbars.Navigation (map);
Dojo.connect (Navtoolbar, "Onextenthistorychange", Extenthistorychangehandler);

Initialize the online editing tool bar
Edittoolbar = new Esri.toolbars.Edit (map);
Dojo.connect (Map.graphics, "OnClick", function (evt) {
Dojo.stopevent (EVT);
Activatetoolbar (evt.graphic);
});

Initializing the Drawing tool bar
toolbar = new Esri.toolbars.Draw (map);
Dojo.connect (toolbar, "Ondrawend", Addtomap);

Display coordinates
Dojo.connect (Map, "OnMouseMove", showcoordinates);
Dojo.connect (Map, "onmouseout", hidecoordinates);

Load Eagle Eye diagram, load layer list
Dojo.connect (Map, "Onlayeradd", showlayers);

Record annotations before loading
Window.settimeout ("getbz ();", +);------------------------------

Map Window Update
Alert (document.getElementById (' map1 '));
Resizemap ();
Dojo.connect (document.getElementById (' Map1 '), ' resize ', resizemap);

Double-click Map to locate Street View
Dojo.connect (map, ' OnDblClick ', zoomto3d);

Layer Control
Layerscotrol ([0]);
}catch (e) {
Alert ("Map initialization failed:" +e.message);
}
}

Layer Control
function Layerscotrol (visible) {

try{
Dynamicmapservicelayerbj.setvisiblelayers (visible);
}catch (e) {
alert (e.message);
}
}

Show Layer List
function Showlayers () {

try{
Show all layer names in the drop-down box
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);
}
}

Select Layer
function Selectlayer () {

try{
Layerscotrol ([Dojo.byid ("layers"). value]);
}catch (e) {
alert (e.message);
}
}

Refresh Map
function Resizemap () {
Map.resize ();
Map.reposition ();
}

Locate Street View
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);
Locate Street View
Locationtruemap (x, y);
}
Load Street View by coordinates
function Locationtruemap (x, y) {
window.top.frames["Mapframe"].frames["Ldframe"].showvisionbylnglat (x, y); Navigate to Street View
}

Eagle Eye Chart
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 ("Load Eagle Eye Graph failed:" +e.message);
}

if (layer.loaded) {
Createoverviewmap ();
}
else {
Dojo.connect (layer, "onLoad", Createoverviewmap);
}
}

Previous view, next view
function Extenthistorychangehandler () {
Dijit.byid ("Zoomprev"). Disabled = Navtoolbar.isfirstextent ();
Dijit.byid ("Zoomnext"). Disabled = Navtoolbar.islastextent ();
}

Display coordinate values
function Showcoordinates (EVT)
{
try{
var MP = Evt.mappoint;
Dojo.byid ("Info"). InnerHTML = mp.x.tofixed (4) + "," + mp.y.tofixed (4);
}catch (e) {
Alert ("Display coordinate value error:" +e.message);
}
}

Hide coordinates
function Hidecoordinates (evt) {
Dojo.byid ("Info"). InnerHTML = "";
}

Translation
function pan () {
try{
Toolbar.deactivate ();
Map.setmapcursor (' Default ');
Navtoolbar.activate (Esri.toolbars.Navigation.PAN);
}catch (e) {
alert (e.message);
}
}

Clear the Map
function Clearmap () {
Navtoolbar.deactivate ();
Toolbar.deactivate ();
Map.graphics.clear ();
Map.setmapcursor (' Default ');
}

Add callout to map Method 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 ("New Dimension");
var geopt = Evt.mappoint;
Map.infoWindow.setContent ("<b>x coordinates: </b>" + geopt.y.tofixed (4)
+ "<br><b>y Coordinates: </b>" + geopt.x.tofixed (4)
+ "<table></table>"
+ "<br><input type= ' button ' value= ' Add property ' 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)); Navigate to Street View
}catch (e) {
Alert ("Add callout Error:" +e.message);
}
}

Positioning
function Zoomtopoint (x, y) {
var geoPoint = new Esri.geometry.Point ({"X": X, "Y": y}, Map.spatialreference);
Map.centerandzoom (GeoPoint, 3);
}

Car positioning
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 ("Car positioning" + e.message);
}
}


var url = "http://192.168.1.11:8080";

Receive subject name, coordinate value
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 ("Advertising Information");
Infotemplate.setcontent (
"<div style= ' text-align:center; ' ></div> "+
"<b> Ad Name: </b>" + aa[i][3 "+" <br/> "+
"<b> AD Location: </b>" + aa[i][4 "+" <br/> "+
"<br><input type= ' button ' value= ' modify ad ' onclick= ' map.infoWindow.hide (); modify (" + aa[i][0] + "," + A_x + "," + a_y + ") ' > ' +
"<input type= ' button ' value= ' delete ad ' onclick= ' Map.infoWindow.hide ();d El (" + 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 ("Error getting coordinate points group:" + e.message + "---aa:" + AA);
}
Map.addlayer (Graphicslayer);
}

Online editing-moving features
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 ("Mobile feature Issue:" +e.message);
}
}

function Showinfowindow (evt) {
Evt.stoppropagation ();

Map.infoWindow.setTitle ("New Dimension");
var geopt = Evt.mappoint;
Map.infoWindow.setContent ("<b>x coordinates: </b>" + geopt.y.tofixed (4)
+ "<br><b>y Coordinates: </b>" + geopt.x.tofixed (4)
+ "<table></table>"
+ "<br><input type= ' button ' value= ' Add ad ' onclick= ' Map.infoWindow.hide (); Add (" + Geopt.x + "," + Geopt.y + ") ' > "

);
Map.infoWindow.show (Evt.mappoint,map.getinfowindowanchor (evt.screenpoint));
}

Box selection
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);
Gets the coordinate range of the marquee area
Alert ("Xmax:" +extent.xmax+ ", Xmin:" +extent.xmin+ ", Ymax:" +extent.ymax+ ", ymin:" +extent.ymin ");
};

}

Go Arcgis API Common Interface invocation method

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.