VinayBa

Cached Service and Feature Layer

Discussion created by VinayBa on Sep 5, 2013
HI All,

We have created cached services there are three layers which are feature layer , problem is now when i load the basic map using ArcGISDynamicMapServiceLayer then i add feature layer i am not able to perform onclick functinalities,please let me know if there is anything wrong with my code.Can i use feature layer on top of cache service.


Service Description:

Map Name: Layers

Legend

All Layers and Tables

Dynamic Legend

Dynamic All Layers

Layers:

    WorldCountries_50K (0)
    WorldCountries_100K (1)
    WorldCountries_250K (2)
    WorldCountries_500K (3)

Description:

Copyright Text:

Spatial Reference: 102100  (3857)


Single Fused Map Cache: true

Tile Info:

    Height: 256
    Width: 256
    DPI: 96
    Levels of Detail: 20
        Level ID: 0 [ Start Tile, End Tile ]
            Resolution: 156543.03392800014
            Scale: 5.91657527591555E8
        Level ID: 1 [ Start Tile, End Tile ]
            Resolution: 78271.51696399994
            Scale: 2.95828763795777E8
        Level ID: 2 [ Start Tile, End Tile ]
            Resolution: 39135.75848200009
            Scale: 1.47914381897889E8
        Level ID: 3 [ Start Tile, End Tile ]
            Resolution: 19567.87924099992
            Scale: 7.3957190948944E7
        Level ID: 4 [ Start Tile, End Tile ]
            Resolution: 9783.93962049996
            Scale: 3.6978595474472E7
        Level ID: 5 [ Start Tile, End Tile ]
            Resolution: 4891.96981024998
            Scale: 1.8489297737236E7
        Level ID: 6 [ Start Tile, End Tile ]
            Resolution: 2445.98490512499
            Scale: 9244648.868618
        Level ID: 7 [ Start Tile, End Tile ]
            Resolution: 1222.992452562495
            Scale: 4622324.434309
        Level ID: 8 [ Start Tile, End Tile ]
            Resolution: 611.4962262813797
            Scale: 2311162.217155
        Level ID: 9 [ Start Tile, End Tile ]
            Resolution: 305.74811314055756
            Scale: 1155581.108577
        Level ID: 10 [ Start Tile, End Tile ]
            Resolution: 152.87405657041106
            Scale: 577790.554289
        Level ID: 11 [ Start Tile, End Tile ]
            Resolution: 76.43702828507324
            Scale: 288895.277144
        Level ID: 12 [ Start Tile, End Tile ]
            Resolution: 38.21851414253662
            Scale: 144447.638572
        Level ID: 13 [ Start Tile, End Tile ]
            Resolution: 19.10925707126831
            Scale: 72223.819286
        Level ID: 14 [ Start Tile, End Tile ]
            Resolution: 9.554628535634155
            Scale: 36111.909643
        Level ID: 15 [ Start Tile, End Tile ]
            Resolution: 4.77731426794937
            Scale: 18055.954822
        Level ID: 16 [ Start Tile, End Tile ]
            Resolution: 2.388657133974685
            Scale: 9027.977411
        Level ID: 17 [ Start Tile, End Tile ]
            Resolution: 1.1943285668550503
            Scale: 4513.988705
        Level ID: 18 [ Start Tile, End Tile ]
            Resolution: 0.5971642835598172
            Scale: 2256.994353
        Level ID: 19 [ Start Tile, End Tile ]
            Resolution: 0.29858214164761665
            Scale: 1128.497176
    Format: PNG32
    Compression Quality: 0.0
    Origin: X: -2.0037508342787E7
    Y: 2.0037508342787E7
    Spatial Reference: 102100  (3857)

Initial Extent:

    XMin: -2.6548096424178407E7
    YMin: -1.4376721731989654E7
    XMax: 2.204125777392E7
    YMax: 2.400182614911706E7
    Spatial Reference: 102100  (3857)

Full Extent:

    XMin: -2.2041257773920003E7
    YMin: -3.578420532071707E7
    XMax: 2.204125777392E7
    YMax: 2.400182614911706E7
    Spatial Reference: 102100  (3857)

Units: esriMeters

Supported Image Format Types: PNG32,PNG24,PNG,JPG,DIB,TIFF,EMF,PS,PDF,GIF,SVG,SVGZ,BMP

Document Info:

    Title:
    Author:
    Comments:
    Subject:
    Category:
    Keywords:
    AntialiasingMode: Fast
    TextAntialiasingMode: Force

