require(["esri/map", "dojo/domReady!", "esri/layers/ArcGISDynamicMapServiceLayer", "esri/SpatialReference",], function(Map) { var layer1 = new esri.layers.ArcGISDynamicMapServiceLayer("http://localhost:6080/arcgis/rest/services/carte1/MapServer"); map = new Map("maptest1"); map.addLayers([layer1]); map.on("layers-add-result", function(){ var extent = layer1.fullExtent; map.setExtent(extent); alert(extent.xmax); }); });
welcome to the forums burton!if you have a reference to an extent object, you could find its center using the method extent.getCenter() afterward, you could pass the point which is returned to map.centerAt()
map.addLayer(dynamicMapServiceLayer); console.log(dynamicMapServiceLayer.fullExtent); //this will be null dynamicMapServiceLayer.on("load", function(evt) { console.log(evt.layer.fullExtent); //this will be populated });
Try this instead require(["esri/map", "dojo/domReady!", "esri/layers/ArcGISDynamicMapServiceLayer", "esri/SpatialReference",], function(Map) { var layer1 = new esri.layers.ArcGISDynamicMapServiceLayer("http://localhost:6080/arcgis/rest/services/carte1/MapServer"); map = new Map("maptest1"); map.addLayers([layer1]); map.on("layers-add-result", function(){ var extent = layer1.fullExtent; map.setExtent(extent); alert(extent.xmax); }); });
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.