AnsweredAssumed Answered

WAB add graphics fails if jQuery loaded

Question asked by mhylden on Nov 4, 2015
Latest reply on Nov 10, 2015 by mhylden

I've been attempting to load graphics to my map programmatically, and I think I've finally figured out that it only fails if I have the jQuery library loaded as part of the define statement in the widget.  (e.g. the UseJQuery demo widget, or the custom widget I've been working on.)

example code (the show-id just refers to a button on the html):

 

define(['dojo/_base/declare', 'jimu/BaseWidget','esri/geometry/Point',

   'esri/symbols/SimpleFillSymbol', 'esri/symbols/SimpleMarkerSymbol', 'esri/symbols/SimpleLineSymbol',

   'esri/layers/ArcGISDynamicMapServiceLayer', 'esri/graphic', 'dojo/_base/Color', 'esri/SpatialReference',

  'jimu/loaderplugins/jquery-loader!https://code.jquery.com/jquery-git1.min.js'],

function (declare, BaseWidget, Point, SimpleLineSymbol,

return declare(BaseWidget, {

startup: function(){

var map = this.map;

$('.jimu-widget-use-jquery .show-id').click(function () {

var ptSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 32, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color("#00FF00"), 1), new Color("#00FF00"));

var testPt = new Point(-8442027.57807591, 4910634.987265695, new SpatialReference(102100));

var testG = new Graphic(testPt, ptSymbol);

$('.jimu-widget-use-jquery .my-title').text('title added by jquery.');

}

 

  });

 

});

 

 

 

The same lines that define the ptSymbol, testPt, and testGraphic work in the Draw widget.

 

So my question is this - Is the use of jQuery necessarily separate from creating graphics on the map, and do I have to use some other method of calling my REST endpoints that is dojo-specific to still be able to interact with the map?

 

Thanks in advance,

 

Mikkel

Outcomes