[英]Using drawing tool of ArcGIS
I am discovering Drawing tool of ArcGIS. 我正在发现ArcGIS的绘图工具 。 The code of a widget looks as follows:
小部件的代码如下所示:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width,user-scalable=no">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<title>Maps Toolbar</title>
<link rel="stylesheet" href="https://js.arcgis.com/3.20/dijit/themes/nihilo/nihilo.css">
<link rel="stylesheet" href="https://js.arcgis.com/3.20/esri/css/esri.css">
<style>
html, body, #mainWindow {
font-family: sans-serif;
height: 100%;
width: 100%;
}
html, body {
margin: 0;
padding: 0;
}
#header {
height: 80px;
overflow: auto;
padding: 0.5em;
}
</style>
<script src="https://js.arcgis.com/3.20/"></script>
<script>
var map, toolbar, symbol, geomTask;
require([
"esri/map",
"esri/toolbars/draw",
"esri/graphic",
"esri/symbols/SimpleMarkerSymbol",
"esri/symbols/SimpleLineSymbol",
"esri/symbols/SimpleFillSymbol",
"dojo/parser", "dijit/registry",
"dijit/layout/BorderContainer", "dijit/layout/ContentPane",
"dijit/form/Button", "dijit/WidgetSet", "dojo/domReady!"
], function(
Map, Draw, Graphic,
SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol,
parser, registry
) {
parser.parse();
map = new Map("map", {
basemap: "streets",
center: [-15.469, 36.428],
zoom: 3
});
map.on("load", createToolbar);
// loop through all dijits, connect onClick event
// listeners for buttons to activate drawing tools
registry.forEach(function(d) {
// d is a reference to a dijit
// could be a layout container or a button
if ( d.declaredClass === "dijit.form.Button" ) {
d.on("click", activateTool);
}
});
function activateTool() {
var tool = this.label.toUpperCase().replace(/ /g, "_");
toolbar.activate(Draw[tool]);
map.hideZoomSlider();
}
function createToolbar(themap) {
toolbar = new Draw(map);
toolbar.on("draw-end", addToMap);
}
function addToMap(evt) {
var symbol;
toolbar.deactivate();
map.showZoomSlider();
switch (evt.geometry.type) {
case "point":
case "multipoint":
symbol = new SimpleMarkerSymbol();
break;
case "polyline":
symbol = new SimpleLineSymbol();
break;
default:
symbol = new SimpleFillSymbol();
break;
}
var graphic = new Graphic(evt.geometry, symbol);
map.graphics.add(graphic);
}
});
</script>
</head>
<body class="nihilo">
<div id="mainWindow" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'headline'">
<div id="header" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'top'">
<span>Draw:<br /></span>
<button data-dojo-type="dijit/form/Button">Point</button>
<button data-dojo-type="dijit/form/Button">Multi Point</button>
<button data-dojo-type="dijit/form/Button">Line</button>
<button data-dojo-type="dijit/form/Button">Polyline</button>
<button data-dojo-type="dijit/form/Button">Polygon</button>
<button data-dojo-type="dijit/form/Button">Freehand Polyline</button>
<button data-dojo-type="dijit/form/Button">Freehand Polygon</button>
<button data-dojo-type="dijit/form/Button">Arrow</button>
<button data-dojo-type="dijit/form/Button">Triangle</button>
<button data-dojo-type="dijit/form/Button">Circle</button>
<button data-dojo-type="dijit/form/Button">Ellipse</button>
</div>
<div id="map" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'"></div>
</div>
</body>
</html>
I am very new to ArcGIS, therefore my question might be simple. 我是ArcGIS的新手,因此我的问题可能很简单。 I wonder if it's possible to substitute the background map by some other image, for example, the layer that represents a floor in a building?
我想知道是否可以用其他图像代替背景图,例如,代表建筑物地板的图层? I have this image available in JPEG format and it has global coordinates assigned to it.
我有此图像以JPEG格式提供,并且已为其分配了全局坐标。 So, how can I substitute a map by this image?
那么,如何用该图像替代地图? Should I update these lines of code?
我应该更新这些代码行吗?
map = new Map("map", {
basemap: "streets",
center: [-15.469, 36.428],
zoom: 3
});
Well, those background images are known as basemap in Gis term. 好吧,这些背景图像在Gis术语中称为底图。 ARCGIS js api provides multiple basemaps like topo, street, imagery etc.
ARCGIS js api提供了多个底图,例如topo,街道,图像等。
To change the background/basemap you need to change the basemap keyword. 要更改背景/底图,您需要更改底图关键字。
Example- 例-
Change "streets" to "topo". 将“街道”更改为“拓扑”。 It will change the basemap/background.
它将更改底图/背景。
Note- you can try various types of basemaps which is available on arcgis api. 注意-您可以尝试arcgis api上可用的各种类型的底图。
EDITED[30/May/2017]- 编辑[30 / May / 2017]-
Here I am proposing you to use existing basemap provided by ESRI, However if you want to show your own images as backgroud/basemap then you need to publish/republish a basemap. 在这里,我建议您使用ESRI提供的现有底图,但是,如果要将自己的图像显示为backgroud /底图,则需要发布/重新发布底图。
Hoping this will help you. 希望对您有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.