<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Simple Map</title>
<link rel="stylesheet" type="text/css" href="http://localhost:8080/arcgis_js_api/library/3.9/3.9/js/dojo/dijit/themes/tundra/tundra.css"/>
<link rel="stylesheet" type="text/css" href="http://localhost:8080/arcgis_js_api/library/3.9/3.9/js/esri/css/esri.css" />
<script type="text/javascript" src="http://localhost:8080/arcgis_js_api/library/3.9/3.9/init.js"></script>
<script type="text/javascript">
var map;
require([
"dojo/parser",
"esri/map",
"esri/layers/ArcGISTiledMapServiceLayer",
"esri/layers/FeatureLayer",
"dojo/domReady!"],
function(parser,
Map,
ArcGISTiledMapServiceLayer,FeatureLayer
){
parser.parse();
var myTiledMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/NGS_Topo_US_2D/MapServer");
map = new Map("mapDiv");
map.on("mouse-move",showCoordinates);
map.addLayer(myTiledMapServiceLayer);
});
//鼠标移动显示坐标
function showCoordinates(evt) {
var mp = evt.mapPoint;
var screenPt = map.toScreen(mp);
var str ="<p style=\"display:block\">"+ "屏幕坐标(x,y):" +"("+screenPt.x + "," + screenPt.y + ")"+"</p>";
dojo.byId("DivBottom").innerHTML = str+"地图坐标(x,y):"+"("+mp.x + ", "+ mp.y+")";
}
</script>
</head>
<body class="esri">
<div id="mapDiv" style="width:900px; height:600px; border:1px solid #000;"></div>
<div id="DivBottom"></div>
</body>
</html>
ArcGIS 测试
最新推荐文章于 2023-01-12 03:00:00 发布