"esri is not defined" using JavaScript API 4.6

2522
3
Jump to solution
02-20-2018 06:28 AM
AdminMaps
New Contributor

I am trying to create a very basic map and plot some hard coded points on it. Below is code and the highlighted line gives an error "esri is not defined".

view.when(function(){
   var draw = new Draw({
      view: view
   });

var symbol = {
   type: "simple-marker", // autocasts as new SimpleMarkerSymbol()
   style: "square",
   color: "blue",
   size: "8px", // pixels
   outline: { // autocasts as new SimpleLineSymbol()
   color: [ 255, 255, 0 ],
   width: 3 // points
   }
};

var points = {
"points": [[-122.63, 45.51], [-122.56, 45.51], [-122.56, 45.55], [-122.62, 45.00], [-122.59, 45.53]]
};

var mp = new esri.geometry.Multipoint(points);
var wm_mp = esri.geometry.geographicToWebMercator(mp);
});

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Legacy style coding is not supported in the 4.x api. So you need to require the multipoint geometry type instead and just use the MultiPoint class instead.

View solution in original post

3 Replies
RobertScheitlin__GISP
MVP Emeritus

Legacy style coding is not supported in the 4.x api. So you need to require the multipoint geometry type instead and just use the MultiPoint class instead.

AdminMaps
New Contributor

Thanks that helps. Can you also guide regarding the usage of geographicToWebMercator() method to plot points?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Admin,

   Sure just require this class:

webMercatorUtils | API Reference | ArcGIS API for JavaScript 4.6 

In Case you are not familiar with AMD style coding:

The abc’s of AMD | ArcGIS Blog 

0 Kudos