AnsweredAssumed Answered

Spatial Reference changes after adding OpenStreetMap layer from 4326 to 102100

Question asked by armin_p on Jun 11, 2016
Latest reply on Jun 12, 2016 by armin_p

Hi,

I'm using a featureLayer, I want to use OSM as a base map, after adding osm layer my map spatial reference changes from 4326 to 102100 (web Mercator), even if I set my osm layer spatial reference to 4326, how can I fix this problem?

thanks;

 

function startup() {

    var sr = new esri.SpatialReference({wkid: 4326});

    var startextent = new esri.geometry.Extent(

        50.9484,

        35.9424,

        52.0264,

        36.4271,

        sr

    );

    lyr_branches = new esri.layers.FeatureLayer('http://localhost:6080/arcgis/rest/services/DayBank/MapServer/7', {

        mode: esri.layers.FeatureLayer.MODE_SNAPSHOT,

        id: "branches",

        outFields: ['*']

    });

 

    map = new esri.Map('map', {

        extent: startextent,

        center: [51.420598, 35.721900],

        zoom: 11,

        fadeOnZoom: true,

        minZoom: 10,

        spatialReference: new esri.SpatialReference({wkid: 4326})

    });

     

    osm = new esri.layers.OpenStreetMapLayer({

        id: "osm",

        initialٍExtent: startextent,

        spatialReference: new esri.SpatialReference({

            wkid: 4326

        }),

        center: [51.420598, 35.721900]

    });

 

 

 

 

 

    var selectionSymbol = new esri.symbol.SimpleMarkerSymbol();

    selectionSymbol.setSize(20);

    selectionSymbol.setColor(new dojo.Color([255, 0, 0, 0.5]));

 

 

    lyr_branches.setSelectionSymbol(selectionSymbol);

 

//    map.addLayer(osm);

    map.addLayer(lyr_branches);

 

 

    var featureTable = new esri.dijit.FeatureTable({

        featureLayer: lyr_branches,

        map: map,

        editable: false,

        showGridHeader: false,

        showGridMenu: false,

        showDataTypes: false,

        outFields: ["PostalCode", "Telephone", "Fax", "Address", "Code", "Name"]

    }, 'myTableNode');

 

 

    featureTable.startup();

 

 

    //create query task

    queryTask = new esri.tasks.QueryTask('http://localhost:6080/arcgis/rest/services/DayBank/MapServer/7');

 

 

    cf = new esri.tasks.ClosestFacilityTask('http://localhost:6080/arcgis/rest/services/DayBank/NAServer/Closest%20Facility');

Outcomes