ArcGIS for Javascriptapi Common interface __arcgis

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

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

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

Initialize navigation bar
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);

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

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

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

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

Double click on 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{
Display all layer names in the dropdown 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 based on coordinates
function Locationtruemap (x, y) {
window.top.frames["Mapframe"].frames["Ldframe"].showvisionbylnglat (x, y); Navigate to the 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 ("Failed to load Eagle Eye Chart:" +e.message);
}

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

Previous view, last 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 annotation");
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 attribute ' 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 the 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 ("advertisement Information");
Infotemplate.setcontent (
"<div style= ' text-align:center; ' ></div> "+
"<b> Advertisement Name: </b>" + aa[i][3] + "<br/>" +
"<b> Advertising Position: </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 ("Get coordinate array error: + e.message +"---aa: "+ AA);
}
Map.addlayer (Graphicslayer);
}

Online editing--moving elements
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 element Problem:" +e.message);
}
}

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

Map.infoWindow.setTitle ("New annotation");
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 box selection
Alert ("Xmax: +extent.xmax+", xmin: "+extent.xmin+", Ymax: "+extent.ymax+", ymin: "+extent.ymin");
};

}

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.