|
POST
|
No problem! Let me know if you have any other questions. If you are satisfied, don't forget to mark this thread as answered.
... View more
03-21-2014
10:13 AM
|
0
|
0
|
2038
|
|
POST
|
Hi! Thanks for the response. There are two errors with your current sample so let's fix those. First, you are using parser.parse(); when you already have both "parseOnLoad: true" and "dojo/domReady!" in your code. I noticed that you were copy/pasting code from Nliu's sample, which included the parser. These can all be used in different situations. You may find value in reading documentation about the following modules: "dojo/parser", "dom/ready", "dojo/domReady!". Also read about the 'parseOnLoad' djConfig property. Secondly, you reference dom nodes that do not exist in your sample. Remove the following lines and your sample seems to work for me. dojo.byId("ChangeFeatureRenderer").disabled = false; dojo.byId("SetVisibleLayersProgramatically").disabled = false; dojo.byId("FindNodeByLayer").disabled = false; dojo.byId("InsertNewLayer").disabled = false; *edit, You should always use try/catch blocks if you suspect a problem in a specific section of code. I also recommend browser-based development tools for troubleshooting problems like these.
... View more
03-21-2014
10:07 AM
|
1
|
0
|
3354
|
|
POST
|
It looks like you are creating a new TOC every time a layer is added to your map. Your map has multiple layers being added, so the 'layer-add-result' is firing multiple times.
... View more
03-21-2014
09:33 AM
|
0
|
0
|
3354
|
|
POST
|
You can use DOJO's AMD style event listener, on, and listen for the 'load' event that the map emits. http://dojotoolkit.org/reference-guide/1.9/dojo/on.html#dojo-on Blog: http://dojotoolkit.org/documentation/tutorials/1.9/events/
on(map, "load", function(){
// the map has been loaded, do the following
directions.getDirections();
});
edit* This should also work (same thing written differently).
map.on("load", function(){
// the map has been loaded, do the following
directions.getDirections();
});
... View more
03-21-2014
08:23 AM
|
0
|
0
|
2095
|
|
POST
|
Hi and welcome to the forums! Are you waiting for both the DOM and the map to load before calling getDirections()?
... View more
03-21-2014
08:10 AM
|
0
|
0
|
2095
|
|
POST
|
Hi Jason, You must have a syntax error elsewhere in your application as I was able to draw a polyline using the JSON in your last post. I also changed the version of my sample to 3.5 and it still works. <!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://js.arcgis.com/3.5/js/esri/css/esri.css"> <script src="http://js.arcgis.com/3.5/"></script> <style type="text/css"> html, body, #mapDiv { padding: 0; margin: 0; height: 100%; } </style> <script> var map; require([ "dojo/ready", "esri/map", "esri/graphic", "dojo/on", "esri/symbols/SimpleLineSymbol", "esri/geometry/Polyline" ], function( ready, Map, Graphic, on, SimpleLineSymbol, Polyline ) { // set up the map map = new Map("mapDiv", { basemap: "topo", //center: [-117.17, 34.03], center: [-88.053, 30.714], zoom: 5 }); // Dom Ready Event ready(function () { // Map Load Event on(map, "load", function(){ drawRoute(); }); on(map, "click", function(evt){ try{ console.log(evt.mapPoint); }catch(e){ console.log(e); } }); }); // Draw Route function drawRoute() { // Path Data //var inputJson = {"paths":[[[-13043348,4034155],[-13043274,4034040]],[[-13043274,4034040],[-13043226,4034010]],[[-13043226,4034010],[-13043201,4034010]],[[-13043201,4034010],[-13043193,4033972]],[[-13043193,4033972],[-13043248,4033928]],[[-13043248,4033928],[-13043275,4033909]],[[-13043275,4033909],[-13043284,4033890]],[[-13043284,4033890],[-13043319,4033900]],[[-13043319,4033900],[-13043341,4033886]],[[-13043341,4033886],[-13043349,4033870]],[[-13043349,4033870],[-13043341,4033808]],[[-13043341,4033808],[-13043171,4033551]],[[-13043171,4033551],[-13043097,4033605]],[[-13043097,4033605],[-13043097,4033357]],[[-13043097,4033357],[-13042661,4033348]],[[-13042661,4033348],[-13042660,4033162]],[[-13042660,4033162],[-13042661,4032943]],[[-13042661,4032943],[-13042501,4032943]],[[-13042501,4032943],[-13042498,4032620]],[[-13042498,4032620],[-13042455,4032616]],[[-13042455,4032616],[-13042446,4032376]],[[-13042446,4032376],[-13042419,4032299]],[[-13042419,4032299],[-13042314,4032243]],[[-13042314,4032243],[-13042250,4032188]],[[-13042250,4032188],[-13042237,4032151]],[[-13042237,4032151],[-13042243,4032109]],[[-13042243,4032109],[-13042243,4032056]],[[-13042243,4032056],[-13042240,4032025]],[[-13042240,4032025],[-13042254,4032012]],[[-13042254,4032012],[-13042284,4032064]],[[-13042284,4032064],[-13042315,4032095]],[[-13042315,4032095],[-13042674,4032187]],[[-13042674,4032187],[-13042704,4032195]],[[-13042704,4032195],[-13042739,4032257]],[[-13042739,4032257],[-13042765,4032267]],[[-13042765,4032267],[-13042834,4032275]],[[-13042834,4032275],[-13042868,4032295]],[[-13042868,4032295],[-13042882,4032357]],[[-13042882,4032357],[-13042883,4032422]],[[-13042883,4032422],[-13042926,4032452]],[[-13042926,4032452],[-13042992,4032527]],[[-13042992,4032527],[-13043059,4032609]],[[-13043059,4032609],[-13043116,4032593]],[[-13043116,4032593],[-13043278,4032553]],[[-13043278,4032553],[-13043324,4032547]],[[-13043324,4032547],[-13043488,4032597]],[[-13043488,4032597],[-13043561,4032603]],[[-13043561,4032603],[-13043773,4032808]],[[-13043773,4032808],[-13043889,4032917]],[[-13043889,4032917],[-13043963,4032871]],[[-13043963,4032871],[-13044030,4032829]],[[-13044030,4032829],[-13044206,4032840]],[[-13044206,4032840],[-13044286,4032865]],[[-13044286,4032865],[-13044391,4032910]],[[-13044391,4032910],[-13044509,4032958]],[[-13044509,4032958],[-13044658,4033187]],[[-13044658,4033187],[-13044265,4033451]],[[-13044265,4033451],[-13044065,4033580]],[[-13044065,4033580],[-13043994,4033655]],[[-13043994,4033655],[-13043946,4033713]],[[-13043946,4033713],[-13044097,4033954]],[[-13044097,4033954],[-13043891,4034095]],[[-13043891,4034095],[-13043482,4034361]],[[-13043482,4034361],[-13043381,4034203]]],"spatialReference":{"wkid":102100}}; var inputJson = {"paths":[[[-82.28059583333333,37.676645],[-82.22337388888888,37.649078]],[[-82.22337388888888,37.649078],[-82.21678694444445,37.63686]],[[-82.21678694444445,37.63686],[-82.217025,37.63654722222222]],[[-82.217025,37.63654722222222],[-82.19833694444445,37.628648]],[[-82.19833694444445,37.628648],[-82.16454388888888,37.622905]],[[-82.16454388888888,37.622905],[-82.13079694444444,37.593836]],[[-82.13079694444444,37.593836],[-82.13404388888888,37.555935]],[[-82.13404388888888,37.555935],[-82.06316083333333,37.537762]],[[-82.06316083333333,37.537762],[-81.99972083333333,37.543205]],[[-81.99972083333333,37.543205],[-81.96431777777778,37.544662]],[[-81.96431777777778,37.544662],[-81.94330777777777,37.5179]],[[-81.94330777777777,37.5179],[-81.9128361111111,37.503762]],[[-81.9128361111111,37.503762],[-81.9016338888889,37.48501]],[[-81.9016338888889,37.48501],[-81.89493333333333,37.482933333333335]],[[-81.89493333333333,37.482933333333335],[-81.86131388888888,37.47141]],[[-81.86131388888888,37.47141],[-81.83945277777778,37.482038]],[[-81.83945277777778,37.482038],[-81.81833861111111,37.47138508333333]],[[-81.81833861111111,37.47138508333333],[-81.80213388888889,37.44844]],[[-81.80213388888889,37.44844],[-81.78444722222222,37.40136944444444]],[[-81.78444722222222,37.40136944444444],[-81.7851338888889,37.40085]],[[-81.7851338888889,37.40085],[-81.80295083333332,37.392735]],[[-81.80295083333332,37.392735],[-81.80213083333333,37.372201]],[[-81.80213083333333,37.372201],[-81.79958583333334,37.356641]],[[-81.79958583333334,37.356641],[-81.75790277777777,37.344669]],[[-81.75790277777777,37.344669],[-81.73648888888888,37.340101]],[[-81.73648888888888,37.340101],[-81.7152938888889,37.33817]],[[-81.7152938888889,37.33817],[-81.70774194444445,37.318557]],[[-81.70774194444445,37.318557],[-81.69520388888888,37.320108]],[[-81.69520388888888,37.320108],[-81.68616694444444,37.301731]],[[-81.68616694444444,37.301731],[-81.66487083333334,37.270696]],[[-81.66487083333334,37.270696],[-81.63983083333333,37.232655]],[[-81.63983083333333,37.232655],[-81.63202777777778,37.193307]],[[-81.63202777777778,37.193307],[-81.63247222222222,37.192480555555555]],[[-81.63247222222222,37.192480555555555],[-81.70073388888889,37.143483]],[[-81.70073388888889,37.143483],[-81.75858194444444,37.082746]],[[-81.75858194444444,37.082746],[-81.80376083333333,37.094014]],[[-81.80376083333333,37.094014],[-81.82804888888888,37.094674]],[[-81.82804888888888,37.094674],[-81.85555777777777,37.08610566666667]],[[-81.85555777777777,37.08610566666667],[-81.89637,37.043704]],[[-81.89637,37.043704],[-81.94194583333333,37.028608444444444]],[[-81.94194583333333,37.028608444444444],[-81.98889638888889,37.01555091666667]],[[-81.98889638888889,37.01555091666667],[-82.05962,36.991273]],[[-82.05962,36.991273],[-82.15301277777777,36.9442]],[[-82.15301277777777,36.9442],[-82.15268888888889,36.94458888888889]],[[-82.15268888888889,36.94458888888889],[-82.19889277777777,36.921662805555556]],[[-82.19889277777777,36.921662805555556],[-82.224405,36.912338]],[[-82.224405,36.912338],[-82.2793138888889,36.892602777777775]],[[-82.2793138888889,36.892602777777775],[-88.05388944444445,30.714161027777777]]],"spatialReference":{"wkid":4326}}; // Setup the Symbol var polylineSymbol = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new dojo.Color([102,0,51]), 4); // Updating the Symbol after initial Creation polylineSymbol.setStyle(SimpleLineSymbol.STYLE_DASH); polylineSymbol.setColor(new dojo.Color([102, 0, 0, .5])); polylineSymbol.setWidth(4); //Create Graphic for Route var runningRoute = new Polyline(inputJson); map.graphics.add(new Graphic(runningRoute,polylineSymbol)); } }); </script> </head> <body class="claro"></body> </html> Try checking the console for errors and maybe a try/catch block if you can pinpoint the offending code.
... View more
03-21-2014
07:49 AM
|
0
|
0
|
2038
|
|
POST
|
Hi and welcome to the forums! Below is some code that may help. The code itself is from this sample, but modified to use both 3.9 and AMD style syntax.
<!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://js.arcgis.com/3.9/js/esri/css/esri.css">
<script src="http://js.arcgis.com/3.9/"></script>
<style type="text/css">
html, body, #mapDiv {
padding: 0;
margin: 0;
height: 100%;
}
</style>
<script>
var map;
require([
"dojo/ready",
"esri/map",
"esri/graphic",
"dojo/on",
"esri/symbols/SimpleLineSymbol",
"esri/geometry/Polyline"
], function(
ready,
Map,
Graphic,
on,
SimpleLineSymbol,
Polyline
) {
// set up the map
map = new Map("mapDiv", {
basemap: "topo",
center: [-117.17, 34.03],
zoom: 15
});
// Dom Ready Event
ready(function () {
// Map Load Event
on(map, "load", function(){
drawRoute();
});
});
// Draw Route
function drawRoute() {
// Path Data
var inputJson = {"paths":[[[-13043348,4034155],[-13043274,4034040]],[[-13043274,4034040],[-13043226,4034010]],[[-13043226,4034010],[-13043201,4034010]],[[-13043201,4034010],[-13043193,4033972]],[[-13043193,4033972],[-13043248,4033928]],[[-13043248,4033928],[-13043275,4033909]],[[-13043275,4033909],[-13043284,4033890]],[[-13043284,4033890],[-13043319,4033900]],[[-13043319,4033900],[-13043341,4033886]],[[-13043341,4033886],[-13043349,4033870]],[[-13043349,4033870],[-13043341,4033808]],[[-13043341,4033808],[-13043171,4033551]],[[-13043171,4033551],[-13043097,4033605]],[[-13043097,4033605],[-13043097,4033357]],[[-13043097,4033357],[-13042661,4033348]],[[-13042661,4033348],[-13042660,4033162]],[[-13042660,4033162],[-13042661,4032943]],[[-13042661,4032943],[-13042501,4032943]],[[-13042501,4032943],[-13042498,4032620]],[[-13042498,4032620],[-13042455,4032616]],[[-13042455,4032616],[-13042446,4032376]],[[-13042446,4032376],[-13042419,4032299]],[[-13042419,4032299],[-13042314,4032243]],[[-13042314,4032243],[-13042250,4032188]],[[-13042250,4032188],[-13042237,4032151]],[[-13042237,4032151],[-13042243,4032109]],[[-13042243,4032109],[-13042243,4032056]],[[-13042243,4032056],[-13042240,4032025]],[[-13042240,4032025],[-13042254,4032012]],[[-13042254,4032012],[-13042284,4032064]],[[-13042284,4032064],[-13042315,4032095]],[[-13042315,4032095],[-13042674,4032187]],[[-13042674,4032187],[-13042704,4032195]],[[-13042704,4032195],[-13042739,4032257]],[[-13042739,4032257],[-13042765,4032267]],[[-13042765,4032267],[-13042834,4032275]],[[-13042834,4032275],[-13042868,4032295]],[[-13042868,4032295],[-13042882,4032357]],[[-13042882,4032357],[-13042883,4032422]],[[-13042883,4032422],[-13042926,4032452]],[[-13042926,4032452],[-13042992,4032527]],[[-13042992,4032527],[-13043059,4032609]],[[-13043059,4032609],[-13043116,4032593]],[[-13043116,4032593],[-13043278,4032553]],[[-13043278,4032553],[-13043324,4032547]],[[-13043324,4032547],[-13043488,4032597]],[[-13043488,4032597],[-13043561,4032603]],[[-13043561,4032603],[-13043773,4032808]],[[-13043773,4032808],[-13043889,4032917]],[[-13043889,4032917],[-13043963,4032871]],[[-13043963,4032871],[-13044030,4032829]],[[-13044030,4032829],[-13044206,4032840]],[[-13044206,4032840],[-13044286,4032865]],[[-13044286,4032865],[-13044391,4032910]],[[-13044391,4032910],[-13044509,4032958]],[[-13044509,4032958],[-13044658,4033187]],[[-13044658,4033187],[-13044265,4033451]],[[-13044265,4033451],[-13044065,4033580]],[[-13044065,4033580],[-13043994,4033655]],[[-13043994,4033655],[-13043946,4033713]],[[-13043946,4033713],[-13044097,4033954]],[[-13044097,4033954],[-13043891,4034095]],[[-13043891,4034095],[-13043482,4034361]],[[-13043482,4034361],[-13043381,4034203]]],"spatialReference":{"wkid":102100}};
// Setup the Symbol
var polylineSymbol = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new dojo.Color([102,0,51]), 4);
// Updating the Symbol after initial Creation
polylineSymbol.setStyle(SimpleLineSymbol.STYLE_DASH);
polylineSymbol.setColor(new dojo.Color([102, 0, 0, .5]));
polylineSymbol.setWidth(4);
//Create Graphic for Route
var runningRoute = new Polyline(inputJson);
map.graphics.add(new Graphic(runningRoute,polylineSymbol));
}
});
</script>
</head>
<body class="claro"></body>
</html>
Here's a link to a working version on jsfiddle: http://jsfiddle.net/8qwdH/1/
... View more
03-20-2014
02:58 PM
|
0
|
0
|
2038
|
|
POST
|
Thanks Jeff! Glad everything was taken care of! Apologies for the delayed response; most of us have been at the DevSummit all week.
... View more
03-14-2014
08:57 AM
|
0
|
0
|
1527
|
|
POST
|
Hi Keith! Some documentation here: https://developers.arcgis.com/javascript/jshelp/inside_feature_layers.html The tutorial links at the bottom of that document are what you are looking for.
... View more
03-04-2014
02:04 PM
|
0
|
0
|
1690
|
|
POST
|
What version of Chrome are you seeing this issue in? You are not seeing this issue in Firefox or IE, correct? Also, is this desktop or mobile? I am using: Version 33.0.1750.146 m. Using your code, the 'extent-change' event fires once when the the map first loads, as expected. However, the 'extent-change' event does not fire on a single map click. I must drag or zoom for the 'extent-change' event to fire.
... View more
03-04-2014
01:57 PM
|
0
|
0
|
2114
|
|
POST
|
Great find Ben! Thanks a bunch for pointing that out. I'll notify the doc guys and get it fixed. If you ever find any other issues don't hesitate to email the team, email support or make a new thread here. You're always very helpful. Thanks again Ben!
... View more
02-07-2014
08:28 AM
|
0
|
0
|
802
|
|
POST
|
Hi Michelle. I spent some time on this yesterday but did not realize your application was written in the old style so I put it aside. Jake's code is in the newer style (AMD) and on the right track but I personally would use a dgrid instead of DataGrid. As for the issue, yep that's exactly it! When coding in the legacy style, you will need to require each module individually and invoke using the same path pattern. New Style (AMD):
require([
"esri/map",
"esri/dijit/HomeButton"
], function (Map, HomeButton) {
var home = new HomeButton();
});
Old Style (Legacy):
dojo.requrie("esri.Map");
dojo.requrie("esri.dijit.HomeButton");
var home = new esri.dijit.HomeButton();
Is there any reason you are writing your application in the legacy style? It will be deprecated sooner than later and I only bring it up so you aren't forced to rewrite the entire application somtime in the next year.
... View more
02-05-2014
09:45 AM
|
0
|
0
|
1907
|
|
POST
|
Absolutely! For this task, I would highly recommend using dgrid over dojox.datagrid. Depending on your data source, you have several options: dgrid (OnDemandGrid) with a standard Memory store. Refresh the grid when your featureLayer update event fires --- myGrid.refresh(); dgrid (OnDemandGrid) with a JsonRest store. Automatically updates depending on your external JSON data. http://dojotoolkit.org/reference-guide/1.9/dojo/store/JsonRest.html http://dojofoundation.org/packages/dgrid/tutorials/grids_and_stores/ https://github.com/SitePen/dgrid/wiki/OnDemandList-and-OnDemandGrid These are only two of the many options available to you. At the end of the day, it depends on what you feel comfortable with.
... View more
02-05-2014
09:33 AM
|
0
|
0
|
1797
|
|
POST
|
Hi Shaning. This is a bit off-topic but needs to be said: I've personally asked you three times to PLEASE use tags when posting code snippets. I've also seen others ask you to do the same, yet you still do not comply. I've also noticed you like to credit yourself with answering your own questions, when someone else offers you a legitimate answer. This is a bit frustrating for both myself and other forum-goers, as it seems you either a) don't understand general forum etiquette or b) you are ignoring our polite requests intentionally. I know option b) is unlikely, as you spend a lot of time on this forum seeking help. However, please be aware that there is a fine line between helping someone, and doing their work for them. If you would like help, please respect the other users of this forum and follow the rules and guidelines. Thank you very much. Back on topic: Please create a jsfiddle highlighting your problem, with a clear explanation of the issue and errors and I will be able to assist you.
... View more
02-05-2014
09:19 AM
|
0
|
0
|
2646
|
|
POST
|
there is no real way to manually call those methods on map for every single combination on when the map is going to be displaced. Why not? It has to be an event that tells you when the reposition happen. Exactly. The map isn't going to throw an event for something unrelated to the map itself. You need to create a custom event for changes in your interface. It only works when you resize the the browser window, but when you use the plank I shared, and add things to the dom, which causes the map to reposition, that event is not fired. This sounds more like a flaw in your application design, rather than a problem with the JSAPI. If you add anything to the dom, fire map.resize() and map.resposition. Anytime somethings gets added or removed from the dom, an event can and will be fired. Another option: wire up an event on the map container to see when the height or width of the container has been changed.
... View more
02-04-2014
11:52 AM
|
0
|
0
|
1091
|
| 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
|