AnsweredAssumed Answered

FeatureLayer does not accept WGS84 ( WKID 4326 )

Question asked by eckardtr on Mar 27, 2012
Latest reply on Apr 10, 2012 by eckardtr
Hello,

i want to display Points, witch are generated from PHP. I get this infortmation via AJAX / JSON.
This is my sample code, witch is cutted to the main thing. My problem ist, that the WGS 84 coordinates wont be accept by the ESRI Javascript API.

The Point on the MAP is allways in the Atlantic Ocean near to Africa. I thing the API still uses wkid: 102100
What is my fault? I played with the code more than one day but i cant found a solution.

[PHP]
var myExtent = new esri.geometry.Extent(-10, 40, 35, 57, new esri.SpatialReference({wkid:4326}));

map = new esri.Map("mapDiv", {
    nav:true,
    extent:esri.geometry.geographicToWebMercator(myExtent)
});

var basemapURL= "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"
var basemap = new esri.layers.ArcGISTiledMapServiceLayer(basemapURL);
map.addLayer(basemap);

infoTemplate_logger2=new esri.InfoTemplate("<h3>${Name}</h3>","mytest");


var featureCollection = {
    layerDefinition: {
      "geometryType": "esriGeometryPoint",
      "spatialReference" : {
            "wkid" : 4326
      },
      "drawingInfo": {
        "renderer": {
          "type": "simple",
          "symbol": {
            "type": "esriPMS",
            "url": "http://icons.iconarchive.com/icons/mart/glaze/128/log-icon.png",
            "contentType": "image/png",
            "width": 24,
            "height": 24
          }
        }
      },
      "fields": [
      {
          "name": "OBJECTID",
          "type": "esriFieldTypeOID",
          "alias": "OBJECTID"
      },
      {
        "name": "Name",
        "type": "esriFieldTypeString",
        "alias": "Name"
      }
      ]
    },
    "featureSet":{
       "geometryType":"esriGeometryPoint",
       "spatialReference":{
          "wkid":4326
       },
       "features":[
          {
             "geometry":{
                "x":8.55,
                "y":47.3666667
             },
             "attributes":{
                "OBJECTID":2,
                "Name":"Zürich",
             }
          }
       ]
    }
  };

  featureLayer = new esri.layers.FeatureLayer(featureCollection, {
    mode: esri.layers.FeatureLayer.MODE_SNAPSHOT,
    infoTemplate: infoTemplate_logger2,
  });


[/PHP]

Outcomes