0

I am using ArcGIS map which gives me an error:

enter image description here

Below is my function which i am using to implementing the map on my application:

function handlerForVariableB (latt, longt, complaintid)
{


  // execute code that is relevant when "$a" was set on the server-side. 
   $.ajax({
    type: "GET",
    url:  "tools/nrega_v2.1/map.php",
    data: 'complaintid='+complaintid,
    success: function(data){         
      var data_array = JSON.parse(data);


  $('.modal-info').html("");

  var hrymap='<div id="hrymap"></div>';
    $(".modal-info").append(hrymap);

  $('#hrymap').html(""); 

    $('#hrymap').html("<div id='map' style='width:850px;height:650px;'><div id='BasemapToggle'></div></div>");
          //var map;

      var map;

     require([
        "esri/map", "esri/views/MapView", "esri/widgets/BasemapToggle",
        "esri/geometry/Point",
        "esri/symbols/SimpleMarkerSymbol",
        "esri/graphic", 
        "esri/layers/GraphicsLayer", "esri/symbols/PictureMarkerSymbol","esri/layers/ArcGISDynamicMapServiceLayer","esri/layers/ArcGISTiledMapServiceLayer",
        "dojo/domReady!"
      ], function(
        Map,  MapView,
  BasemapToggle,Point, SimpleMarkerSymbol, Graphic, GraphicsLayer,PictureMarkerSymbol,ArcGISDynamicMapServiceLayer,ArcGISTiledMapServiceLayer
      ) {
        map = new Map("map", {
          basemap: "<?php echo $basemap; ?>",
      center: [longt,latt],
          zoom: "<?php echo $zoomlevel; ?>",

        });
         var view = new MapView({
    container: "viewDiv",
    map: map,
    center: [-86.049, 38.485],
    zoom: 3
  });

  // 1 - Create the widget
  var toggle = new BasemapToggle({
    // 2 - Set properties
    view: view, // view that provides access to the map's 'topo' basemap
    nextBasemap: "hybrid" // allows for toggling to the 'hybrid' basemap
  });
 view.ui.add(toggle, "top-right");

        map.on("load", function() {
          var gl = new GraphicsLayer();
          var p = new Point(longt,latt);

     var s = new PictureMarkerSymbol('img/location.png', 51, 51);

          var g = new Graphic(p, s);
          gl.add(g);
          map.addLayer(gl);
          map.addLayer(new ArcGISDynamicMapServiceLayer('<?php echo $roadlayers; ?>'));

                    });
      });

     $("#detail_content").css({'display':'block'});



    }
  });



}

Below are the js and css which are using in my application:

<link rel="stylesheet" href="inc/css/bootstrap.min.css">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="inc/css/font-awesome.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" href="inc/css/ionicons.min.css">
  <!-- jvectormap -->
   <!-- Theme style -->
  <link rel="stylesheet" href="inc/css/AdminLTE.min.css">
<link rel="stylesheet" href="css/global.css">
<link href="css/custom.css" type="text/css" rel="stylesheet">
  <link rel="stylesheet" href="inc/css/skins/_all-skins.min.css">
  <link rel="stylesheet" href="inc/css/custom.css">
  <link rel="stylesheet" href="inc/style.min.css">
 <link rel="stylesheet" href="leafletslib/leaflet.css" />
  <script src="leafletslib/leaflet.js"></script>
  <script src="js/jquery-3.4.1.min.js"></script>
    <script src="lib/jquery.crypt.js"></script>
    <script src="lib/jquery.validarium.js"></script>
    <link rel="stylesheet" href="https://js.arcgis.com/3.29/esri/css/esri.css">
    <script src="https://js.arcgis.com/3.29/"></script>
  <script src="js/bootstrap.min.js"></script>
  • You are trying to load esri/views/MapView from the wrong version of ArcGIS Javascript API. This class exists on version 4.x of the API, not 3.29. – isshp Jul 23 at 6:59
  • I am getting the same error with 4.11 version – sumit kundan Jul 23 at 7:14
  • Loading failed for the <script> with source “js.arcgis.com/4.11/esri/layers/ArcGISDynamicMapServiceLayer.js”. – sumit kundan Jul 23 at 7:17
  • Once again, you're mixing up classes from two different versions. esri/layers/ArcGISDynamicMapServiceLayer belongs to version 3.x. You should decide which version you want to use and then find the relevant classes from API. Use the documentation: v3.x or v4.x – isshp Jul 23 at 7:29
  • i need actually basemap toggle with simplemarker please suggest me which relevan class i use to achieve my requirement – sumit kundan Jul 23 at 7:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.