Supports Dynamic Layers: true

MaxRecordCount: 1000

MaxImageHeight: 2048

MaxImageWidth: 2048

Supported Query Formats: JSON, AMF

Min Scale: 5.91657527591555E8

Max Scale: 1.8489297737236E7



Child Resources:   Info   Dynamic Layer
 



Below is code


<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=7, IE=9, IE=10">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
    <title>Feature Layer Only Map</title>
    
    <style>
      html, body, #map {
        height: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
      }
    </style>
 <script src="http://js.arcgis.com/3.6/"></script>
<script>
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.layout.AccordionContainer");
dojo.require("esri.map");
dojo.require("esri.layers.FeatureLayer");
dojo.require("dijit.TooltipDialog");
var myMap;    // global variable representing the map

function init() {
esri.config.defaults.map.zoomDuration = 250; //time in milliseconds; default is 250
esri.config.defaults.map.zoomRate = 25; //refresh rate of zoom animation; default is 25

 


var bounds = new esri.geometry.Extent({
            "xmin":-2.204125777392E7,
            "ymin":-1.4348737528212927E7,
            "xmax":2.204125777392E7,
            "ymax":2.3907585678113185E7,
            "spatialReference":{"wkid":102100}
          });
 myMap = new esri.Map("mapDiv", { 
            extent: bounds
          });
 var opLayer1 = new esri.layers.ArcGISTiledMapServiceLayer("http://10.32.9.106:6080/arcgis/rest/services/KX_Mapping/World_Countries_WMS_Cached/MapServer");
 myMap.addLayer(opLayer1);
 
 
 addNeighborhoods();

}

function addNeighborhoods() {
    try{
 var info_content = "<table><tr><td><b>COUNTRY :</b></td><td style='text-align:right'>${COUNTRY}</td></tr></table>";
     console.log(" adding neghbordhoods");
 var maxOffset = calcOffset();
 var infoTemplate1 = new esri.InfoTemplate("fdsfd", "Sdfd");
 var  featureLayer1 = new esri.layers.FeatureLayer("http://10.32.9.106:6080/arcgis/rest/services/KX_Mapping/World_Countries_WMS_Cached/MapServer/1",{
  
    infoTemplate: infoTemplate1,
    maxAllowableOffset: maxOffset,
  id: "sd_neighborhoods"
 });
 dojo.connect(featureLayer1, "onLoad", function(){
          console.log("feture layer added ");
   //myMap.addLayer(featureLayer1);
   require(["dojo/on", "esri/symbols/SimpleFillSymbol", "esri/symbols/SimpleLineSymbol", "dojo/_base/Color", "esri/graphic"], function(on, SimpleFillSymbol, SimpleLineSymbol, Color, Graphic) {
                    on(featureLayer1, "click", function(evt) {
                        
      console.log(" added ");
                        // clears current selection
                       
                        myMap.graphics.clear();
                        // create new graphic with selected graphic's geometry
                        var graphic = new Graphic(evt.graphic.geometry);
                        
                        // create a new symbol for the graphic
                        var sfs = new SimpleFillSymbol(SimpleFillSymbol.STYLE_FORWARD_DIAGONAL, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255, 0, 0]), 2), new Color([255, 255, 0, 0.5]));
                        
                        // add symbol to the graphic
                        graphic.setSymbol(sfs);     
                        
                        // add the graphic to the map   
                        myMap.graphics.add(graphic);
                    });
                });
 });
 
 
 

   }catch(e){
     console.log("error "+e);
   }
 }
function showTooltip(evt){
 var newTip = new dijit.TooltipDialog({
   id: "ttDialog",
   content: evt.graphic.attributes.COUNTRY,
   style: "position: absolute; opacity: 0.8; width: auto; font: normal normal bold 6pt Tahoma;z-index:100"
 });
 newTip.startup();

 dijit.placeOnScreen(newTip.domNode, {x: evt.pageX, y: evt.pageY}, ["TL", "BL"], {x: 10, y: 10});
}

function hideTooltip() {
var oldTip = dijit.byId("ttDialog");
 if (oldTip) {
   oldTip.destroy();
 }
}
function calcOffset() {
  return (myMap.extent.getWidth() / myMap.width);
  // console.log('extent changed...maxOffset: ', globals.maxOffset);
}

dojo.addOnLoad(init);
</script>
  </head>
  <body>
    <div id="mapDiv"></div>
  </body>
</html>

Outcomes