Select to view content in your preferred language

WAB add graphics fails if jQuery loaded

3383
1
Jump to solution
11-04-2015 01:17 PM
MikkelHylden
Regular Contributor

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

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
MikkelHylden
Regular Contributor

I did get my graphics to start drawing/working again.  The issue seemed to be that I had a mismatch in the order of all the dojo declare items at the top of the javascript.  Very frustrating to find it was something so simple, but I'll consider it an expensive lesson learned as I move forward with dojo.  Very sneaky that it doesn't give any kind of error related to the order of the declares, it just fails to work right.  Grrrr...  

View solution in original post

0 Kudos
1 Reply
MikkelHylden
Regular Contributor

I did get my graphics to start drawing/working again.  The issue seemed to be that I had a mismatch in the order of all the dojo declare items at the top of the javascript.  Very frustrating to find it was something so simple, but I'll consider it an expensive lesson learned as I move forward with dojo.  Very sneaky that it doesn't give any kind of error related to the order of the declares, it just fails to work right.  Grrrr...  

0 Kudos