mogurlu

esri js 3.5 measurement ArcGISTiledMapServiceLayer problem

Discussion created by mogurlu on Aug 2, 2013
Hi,

JS 3.5 api don't support Measurement Tool with projected ArcGISTiledMapServiceLayer.

Is anyone figured out this problem?

https://developers.arcgis.com/en/javascript/jssamples/widget_measureproject.html

This example only works with ArcGISDynamicMapServiceLayer


[HTML]
<!DOCTYPE html>
<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">
    <!--The viewport meta tag is used to improve the presentation and behavior of the samples
    on iOS devices-->
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
    <title>Measure Tool</title>
    <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/dojo/dijit/themes/claro/claro.css">
    <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/css/esri.css">
    <style>
      html,body {
        height:100%;
        width:100%;
        margin:0;
      }
      body {
        background-color:#FFF;
        overflow:hidden;
      }
      #map {
        margin:5px;
        padding:0px;
        border:solid 4px #46472B;
      }
      #measureWindow {
        position:absolute;
        right:35px;
        top:5px;
        z-index:998;
        width:245px;
        padding:20px;
        background:#46472B;
      }
      .roundedCorners{
        -moz-border-radius:6px;
        -webkit-border-radius:6px;
        border-radius:6px;
      }
      .innerDiv{
        background:#F1F1DC; padding:4px;
      }
    </style>

    <script>        var dojoConfig = { parseOnLoad: true };</script>
    <script src="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/"></script>
    <script>
        dojo.require("dijit.layout.BorderContainer");
        dojo.require("dijit.layout.ContentPane");

        dojo.require("esri.map");
        dojo.require("esri.dijit.Measurement");
        dojo.require("esri.dijit.Scalebar");

        var map;

        function init() {
            //This sample requires a proxy page to handle communications with the ArcGIS Server services. You will need to 
            //replace the url below with the location of a proxy on your machine. See the 'Using the proxy page' help topic
            //for details on setting up a proxy page.
            esri.config.defaults.io.proxyUrl = "/proxy";
            esri.config.defaults.io.alwaysUseProxy = false;

            //This service is for development and testing purposes only. We recommend that you create your own geometry service for use within your applications
            esri.config.defaults.geometryService = new esri.tasks.GeometryService("http://myserver/ArcGIS/rest/services/Geometry/GeometryServer");

            map = new esri.Map("map");

            dojo.connect(map, 'onLoad', function (map) {
                initToolbar(map);
            });

            var layer = new esri.layers.ArcGISTiledMapServiceLayer("http://myserver/ArcGIS/rest/services/cachedlayer/MapServer");
            map.addLayer(layer);
        }

        function initToolbar(mymap) {
            var measurement = new esri.dijit.Measurement({
                map: mymap
            }, dojo.byId('measurementDiv'));
            measurement.startup();
        }
        dojo.ready(init);
    </script>
  </head>
 
  <body class="claro">
    <div id="mainWindow"  data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="design:'headline',gutters:false"
    style="width:100%; height:100%;">
      <div id="map" class="roundedCorners" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'center'" style="position:relative;">
      <div class="roundedCorners" id="measureWindow" >
        <div class="innerDiv roundedCorners">
          <div id="measurementDiv"></div>
        </div>
      </div>
     </div>
    </div>
  </body>
</html>

[/HTML]

Outcomes