|
POST
|
+1 to Jeff; he beat me to it! @Holyoaks, when you find the final solution to your problem, make sure you mark this thread as answered. Many people use nliu's TOC widget (it's great!) and this is a useful thread in case anyone runs into a similar problem.
... View more
10-02-2013
08:53 AM
|
0
|
0
|
1895
|
|
POST
|
Hmm. I can't replicate it http://jsfiddle.net/NcCWw/7/. It's working in this instance. Just not working with my full code. I suppose it's possible that it's the TOC widget I'm using that's causing the issue. OK great! We've narrowed it down. I would try initializing the TOC before my ready and parser calls, to make sure it's accessible when the page first loads.
... View more
10-02-2013
08:18 AM
|
0
|
0
|
1895
|
|
POST
|
No. The event isn't fired. The error seems to be in attaching the event to the map. Hmmm... could you replicate the issue with http://jsfiddle.net/ so I can take a look at your code?
... View more
10-02-2013
07:38 AM
|
0
|
0
|
1728
|
|
POST
|
Are you able to fire the event with a simple console.log in the function block, like in this jsfiddle? http://jsfiddle.net/NcCWw/ *edit Also, you should probably be creating the TOC object earlier on in your code (preferably before the parser runs). You can still start it up inside your event.
... View more
10-02-2013
07:33 AM
|
0
|
0
|
1728
|
|
POST
|
Unfortunately, this issue you are describing is very vague and it is hard to tell what could be wrong. If you don't mind, could you recreate your issue with code in a http://jsfiddle.net/ so we can take a look?
... View more
10-02-2013
07:28 AM
|
0
|
0
|
864
|
|
POST
|
Both are valid.
map.on("layers-add-result", function(e) {
//stuff
});
on(map, "layers-add-result", function(e) {
//stuff
});
In that document holyoaks linked, there is another document linked at the bottom that discusses both uses. https://dojotoolkit.org/reference-guide/1.9/dojo/Evented.html#dojo-evented Map is an object that fires its own events, as explained here: https://developers.arcgis.com/en/javascript/jsapi/map-amd.html Now, onto troubleshooting... Does the event fire? What happens when you wrap the problematic code in a try/catch?
... View more
10-02-2013
07:20 AM
|
0
|
0
|
1728
|
|
POST
|
Ganesh, you still haven't corrected your require block. The modules and their namespace declarations need to be invoked in the same order. If you line up your module names and namespace declarations, you will notice you have an extra declaration for array. You *really* need to read the tutorials on DOJO's site. This type of error is covered very early on. Please read this: http://dojotoolkit.org/documentation/tutorials/1.9/modern_dojo/ "dojo/ready", "dgrid/OnDemandGrid", "dgrid/Selection", "dojo/store/Memory", "esri/map", "esri/config", "esri/dijit/Geocoder", "esri/geometry/screenUtils", "esri/geometry/Extent", "esri/geometry/Point", "esri/geometry/webMercatorUtils", "esri/tasks/locator", "esri/graphic", "esri/SpatialReference", "esri/layers/FeatureLayer", "esri/layers/KMLLayer", "esri/tasks/QueryTask", "esri/tasks/query", "esri/tasks/RelationParameters", "esri/tasks/GeometryService", "esri/tasks/BufferParameters", "esri/symbols/SimpleMarkerSymbol", "esri/symbols/SimpleLineSymbol", "esri/symbols/PictureMarkerSymbol", "esri/symbols/Font", "esri/symbols/TextSymbol", "esri/InfoTemplate", "esri/dijit/BasemapGallery", "esri/arcgis/utils", "dojo/_base/array", "dojo/_base/Color", "dojo/_base/declare", "dojo/dom-style", "dojo/on", "dojo/number", "dojo/dom", "dojo/dom-construct", "dojo/query", "dijit/registry", "dojo/parser", "dijit/form/Button", "dijit/form/TextBox", "dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dijit/layout/AccordionContainer", "dijit/layout/TabContainer", "dijit/Menu", "dijit/TitlePane", "dojo/domReady!" ready, Grid, Selection, Memory, Map, esriConfig, Geocoder, screenUtils, Extent, Point, webMercatorUtils, Locator, Graphic, SpatialReference, FeatureLayer, KMLLayer, QueryTask, Query, RelationshipParameters, GeometryService, BufferParameters, SimpleMarkerSymbol, SimpleLineSymbol, PictureMarkerSymbol, Font, TextSymbol, InfoTemplate, BasemapGallery, arcgisUtils, array, arrayUtils, Color, declare, domStyle, on, number, dom, domConstruct, query, registry, parser, Button, TextBox, BorderContainer, ContentPane, AccordionContainer, TabContainer, Menu, TitlePane, domReady Make sure you mark the thread as 'answered' when you find the answer you seek.
... View more
10-01-2013
02:33 PM
|
0
|
0
|
2447
|
|
POST
|
No worries! I completely understand where you are coming from. If you want to send non-sensitive code to me via private message, I could potentially look it over. Otherwise, in an attempt to help, I created a quick sample based on the code you posted that may or may not be helpful in identifying the best place to invoke the parser. It's hard to help further without any new code.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=7,IE=9">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<title>testing</title>
<link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.4/js/esri/css/esri.css">
<link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/dojo/dijit/themes/claro/claro.css" />
<style type="text/css">
html, body, #mapDiv {
padding: 0;
margin: 0;
height: 100%;
}
</style>
<script src="http://js.arcgis.com/3.7/"></script>
<script>
require([
"dojo/ready",
"dojo/parser",
"dojo/dom-construct",
"dojo/_base/Color",
"esri/graphic",
"esri/map",
"esri/dijit/Popup",
"esri/geometry/Point",
"esri/symbols/SimpleFillSymbol",
"esri/symbols/SimpleLineSymbol",
"esri/symbols/SimpleMarkerSymbol",
], function(
ready,
parser,
domConstruct,
Color,
Graphic,
Map,
Popup,
Point,
SimpleFillSymbol,
SimpleLineSymbol,
SimpleMarkerSymbol
) {
// Variables
var map;
var highlightMarkerSymbol;
var popup;
// Set up
popup = new Popup({
titleInBody: false
},domConstruct.create("div"));
map = new Map("mapDiv", {
infoWindow: popup,
basemap: "topo",
center: [-92.593, 38.5],
zoom: 7
});
highlightMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 22, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255,255,0]), 2), new Color([255,255,0,0.5]));
ready(function () {
// parse the fully loaded DOM
parser.parse();
//do stuff
map.on("click", function(evt){
// remove old graphics from map
map.graphics.graphics.forEach(function(g){
if(g.visible == true)
map.graphics.remove(g);
});
// create simple symbol
var point = new Point(evt.mapPoint.getLongitude(), evt.mapPoint.getLatitude());
var graphic = new Graphic(point, highlightMarkerSymbol);
// add the graphic and show the popup
map.graphics.add(graphic);
map.infoWindow.setTitle("test");
map.infoWindow.setContent("test");
map.infoWindow.show(point);
});
});
});
</script>
</head>
<body class="claro">
<div id="mapDiv"></div>
</body>
</html>
... View more
10-01-2013
02:22 PM
|
0
|
0
|
1742
|
|
POST
|
Any chance you could create a jsfiddle that shows the problem? I, like you, suspect it has to do with the parser, or rather, when the parser is invoked.
... View more
10-01-2013
01:29 PM
|
0
|
0
|
1742
|
|
POST
|
var qt = new QueryTask(url);
var query = new Query();
query.where = "1=1";
query.returnGeometry = false;
query.outFields = outFieldsArr;
qt.execute(query, function (results) {
console.log("results:", results);
//do something else
});
on(qt, "complete", function(results){
console.log('test');
});
The above worked for me. If your app is failing silently and events aren't being triggered, use a try/catch block to identify at what point your code fails.
... View more
10-01-2013
11:57 AM
|
1
|
0
|
980
|
|
POST
|
Thanks for your assistance Jon. So it looks like you moved the map, grid and memstore outside of the ready function and added the line window.grid.set("store", memStore); into the populateGrid function? Geoff I also changed a leftover reference from 'array' to 'arrayUtils,' made sure you were setting the correct idProperty for the store and removed a reference to a div with an id of 'container' that did not exist.
... View more
10-01-2013
10:32 AM
|
0
|
0
|
1010
|
|
POST
|
I've seen people use the following:
var qt = new QueryTask(url);
var query = new Query();
query.where = "1=1";
query.returnGeometry = false;
query.outFields = outFieldsArr;
qt.execute(query, function (results) {
console.log("results:", results);
//do something else
});
Although this isn't using the on event specifically, it may help.
... View more
10-01-2013
10:30 AM
|
0
|
0
|
980
|
|
POST
|
http://jsfiddle.net/8RvcR/8/ Fixed. Made a number of small changes. If you use a different dataset, you have to change the column definitions and the outFields for the new dataset. Also, if your code fails silently, use try/catch blocks to identify the source of the error. This is the best JS advice anyone ever gave me.
... View more
10-01-2013
08:28 AM
|
0
|
0
|
3784
|
|
POST
|
Hi Jeff, I tried it works for me.... check this fiddle: http://jsfiddle.net/patelmanya/f9nCn/ or did I get that wrong. Thanks, Manish I believe he's talking about being unable to download the API here: http://www.esri.com/apps/products/download/index.cfm?fuseaction=download.all#ArcGIS_API_for_JavaScript
... View more
10-01-2013
07:53 AM
|
0
|
0
|
2561
|
|
POST
|
Hey Geoff, I tried to make a demo using your code but I don't have enough context to do it successfully (need your css, and a ArcGISTiledMapServiceLayer with a spacial reference of wkid: 3361) Could you replicate your problem in a jsfiddle so us forum-goers can have a better chance of successfully fixing the problem. One thing I noticed while trying to build a demo: the parser is potentially being called too early. Make sure your map and dgrid are created before invoking parser.parse(); Hard to say if that matters in the context of this application without seeing the error in action.
... View more
10-01-2013
07:13 AM
|
0
|
0
|
2775
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 08-26-2014 09:56 AM | |
| 1 | 09-18-2014 11:50 AM | |
| 1 | 09-19-2014 11:28 AM | |
| 1 | 07-09-2014 01:43 PM | |
| 1 | 07-09-2014 02:05 PM |
| Online Status |
Offline
|
| Date Last Visited |
08-14-2024
05:31 PM
|