laptop and a wrench

Bogue

Javascript example from the resource center is not working http://help.arcgis.com/en/webapi/javascript/arcgis/demos/util/util_simplify.html. The map service http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Portland/ESRI_LandBase_WebMercator/MapServer does not exist.

Dernière publication: August 25, 2014 ArcGIS API for JavaScript
Numéro d’ID de bogue NIM065979
EnvoiMarch 15, 2011
Dernière modificationJune 5, 2024
S’applique àArcGIS API for JavaScript
Version trouvée2.2
Langue du programmeJavaScript
Version de correction2.2
StatutFixed

Informations supplémentaires

This sample was using a deprecated service. I fixed the sample and published it to the help system, here's a link to the working sample:

Solution de contournement

Sample code with another map service.<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "<a href="http://www.w3.org/TR/html4/strict.dtd" target="_blank">http://www.w3.org/TR/html4/strict.dtd</a>"><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=7" /> <!--The viewport meta tag is used to improve the presentation and behavior of the samples on iOS devices--> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/> <title>Simplify a polygon</title> <link rel="stylesheet" type="text/css" href="<a href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.2/js/dojo/dijit/themes/claro/claro.css" target="_blank">http://serverapi.arcgisonline.com/jsapi/arcgis/2.2/js/dojo/dijit/themes/claro/claro.css</a>"> <script src="<a href="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.2" target="_blank">http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.2</a>" type="text/javascript"></script> <script type="text/javascript"> dojo.require("esri.map"); dojo.require("esri.tasks.geometry"); dojo.require("esri.geometry"); var map = null; var gsvc = null; var qtask = null; var polygonGraphic = null; var queryGraphic = null; function initialize() { map = new esri.Map("map"); dojo.connect(map, "onLoad", function () { drawPolygon(); }); var layer = new esri.layers.ArcGISDynamicMapServiceLayer("<a href="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer" target="_blank">http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer</a>"); map.addLayer(layer); //map.setExtent(new esri.geometry.Extent(-85.974236093929, 37.8793271200451, -85.3777322115035, 38.4978151750415, new esri.SpatialReference({wkid: 4326}))); gsvc = new esri.tasks.GeometryService("<a href="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer" target="_blank">http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer</a>"); qtask = new esri.tasks.QueryTask("<a href="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer/2" target="_blank">http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer/2</a>"); } function drawPolygon() { var latOffset, lonOffset, center, lat, lon, points; ///// Get map center center = map.extent.getCenter(); lat = center.y; lon = center.x + 500; ///// Create a Green Polygon latOffset = 500; lonOffset = 500; points = [ new esri.geometry.Point(lon - lonOffset, lat), new esri.geometry.Point(lon, lat + latOffset), new esri.geometry.Point(lon + lonOffset, lat), new esri.geometry.Point(lon, lat - latOffset), new esri.geometry.Point(lon - lonOffset, lat), new esri.geometry.Point(lon - 2 * lonOffset, lat + latOffset), new esri.geometry.Point(lon - 3 * lonOffset, lat), new esri.geometry.Point(lon - 2 * lonOffset, lat - latOffset), new esri.geometry.Point(lon - 1.5 * lonOffset, lat + latOffset), new esri.geometry.Point(lon - lonOffset, lat) ]; var polygon = new esri.geometry.Polygon(); polygon.addRing(points); polygon.spatialReference = new esri.SpatialReference({ wkid: 2253}); // Add the polygon to map var symbol = new esri.symbol.SimpleFillSymbol().setStyle(esri.symbol.SimpleFillSymbol.STYLE_SOLID); polygonGraphic = new esri.Graphic(polygon, symbol); map.graphics.add(polygonGraphic); } function doSimplify() { gsvc.simplify([ polygonGraphic.geometry ], simplifyCallback); } function simplifyCallback(geometries) { alert("Number of Rings returned by Simplify operation = " + geometries[0].rings.length); polygonGraphic.setGeometry(geometries[0]); doQuery(polygonGraphic); // select a ring to do query } function doQuery(polygonGraphic) { var query = new esri.tasks.Query(); //query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_INTERSECTS; query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_CONTAINS; query.geometry = polygonGraphic.geometry; query.returnGeometry = true; qtask.execute(query, queryCallback); //alert(query); } function queryCallback(featureSet) { map.graphics.remove(queryGraphic); var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0,0,255,255]), 2), new dojo.Color([0,0,255,0.35])); var features = featureSet.features; //alert("Features : " +features); var polys = new esri.geometry.Polygon(); //For performance, push all featureSet polygons into polys geometry. //Users will not be able to query individual polygons, but the display will be faster for (var j=0, jl=features.length; j<jl; j++) { var featureGeom = features[j].geometry; for (var k=0, kl=featureGeom.rings.length; k<kl; k++) { var featureGeomRing = featureGeom.rings[k]; polys.addRing(featureGeomRing); } } //alert(polys); queryGraphic = new esri.Graphic(polys,symbol) map.graphics.add(queryGraphic); //alert("Inside querycall back"); } dojo.addOnLoad(initialize); </script></head><body class="claro"> Many spatial operations require topologically correct geometry. <br/><input type="button" value="Simplify the polygon and Do a Query with simplified polygon" onclick="doSimplify();" /> <br/>If you try to use the self-intersecting geometry above without simplifying it you will get incorrect results. <br/><input type="button" value="Execute query task without simplifying polygon" onclick="doQuery(polygonGraphic);" /> <div id="map" style="width:600px; height:400px; border:1px solid #000;"></div></body></html>

Étapes pour reproduire

ID de bogue: NIM065979

Logiciel:

  • ArcGIS API for JavaScript

Recevoir une notification lorsque le statut d’un bogue change

Télécharger l’application Esri Support

En savoir plus sur ce sujet

Obtenir de l’aide auprès des experts ArcGIS

Contacter le support technique

Télécharger l’application Esri Support

Accéder aux options de téléchargement