如何将地图居中到选定点

时间:2016-02-11 19:45:12

标签: arcgis

我有一个由点组成的功能层。通过单击表格上的某一行,将切换地图视图,并且仅显示一个选定点 通过JavaScript命令:

  

featureLayer.setDefinitionExpression(" ID =&#34 + NUM);

现在我的目标是将地图集中到这一点

1 个答案:

答案 0 :(得分:0)

首先,您必须通过featureLayer.graphics从featureLayer获取图片。然后使用map.centerAndZoom(mapPoint, levelOrFactor)map.centerAt(mapPoint)缩放到您的图片。

var graphic = featureLayer.graphics[0];
if (graphic && graphic.geometry.type === "point") {
    map.centerAndZoom(graphic.geometry, 17); // or map.centerAt(graphic.geometry);
}