|
POST
|
Try this. First, add "dojo/_base/event" to your list of requires. Now add this event handler on your geocoder div: on(dijit.byId('search'), 'keydown', function(e) {
var theInput = dijit.byId('search').value;
if (theInput.length > 5) {
event.stop(e);
}
}); Obviously, adjust the length to whatever you want. In my application, any additional characters beyond 5 stops the input in its tracks.
... View more
02-17-2015
11:40 AM
|
0
|
0
|
1870
|
|
POST
|
Wouldn't you just declare the map variable globally and then assign it within the define section? Something like this:
var map; define(["esri/map", "dojo/on"], function (Map) { return { createMap: function (mapDivID) { map = new Map(mapDivID); }, //createMap ends }; }); define(["esri/map", "dojo/on"], function (Map) { return { createMap: function (mapDivID) { var map = new Map(mapDivID); }, //createMap ends }; });
... View more
02-13-2015
08:08 AM
|
1
|
0
|
3579
|
|
POST
|
Dates values are in Epoch format so you'll need to specify your date value as such. If you have your date of interest as a variable, then the Epoch value of that date would be: var epochDate = theDate.getTime() / 1000; Your query then should be "date_created > " + epochDate This is untested, though..
... View more
02-04-2015
08:48 AM
|
2
|
0
|
1148
|
|
POST
|
Based on ESRI's attribute inspector sample, it looks like that shading is controlled by the Dojo dijitTextBoxDisabled css class.
... View more
02-03-2015
01:55 PM
|
1
|
0
|
1425
|
|
POST
|
If it helps, I do this in one of my applications. The infoWindow appears and has two buttons that the user can click which fires off a function that generates a report. Here's the entire function for the content of my infoWindow: function SetSwmPopupInfo(graphic) { var fullAttr = graphic.attributes; var rptParam, content, theProjID, theTipType; var theCipID = fullAttr.ProjectNo; rptParam = "'" + graphic.attributes.OBJECTID + ',' + graphic.geometry.type + ',' + "SWM" + "'"; rptProjectName = graphic.attributes.ProjTitle; if (theCipID.length > 1) { theProjID = fullAttr.ProjectNo; } else { theProjID = "Unknown"; } content = '<table width=\"100%\"><tr><td valign=\'top\' style=\"font-weight:bold;padding-left:3px;padding-right:3px\">Project Name:</td><td valign=\'top\' style=\"padding-left:3px;padding-right:3px\">' + fullAttr.ProjTitle + '</td></tr>'; content = content + '<tr><td valign=\'top\' style=\"font-weight:bold;padding-left:3px;padding-right:3px;vertical-align:top\">CIP Project ID:</td><td valign=\'top\' style=\"padding-left:3px;padding-right:3px;vertical-align:top\">' + theProjID + '</td></tr>'; content = content + '<tr><td valign=\'top\' style=\"font-weight:bold;padding-left:3px;padding-right:3px;vertical-align:top\">Type of Project:</td><td valign=\'top\' style=\"padding-left:3px;padding-right:3px;vertical-align:top\">' + fullAttr.Category.toProperCase() + '</td></tr>'; content = content + '<tr><td colspan=\"2\" align=\"center\"><br/><button id=\"reportButton\" type=\"button\" onclick=\"getTractProjectReport(' + rptParam + ')\">View a Summary Demographic Report (Census Tract Level)</button></td></tr>'; content = content + '<tr><td colspan=\"2\" align=\"center\"><button id=\"reportBlockButton\" type=\"button\" onclick=\"getBlockProjectReport(' + rptParam + ')\">View a Summary Demographic Report (Block Group Level)</button></td></tr></table>'; return content; } Make sure the function you are trying to call is located within the function of your AMD requires: require(["esri/map""], function("Map") { ... //Place your called function inside and at the end of this space });
... View more
01-29-2015
01:48 PM
|
0
|
0
|
1732
|
|
POST
|
Cool- thanks, Ken! I've converted Joel's snippit "back" to legacy if anyone also needs it. The workaround does seem to work- not perfectly, but much better than without it!
... View more
01-29-2015
12:57 PM
|
0
|
0
|
1411
|
|
POST
|
I don't want to hijack Tracy's thread but this has frustrated me as well so I was watching this thread. I want/need to implement this into a legacy 3.3 API project but it's choking on my dojo.require. I tried "esri.kernel" instead of "esri/kernel" but it can't find it. Any guesses on how to reference this under legacy coding?
... View more
01-29-2015
12:23 PM
|
0
|
2
|
1411
|
|
POST
|
There is a mouse-drag event. Maybe that's what needs to be set up if you determine that the visitor is using a smartphone?..
... View more
01-26-2015
11:39 AM
|
0
|
1
|
2084
|
|
POST
|
[Nothing feels better than having this stupid forum dump your reply and have to start all over.. Grrr.....] I can see how my response might be confusing. It's quite the hot mess I've developed. Your workflow would be something like this: User clicks button to run your report The HTML button's onClick event would first create and display a new browser window. (in my case, I have a very basic HTML file, demographicReport.html, which is barebones and only contains one of those JSON "Loading" animated GIFs so that the user knows something is happening). Once the second window is opened, you need to clear the HTML from the page and begin creating your report using javascript and DOM manipulation. The first step here is some sort of "base template" for your report. Now, my report may or may not contain some elements so I basically had to create the entire report from scratch AND programmatically. If your report is going to be fairly static about what is included, you can probably get away with manually writing some HTML and then passing that file to the window.open() method I've previously discussed and skip what I'm about to talk about next. In my app, here's where that returnTractHtml ReportTemplate function comes into play. I've included a couple screenshots which show the code of the function as well as what that HTML finally looks like once it's inserted into the HTML page. Hopefully you can see the basic structure between this barebones screenshot and the PDF report example I previously attached. Once I have that template "code" in the variable, I update the page in the second window with that content (also part of the second code snippit in my original reply). The framework for your report is now in place- let's add some information to it. To do this, you're going to be using a whole lot of DOM manipluation functions such as getElementByID to update/modify any existing HTML page elements and createElement to create new items to insert into the page. Try to keep everything grouped into DIV elements for structure and for keeping tract of everything. It sounded like the primary feature of your "report" would be the contents of your Grid. In this case, give your report template an empty HTML table framework. Loop through your Grid's values and then manually add that information into your report's HTML Table template using DOM. This reference should give you some idea of what that javascript might look like. It's a lot of upfront work but unless you can find another solution (geoprocessing service?..), it might be your only bet. Hope this helps!
... View more
01-07-2015
02:49 PM
|
1
|
0
|
3019
|
|
POST
|
Hi Jay, I do some reporting within the JS API but probably not in the way you're probably thinking. Here's the basic idea: Upon a user mouse click of a button within my app, it performs queries against 3 different census datasets using deferred lists. Once the results are returned, I build the "report" on the fly by creating DOM objects in a secondary browser window (a popup). In the onClick event for the button, you'd create the popup browser window and assign it to a global variable: //The new browser window must be opened in the function called by the 'onClick' event so
//the new window is created here and its associated variable is created with a global scope.
//Calculate the center of the screen for placement of the new window
var center_left = (screen.width / 2) - (1100 / 2);
var center_top = (screen.height / 2) - (600 / 2);
newWindow = window.open('demographicReport.html','mywindow','width=1100,height=600,menubar=yes,scrollbars=yes,left=' + center_left + ',top=' + center_top); In the code above, demographicReport.html is a real HTML file but it's content doesn't really matter. It's only loaded as the initial source for the new window. Once the window is opened, the contents are cleaned out using DOM functions and then my report is constructed. So, in the callback function for the deferredList, I have code to erase the HTML and insert new HTML: //Create the string based version of the HTML page template
var bodyContent;
bodyContent = returnTractHtmlReportTemplate();
//Open the new window and obtain a reference to it's DOM
theDocument = newWindow.document;
//Swap out the empty DOM of the browser for a string based version of the HTML template
theDocument.open("text/html","replace");
theDocument.write(bodyContent);
theDocument.close(); Once you have the basic HTML set up, you can now use standard JS to add or edit DOM elements: //Now begin editing/adding page elements as needed
theDocument.getElementById("prjName").innerHTML = rptProjectName;
theDocument.getElementById("tractCount").innerHTML = raceResults.length; It's involved and tedious but it will get the job done. Your user can then print the web page to a PDF if they want to save it for later. Attached is an example output of my process.
... View more
01-07-2015
11:45 AM
|
0
|
1
|
3022
|
|
POST
|
Am I seeing this correctly? I've begun using the onError event with my services to indicate to the user that there's an issue when my application loads. This works great when it throws something like a 500 error, etc. Recently, we had a situation where the services were just reaching the 60 second timeout limit. When I was trying to debug this, I noticed that the onError event was called at the conclusion of the 60 second timeout but that the error variable (i.e. layer.on("error", function(error){...}) ) is undefined when the "error" is a service timeout. Is this as designed? Should I or should I not assume that an undefined error variable within that function is a service timeout?? In other words, is it likely that other "errors" may trigger the onError event but leave the error variable as undefined? Thanks! Steve
... View more
01-06-2015
08:37 AM
|
0
|
0
|
4708
|
|
POST
|
Unless I'm missing something, I do exactly this in one of my apps. Here's the REST Service directory for my published service with the table so you can see that it's set up just like your service. As part of my overall app (it shows stream gauge readings in our County), you can view a larger hydrograph in a new window. The new window opens, loads the JS API and does a QueryTask on that table to retrieve the data to be displayed in the graph. It's written in legacy coding but here's an example link.
... View more
12-17-2014
12:02 PM
|
0
|
0
|
1308
|
|
POST
|
I've also added a couple other options based on the lat/long location clicked. These may or may not be applicable to your project: Bing also has an oblique aerial view (based on Pictommetry products) which you can display: ctxMenuForMap.addChild(new MenuItem({
id: "lblBirdsEye",
label: "Open Location in Bing\'s Birds Eye View",
onClick: function() {
openBirdsEye(currentMouseLocation);
}
function openBirdsEye(theLocation) {
var theLatLongGeom = webMercatorUtils.webMercatorToGeographic(theLocation);
var theUrl = "http://bing.com/maps/default.aspx?cp=" + theLatLongGeom.y + "~" + theLatLongGeom.x + "&style=b&dir=0#ToggleTaskArea";
window.open(theUrl, 'BirdsEye', "height=650,width=800,resizable=yes,scrollbars=yes");
} Finally, pull up NWS weather forecasts for a given location: ctxMenuForMap.addChild(new MenuItem({
id: "lblShowWeather",
label: "NWS Forecast For This Location",
onClick: function() {
openWeatherForecast(currentMouseLocation);
}
}));
function openWeatherForecast(theLocation) {
var theLatLongGeom = webMercatorUtils.webMercatorToGeographic(theLocation);
var theUrl = "http://forecast.weather.gov/MapClick.php?lon=" + theLatLongGeom.x + "&lat=" + theLatLongGeom.y;
window.open(theUrl, 'Forecast', "height=600,width=1050,resizable=yes,scrollbars=yes");
}
... View more
12-17-2014
09:37 AM
|
6
|
1
|
3673
|
|
POST
|
I've added it to my application as a context menu item. I implemented it based on ESRI's context menu sample and then added my own code: ctxMenuForMap.addChild(new MenuItem({
id: "lblStreetview",
label: "Open Location in Google Streetview",
onClick: function() {
openStreetview(currentMouseLocation);
}
function openStreetview(theLocation) {
var theLatLongGeom = webMercatorUtils.webMercatorToGeographic(theLocation);
var theUrl = "http://maps.google.com/maps?q=Your+Sign+Location+in+Street+View@" + theLatLongGeom.x + "," + theLatLongGeom.y + "&cbll=" + theLatLongGeom.y + "," + theLatLongGeom.x + "&layer=c";
window.open(theUrl, 'Streetview', "height=500,width=800,resizable=yes,scrollbars=yes");
} Note that you'll need to add a reference for the webMercatorUtils.
... View more
12-17-2014
09:11 AM
|
6
|
2
|
3673
|
|
POST
|
Bummer. You're a pretty seasoned veteran of the JS API so I'm not surprised that you already tried my suggestions. Ya never know, though!
... View more
12-10-2014
10:05 AM
|
0
|
1
|
2939
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 4 hours ago | |
| 1 | 4 weeks ago | |
| 2 | 4 weeks ago | |
| 2 | 05-21-2026 01:51 PM | |
| 1 | 03-12-2026 01:43 PM |