|
POST
|
This happens in Chrome version 33.0.1750.154. I'll have to double-check my version at home.
... View more
04-22-2014
09:50 AM
|
0
|
0
|
2161
|
|
POST
|
Ok, I got this working, somewhat, but I'll get to that. This works.
require([
"dojo/Evented",
"dojo/ready",
"dojo/parser",
"dojo/on",
"extras/clusterlayerNew",
"esri/map",
"esri/layers/graphics",
"esri/layers/FeatureLayer",
"esri/layers/GraphicsLayer",
"esri/tasks/QueryTask",
"esri/tasks/query",
"dijit/layout/BorderContainer",
"dijit/layout/ContentPane",
"dojo/domReady!"
],
function (
Evented,
ready,
parser,
on,
ClusterlayerNew,
Map, // you had lower-case map, which can cause problems when creating a map variable
graphics, // This is an empty object because it is not a module
FeatureLayer,
GraphicsLayer,
QueryTask, // was called queryTask, biggest issue
Query,
BorderContainer,
ContentPane
) {
var map;
// scope this out here. The above had same name (case matters).
var queryTask = new QueryTask("http://gis.phila.gov/ArcGIS/rest/services/PhilaGov/Police_Incidents_Last30/MapServer/0");
function init() {
parser.parse();
map = new Map("map", { // You had map = new map(), this could cause issues, probably in IE, everything breaks in IE.
center: [-75.1700, 39.9500],
zoom: 12,
basemap: "hybrid"
});
runQuery(); // you need the map in the runQuery method, so initialize it first then do runQuery
}
function runQuery() {
var query = new Query();
query.returnGeometry = true;
query.where = '1=1';
query.outFields = ["DC_DIST", "POINT_X", "POINT_Y"];
queryTask.on("complete", function (event) {
console.debug('ClusterlayerNew is an empty object?', ClusterlayerNew);
// This clusterlayer module is broken, it returns an empty object, even after I quickly edited it.
// I did not try troubleshooting this
var cL = new ClusterlayerNew({
displayOnPan: false,
map: map,
features: event.featureSet.features,
infoWindow: {
template: new esri.InfoTemplate("${SECTOR}"),
width: 325,
height: 100
},
flareLimit: 15,
flareDistanceFromCenter: 20
});
map.addLayer(cL);
});
// you were trying to execute this outside the scope of the function the query was defined in.
queryTask.execute(query);
};
// before, this was the class "QueryTask", the class is not initialized, thus not an event emitter.
on(queryTask, "error", function (err) {
alert(err.details);
});
// Use the ready() method as opposed to dojo.addOnLoad
ready(init);
});
See my comments for some of the issues you had. One of your main issues seems to be with scope, so I would run through some material and you'll soon see where things broke. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope Don't mix the old dojo.lib.ClassName() with the AMD loading of modules. In this case, it probably just added to the confusion. Note - Mixing the two won't necessarily break your code (yet), but it should be avoided fro consistency. That clusterlayerNew module is broken or something, I couldn't get it to work, but my changes above load your map and at least try to create that cluster layer. You may want to check out a project I have been working on to do clusters in a fashion more similar to a FeatureLayer. https://github.com/odoe/esri-clusterfeaturelayer Hope that helps a bit.
... View more
04-16-2014
12:40 PM
|
0
|
0
|
745
|
|
POST
|
How about on(queryTask, 'complete', function(){}); You lost me there, but the execute method returns a Promise, so you can also do. queryTask.execute(query).then(someFunction);
... View more
04-15-2014
11:35 AM
|
0
|
0
|
3476
|
|
POST
|
Do you mean dojo/_base/Color? I don't think I've seen an esri/Color module.
... View more
04-11-2014
12:24 PM
|
0
|
0
|
1027
|
|
POST
|
Scott Davis did a Dojo build presentation at Dev Summit this year. https://github.com/stdavis/dojo-build-presentation https://github.com/stdavis/dojo-build-example That will probably help you out. I haven't gotten around to trying it yet (dojo builds are my mortal enemy) but Scott and the AGRC team have done all the hard work of how to do it, so it can be done, with a little hackery.
... View more
04-10-2014
05:53 AM
|
0
|
0
|
1325
|
|
POST
|
arcgis.Utils.createmap takes a third options parameter. https://developers.arcgis.com/javascript/jsapi/esri.arcgis.utils-amd.html#createmap It looks a little odd at first, but you can do the following: var mapOptions = { basemap: "topo", autoResize: false, // see http://forums.arcgis.com/threads/90825-Mobile-Sample-Fail center: [-71.7, 42.35], zoom: 8, minZoom: 7, logo: false, slider: true, sliderStyle: "small" }); arcgisUtils.createMap(webmapid, "mapDiv", { mapOptions: mapOptions }).then(function (response) {map = response.map;}); That should do what you're looking for.
... View more
04-03-2014
06:08 AM
|
0
|
0
|
1615
|
|
POST
|
Could it be the map is loading before this line has a chance to run. def.addCallback(lang.hitch(this, function (tokenInfo) {...})) I can't tell when the initPredefinedSecurity() executes, but if you want to be sure it runs before the map loads, maybe try returning a promise so you can do initPredefinedSecurity().then(function() { /*map load goodies*/ }); Again, I could be totally misunderstanding the sequence of events you have going here.
... View more
03-28-2014
12:11 PM
|
0
|
0
|
784
|
|
POST
|
You may want to take a look at Scotts blog post here http://geospatialscott.blogspot.com/2013/09/the-esri-api-for-javascriptdojo-build.html He discusses how he is using the Dojo build system to create single file builds and a big help was that there is a minified, unbuilt version of the api where the URL looks like js.arcgis.com/3.8amd. Since it's unbuilt, it's definitely not for production use, too slow and too many requests, but you could probably figure out how to incorporate it into your r.js build system. There is also an example showing r.js to turn your modules into single-file builds with the esri js api. https://github.com/robertd/esri-jsapi-rjs-example The esri stuff is still coming from CDN, but your own code can be a single built file, including templates. The former of these two options sounds like it might best assist in your case.
... View more
03-28-2014
08:53 AM
|
0
|
0
|
1872
|
|
POST
|
You may want to take a look at this project https://github.com/odoe/esri-clusterfeaturelayer I took the ClusterLayer and updated to act more like a FeatureLayer. It has a ton of options to override renderers, zoom on click and more. The index.html file has an example of how it is used.
... View more
03-27-2014
04:28 AM
|
0
|
0
|
833
|
|
POST
|
You will want to review the Map module here https://developers.arcgis.com/javascript/jsapi/map-amd.html#map1 Review the details for a basemap Specify a basemap for the map. The following are valid options: "streets" , "satellite" , "hybrid", "topo", "gray", "oceans", "national-geographic", "osm". As of version 3.3 You can omit the basemap option to not load a default basemap, then after you create the map you can add your layer as follows. map.addLayer(basemap);
... View more
03-20-2014
01:29 PM
|
0
|
0
|
2137
|
|
POST
|
Do you mean the basemap? That's the street basemap defined in the map constructor.
map = new Map("map", {
basemap: "streets",
center: [-111.5, 39.541],
zoom: 7
});
Other than that, there are no other services. That example uses the GraphicsLayer to draw graphics and buffers on the map.
... View more
03-20-2014
11:12 AM
|
0
|
0
|
2137
|
|
POST
|
You could try jsdoc3. Docco is also pretty popular, but I've never used either. I try to use JSDoc style comments so that I could use something like jsdoc3 to generate docs if I need to.
... View more
03-17-2014
11:19 AM
|
0
|
0
|
956
|
|
POST
|
It's probably the map adjusting to fit the viewable space. If you provide an extent of 100x100, but the browser page or map DOM element is only 75x95, the map will adjust to fit in that space. You could try and set the center and zoom level when the map loads using the mapOptions and then the map is loaded, set the initialExtent to the extent at load, so if you want to return to that initial extent via a Home button or something, you can.
... View more
03-06-2014
05:52 AM
|
0
|
0
|
1799
|
|
POST
|
Ooh, I forgot about the AMD build, nice catch Tom! I think I tried in vain once to compile the EsriJS API locally (when running our requirejs experiments), but it wasn't using the AMD build.
... View more
03-04-2014
09:06 AM
|
0
|
0
|
4324
|
|
POST
|
The ArcGIS JavaScript API version of Dojo is an already built version of Dojo, so you cannot replace the Dojo loader with RequireJS. You can apparently use the RequireJS loader with Dojo, but only with the downloaded version and you can specify which loader to use (I have never done this, but that's my understanding). So in short, you can't use RequireJS with the ArcGIS JS API. Dojo doesn't provide a "shim" property in the config, but you can fake it like define('knockout', function() {
return ko;
});
... View more
03-04-2014
04:34 AM
|
0
|
0
|
4324
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | Wednesday | |
| 2 | 05-19-2026 02:12 PM | |
| 1 | 04-24-2026 11:01 AM | |
| 2 | 04-21-2026 07:06 AM | |
| 1 | 02-27-2026 06:31 AM |
| Online Status |
Offline
|
| Date Last Visited |
yesterday
|