<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Add Shapefile code - Why all shapefile features shows the same location on map? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/add-shapefile-code-why-all-shapefile-features/m-p/566049#M52841</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi. I was looking for the answer to this question. I don't know if someone else have this problem right now, but i hope that this answer can help with this problem. To fix that, you need to change params.numberOfDigitsAfterDecimal = 0; to params.numberOfDigitsAfterDecimal = 14; or another value according of your configuration. Just with that change I was able to fix this problem. I hope this can help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 17 Nov 2017 19:59:52 GMT</pubDate>
    <dc:creator>Ronald_GuiovanniVenegas_Pulido</dc:creator>
    <dc:date>2017-11-17T19:59:52Z</dc:date>
    <item>
      <title>Add Shapefile code - Why all shapefile features shows the same location on map?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/add-shapefile-code-why-all-shapefile-features/m-p/566048#M52840</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin-bottom: 1em; font-size: 15px; color: #222426; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: rgba(248, 248, 248, 0.6);"&gt;I am developing the JS app using 3.15. I have tried this code in my app Add Shapefile&amp;nbsp; from the esri samples here&lt;/P&gt;&lt;P style="margin-bottom: 1em; font-size: 15px; color: #222426; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: rgba(248, 248, 248, 0.6);"&gt;&lt;A href="https://developers.arcgis.com/javascript/jssamples/portal_addshapefile.html" title="https://developers.arcgis.com/javascript/jssamples/portal_addshapefile.html"&gt;Add shapefile | ArcGIS API for JavaScript&lt;/A&gt;&lt;/P&gt;&lt;P style="margin-bottom: 1em; font-size: 15px; color: #222426; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: rgba(248, 248, 248, 0.6);"&gt;but shapefile features added at the same location on map.If the polygon features it shows square but not the actual shape of the polygon.&lt;/P&gt;&lt;P style="margin-bottom: 1em; font-size: 15px; color: #222426; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: rgba(248, 248, 248, 0.6);"&gt;My map intialextent and Spatialreference for basemap are&lt;/P&gt;&lt;P style="margin-bottom: 1em; font-size: 15px; color: #222426; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: rgba(248, 248, 248, 0.6);"&gt;&lt;CODE style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif;"&gt;var initialExtent = new esri.geometry.Extent({&lt;BR /&gt;&amp;nbsp; "xmin": 51.53195000000005,&lt;BR /&gt;&amp;nbsp; "ymin": 22.62777042700003,&lt;BR /&gt;&amp;nbsp; "xmax": 56.01812603400003,&lt;BR /&gt;&amp;nbsp; "ymax": 25.164240001000053,&lt;BR /&gt;&amp;nbsp; "spatialReference": {&lt;BR /&gt;&amp;nbsp; "wkid": 4326&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;});&lt;/CODE&gt;&lt;/P&gt;&lt;P style="margin-bottom: 1em; font-size: 15px; color: #222426; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: rgba(248, 248, 248, 0.6);"&gt;&lt;SPAN style="color: #222426; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 15px; background-color: rgba(248, 248, 248, 0.6);"&gt;map = new Map("map", { extent: esri.geometry.geographicToWebMercator(initialExtent), zoom: 2, logo: false }); &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 1em; font-size: 15px; color: #222426; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: rgba(248, 248, 248, 0.6);"&gt;&lt;SPAN style="color: #222426; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 15px; background-color: rgba(248, 248, 248, 0.6);"&gt;map.addLayer(_baseMap); &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 1em; font-size: 15px; color: #222426; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: rgba(248, 248, 248, 0.6);"&gt;&lt;SPAN style="color: #222426; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 15px; background-color: rgba(248, 248, 248, 0.6);"&gt;and code for add shapefile is following and attahced is the screenshot of result all features are at same location.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 1em; font-size: 15px; color: #222426; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: rgba(248, 248, 248, 0.6);"&gt;&lt;SPAN style="color: #222426; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 15px; background-color: rgba(248, 248, 248, 0.6);"&gt;&lt;CODE style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif;"&gt;&lt;SPAN&gt;var portalUrl = "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fwww.arcgis.com" rel="nofollow" target="_blank"&gt;http://www.arcgis.com&lt;/A&gt;&lt;SPAN&gt;";&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;//var form = dom.byId("uploadFormShapefile");&lt;BR /&gt;// on(form, "form:click", function (event) {&lt;BR /&gt;on(dom.byId("uploadFormShapefile"), "change", function (event) {&lt;BR /&gt;&amp;nbsp; debugger;&lt;BR /&gt;&amp;nbsp; var fileName = event.target.value.toLowerCase();&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; if (sniff("ie")) { //filename is full path in IE so extract the file name&lt;BR /&gt;&amp;nbsp; var arr = fileName.split("\\");&lt;BR /&gt;&amp;nbsp; fileName = arr[arr.length - 1];&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; if (fileName.indexOf(".zip") !== -1) {//is file a zip - if not notify user&lt;BR /&gt;&amp;nbsp; generateFeatureCollectionShapeFile(fileName);&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; else {&lt;BR /&gt;&amp;nbsp; dom.byId('upload-status').innerHTML = '&amp;lt;p style="color:red"&amp;gt;Add shapefile as .zip file&amp;lt;/p&amp;gt;';&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;function generateFeatureCollectionShapeFile(fileName) {&lt;BR /&gt;&amp;nbsp; debugger;&lt;BR /&gt;&amp;nbsp; var name = fileName.split(".");&lt;BR /&gt;&amp;nbsp; //Chrome and IE add c:\fakepath to the value - we need to remove it&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; //See this link for more info: &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fdavidwalsh.name%2Ffakepath" rel="nofollow" target="_blank"&gt;http://davidwalsh.name/fakepath&lt;/A&gt;&lt;BR /&gt;&amp;nbsp; name = name[0].replace("c:\\fakepath\\", "");&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; dom.byId('upload-status').innerHTML = '&amp;lt;b&amp;gt;Loading &amp;lt;/b&amp;gt;' + name;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; //Define the input params for generate see the rest doc for details&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; //&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fwww.arcgis.com%2Fapidocs%2Frest%2Findex.html%3Fgenerate.html" rel="nofollow" target="_blank"&gt;http://www.arcgis.com/apidocs/rest/index.html?generate.html&lt;/A&gt;&lt;BR /&gt;&amp;nbsp; var params = {&lt;BR /&gt;&amp;nbsp; 'name': name,&lt;BR /&gt;&amp;nbsp; 'targetSR': map.spatialReference,&lt;BR /&gt;&amp;nbsp; 'maxRecordCount': 1000,&lt;BR /&gt;&amp;nbsp; 'enforceInputFileSizeLimit': true,&lt;BR /&gt;&amp;nbsp; 'enforceOutputJsonSizeLimit': true&lt;BR /&gt;&amp;nbsp; };&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; //generalize features for display Here we generalize at 1:40,000 which is approx 10 meters&lt;BR /&gt;&amp;nbsp; //This should work well when using web mercator.&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; var extent = esri.geometry.getExtentForScale(map, 40000);&lt;BR /&gt;&amp;nbsp; //var extent = scaleUtils.getExtentForScale(map, 40000); //new esri.geometry.geographicToWebMercator(scaleUtils.getExtentForScale(map, 40000)); &lt;BR /&gt;&amp;nbsp; var resolution = extent.getWidth() / map.width;&lt;BR /&gt;&amp;nbsp; params.generalize = true;&lt;BR /&gt;&amp;nbsp; params.maxAllowableOffset = resolution;&lt;BR /&gt;&amp;nbsp; params.reducePrecision = true;&lt;BR /&gt;&amp;nbsp; params.numberOfDigitsAfterDecimal = 0;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; var myContent = {&lt;BR /&gt;&amp;nbsp; 'filetype': 'shapefile',&lt;BR /&gt;&amp;nbsp; 'publishParameters': JSON.stringify(params),&lt;BR /&gt;&amp;nbsp; 'f': 'json',&lt;BR /&gt;&amp;nbsp; 'callback.html': 'textarea'&lt;BR /&gt;&amp;nbsp; };&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; //use the rest generate operation to generate a feature collection from the zipped shapefile&lt;BR /&gt;&amp;nbsp; request({&lt;BR /&gt;&amp;nbsp; url: portalUrl + '/sharing/rest/content/features/generate',&lt;BR /&gt;&amp;nbsp; content: myContent,&lt;BR /&gt;&amp;nbsp; form: dom.byId('uploadFormShapefile'),&lt;BR /&gt;&amp;nbsp; handleAs: 'json',&lt;BR /&gt;&amp;nbsp; load: lang.hitch(this, function (response) {&lt;BR /&gt;&amp;nbsp; if (response.error) {&lt;BR /&gt;&amp;nbsp; errorHandler(response.error);&lt;BR /&gt;&amp;nbsp; return;&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; var layerName = response.featureCollection.layers[0].layerDefinition.name;&lt;BR /&gt;&amp;nbsp; dom.byId('upload-status').innerHTML = '&amp;lt;b&amp;gt;Loaded: &amp;lt;/b&amp;gt;' + layerName;&lt;BR /&gt;&amp;nbsp; addShapefileToMap(response.featureCollection);&lt;BR /&gt;&amp;nbsp; }),&lt;BR /&gt;&amp;nbsp; error: lang.hitch(this, errorHandler)&lt;BR /&gt;&amp;nbsp; });&lt;BR /&gt;}&lt;BR /&gt;function errorHandler(error) {&lt;BR /&gt;&amp;nbsp; debugger;&lt;BR /&gt;&amp;nbsp; dom.byId('upload-status').innerHTML =&lt;BR /&gt;&amp;nbsp; "&amp;lt;p style='color:red'&amp;gt;" + error.message + "&amp;lt;/p&amp;gt;";&lt;BR /&gt;}&lt;BR /&gt;function addShapefileToMap(featureCollection) {&lt;BR /&gt;&amp;nbsp; debugger;&lt;BR /&gt;&amp;nbsp; //add the shapefile to the map and zoom to the feature collection extent&lt;BR /&gt;&amp;nbsp; //If you want to persist the feature collection when you reload browser you could store the collection in&lt;BR /&gt;&amp;nbsp; //local storage by serializing the layer using featureLayer.toJson() see the 'Feature Collection in Local Storage' sample&lt;BR /&gt;&amp;nbsp; //for an example of how to work with local storage.&lt;BR /&gt;&amp;nbsp; var fullExtent;&lt;BR /&gt;&amp;nbsp; var layers = [];&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; arrayUtils.forEach(featureCollection.layers, function (layer) {&lt;BR /&gt;&amp;nbsp; var infoTemplate = new InfoTemplate("Details", "${*}");&lt;BR /&gt;&amp;nbsp; var featureLayer = new FeatureLayer(layer, {&lt;BR /&gt;&amp;nbsp; infoTemplate: infoTemplate&lt;BR /&gt;&amp;nbsp; });&lt;BR /&gt;&amp;nbsp; //associate the feature with the popup on click to enable highlight and zoom to&lt;BR /&gt;&amp;nbsp; featureLayer.on('click', function (event) {&lt;BR /&gt;&amp;nbsp; map.infoWindow.setFeatures([event.graphic]);&lt;BR /&gt;&amp;nbsp; });&lt;BR /&gt;&amp;nbsp; //change default symbol if desired. Comment this out and the layer will draw with the default symbology&lt;BR /&gt;&amp;nbsp; changeRenderer(featureLayer);&lt;BR /&gt;&amp;nbsp; fullExtent = fullExtent ?&lt;BR /&gt;&amp;nbsp; fullExtent.union(featureLayer.fullExtent) : featureLayer.fullExtent;&lt;BR /&gt;&amp;nbsp; layers.push(featureLayer);&lt;BR /&gt;&amp;nbsp; });&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; map.addLayers(layers);&lt;BR /&gt;&amp;nbsp; map.setExtent(fullExtent.expand(1.25), true);&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; dom.byId('upload-status').innerHTML = "";&lt;BR /&gt;}&lt;BR /&gt;function changeRenderer(layer) {&lt;BR /&gt;&amp;nbsp; //change the default symbol for the feature collection for polygons and points&lt;BR /&gt;&amp;nbsp; var symbol = null;&lt;BR /&gt;&amp;nbsp; switch (layer.geometryType) {&lt;BR /&gt;&amp;nbsp; case 'esriGeometryPoint':&lt;BR /&gt;&amp;nbsp; symbol = new PictureMarkerSymbol({&lt;BR /&gt;&amp;nbsp; 'angle': 0,&lt;BR /&gt;&amp;nbsp; 'xoffset': 0,&lt;BR /&gt;&amp;nbsp; 'yoffset': 0,&lt;BR /&gt;&amp;nbsp; 'type': 'esriPMS',&lt;BR /&gt;&amp;nbsp; 'url': 'images/BluePin1LargeB.png',&lt;BR /&gt;&amp;nbsp; 'contentType': 'image/png',&lt;BR /&gt;&amp;nbsp; 'width': 20,&lt;BR /&gt;&amp;nbsp; 'height': 20&lt;BR /&gt;&amp;nbsp; });&lt;BR /&gt;&amp;nbsp; break;&lt;BR /&gt;&amp;nbsp; case 'esriGeometryPolygon':&lt;BR /&gt;&amp;nbsp; symbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,&lt;BR /&gt;&amp;nbsp; new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,&lt;BR /&gt;&amp;nbsp; new Color([112, 112, 112]), 1), new Color([136, 136, 136, 0.25]));&lt;BR /&gt;&amp;nbsp; break;&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; if (symbol) {&lt;BR /&gt;&amp;nbsp; layer.setRenderer(new SimpleRenderer(symbol));&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;}&lt;/CODE&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Feb 2016 04:46:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/add-shapefile-code-why-all-shapefile-features/m-p/566048#M52840</guid>
      <dc:creator>MayurDodiya</dc:creator>
      <dc:date>2016-02-04T04:46:45Z</dc:date>
    </item>
    <item>
      <title>Re: Add Shapefile code - Why all shapefile features shows the same location on map?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/add-shapefile-code-why-all-shapefile-features/m-p/566049#M52841</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi. I was looking for the answer to this question. I don't know if someone else have this problem right now, but i hope that this answer can help with this problem. To fix that, you need to change params.numberOfDigitsAfterDecimal = 0; to params.numberOfDigitsAfterDecimal = 14; or another value according of your configuration. Just with that change I was able to fix this problem. I hope this can help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Nov 2017 19:59:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/add-shapefile-code-why-all-shapefile-features/m-p/566049#M52841</guid>
      <dc:creator>Ronald_GuiovanniVenegas_Pulido</dc:creator>
      <dc:date>2017-11-17T19:59:52Z</dc:date>
    </item>
  </channel>
</rss>

