Select to view content in your preferred language

Issue loading layers from Arc Server

622
0
01-24-2014 05:40 AM
SaaedBhatti1
New Contributor
Hi,
New esri developer. I'm trying to load a layer from arc server but I'm getting this error in console window of developer tools for chrome.
Resource interpreted as Script but transferred with MIME type text/plain: "https://waxhawarcgis.waxhaw.com/arcgis/rest/services/EnerGov/EnerGovMap/MapServer/22?f=json&callback...".

Here is how I'm creating the map and setting the layer

var LAYERS_SERVER = [{ url: 'https://waxhawarcgis.waxhaw.com/arcgis/rest/services/EnerGov/EnerGovMap/MapServer/22', name: 'Flex Utility' }];

var createServerMap = function () {
        var initialZoomLevel = 3;

        map = new esri.Map("map", {
            zoom: initialZoomLevel,
            slider: false,
            wrapAround180: true,
            showAttribution: true,
        });

        map.on('layer-add-result', function (layer, error) {
            if (layer.layer.id == LAYERS_SERVER[0].name)
                map.setExtent(new esri.geometry.Extent(layer.layer.fullExtent.xmin, layer.layer.fullExtent.ymin, layer.layer.fullExtent.xmax, layer.layer.fullExtent.ymax,
                    new esri.SpatialReference({ wkid: map.extent.spatialReference.wkid })));
        });

        addLayers(map, LAYERS_SERVER);
    };

var addLayers = function(map, layers) {
        var template = new esri.InfoTemplate();
        template.setTitle("Info");
        // If a feature layer is setup in system but not in Webmap, add them to the map
        $.each(layers, function (i, val) {
            var gisServerLayer = new esri.layers.FeatureLayer(val.url, {
                mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
                outFields: ["*"],
                id: val.name,
                displayOnPan: true,
                visible: true,
                infoTemplate: template
            });
            map.addLayer(gisServerLayer);
        });
    };

Any help in resolving this would be greatly appreciated. Or if you can point me in the right direction.
0 Kudos
0 Replies