<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" href="http://js.arcgis.com/3.12/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="http://js.arcgis.com/3.12/esri/css/esri.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.1.min.js"></script>
<script src="http://js.arcgis.com/3.12/"></script>
<script type="text/javascript">
require([
"esri/map",
"esri/geometry/webMercatorUtils",
"dojo/domReady!"],
function (Map, webMercatorUtils){
map = new Map("map", {
basemap: "satellite",
center: [-46.807, 32.553],
zoom: 3
});
function getCenterPoint() {
return map.extent.getCenter();
}
map.on("extent-change", function () {
var point = getCenterPoint();
var newPoint = webMercatorUtils.webMercatorToGeographic(point);
var message="current map center is x: " + newPoint.x + ", y: " + newPoint.y;
$("#centerInfo").html(message);
});
});
</script>
</head>
<body>
<div id="map"></div>
<div id="centerInfo"></div>
</body>
</html>
中间最关键的是getCenterPoint() 方法
还有map.extent.getCenter().getLatitude()、map.extent.getCenter().getLongitude()可以直接获取经纬度
原文链接:how to get map center point?