POST
|
Jason, I appreciate your help on this...but that didn't quite do it. When I add this: var statisticDefinition = new StatisticDefinition();
statisticDefinition.statisticType = "count";
statisticDefinition.onStatisticField = "Name";
statisticDefinition.outStatisticFieldName = "total";
query.outStatistics = [statisticDefinition]; it pretty much kills the table. I added the require at the beginning. Sorry to trouble you on this...I'm still learning. thanks,
... View more
09-10-2013
07:33 AM
|
0
|
0
|
426
|
POST
|
Make use of query.outStatistics. Here is a sample. In order to use this feature, the layer or the table has to Support Statistics when published. require([
"esri/tasks/Query", "esri/tasks/StatisticDefinition", ...
], function(Query, StatisticDefinition, ... ) {
var query = new Query();
var statisticDefinition = new StatisticDefinition();
statisticDefinition.statisticType = "count";
statisticDefinition.onStatisticField = "Name";
statisticDefinition.outStatisticFieldName = "Total";
query.outStatistics = [statisticDefinition];
...
}); This seems to be what i am looking for. I am not much of a programmer...would you be able to help me out with the code for this or point me in the direction as to where this would go in the code.? Thanks in advance.
... View more
09-10-2013
06:07 AM
|
0
|
0
|
426
|
POST
|
I am working with the example 'Query with Feature Layer' and I am trying to get some totals from the table. <!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, IE=10">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<title>Page through records</title>
<style>
html, body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
body {
overflow: hidden;
overflow: hidden;
font-family: "Roboto Condensed", sans-serif;
font-size: 0.90em;
margin: 0 auto;
width: 750px;
}
#grid {
height: 336px;
width: 100%;
}
.field-name {
width: 200px;
font-size: .80em;
font-weight: normal;
}
.field-magnitude {
width: 50px;
font-size: .80em;
font-weight: normal;
}
.field-deaths {
width: 70px;
font-size: .80em;
font-weight: normal;
}
.field-date {
width: 70px;
font-size: .80em;
font-weight: normal;
}
#grid .dgrid-row-odd {
background: #F2F5F9;
}
</style>
<script src="http://js.arcgis.com/3.6/">
</script>
<script>
var featureLayer, pageInfo, grid;
require([
"esri/layers/FeatureLayer", "esri/tasks/query", "esri/TimeExtent",
"dojo/number", "dojo/date/locale", "dojo/dom","dojo/on",
"dojo/_base/array", "dojo/store/Memory",
"dgrid/OnDemandGrid", "dojo/domReady!"
], function(
FeatureLayer, Query, TimeExtent,
number, locale, dom, on,
arrayUtils, Memory,
OnDemandGrid
) {
// create a dgrid
var sortAttr = [{
attribute: "magnitude",
descending: true
}];
grid = new OnDemandGrid({
store: Memory({
idProperty: "name"
}),
columns:{
name: "Name",
magnitude: {
label: "Magnitude",
formatter: formatRound
},
deaths: "Deaths",
date:{
label: "Date",
formatter: formatDate
}
},
sort: sortAttr
}, "grid");
// create a feature layer
featureLayer = new FeatureLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/Since_1970/MapServer/0", {
outFields:["*"]
});
// get object IDs from the table (feature layer)
featureLayer.on("load", function () {
// create the query to fetch object IDs for earthquakes that have a magnitude greater than 6.0
// that occurred after January 1st 2007
var query = new Query();
query.where = "Magnitude > 6.0 AND Num_Deaths >= 1";
query.timeExtent = new TimeExtent(new Date("01/01/2007 UTC"));
featureLayer.queryIds(query, function (objectIds) {
fetchRecords(objectIds);
});
});
// click listeners for prev/next page buttons
on(dom.byId("prev"), "click", function() {
queryRecordsByPage(pageInfo.currentPage - 1);
});
on(dom.byId("next"), "click", function() {
queryRecordsByPage(pageInfo.currentPage + 1);
});
// formatting function for numbers
function formatRound(value) {
return number.round(value, 2);
}
// formatting function for dates
function formatDate(value) {
var inputDate = new Date(value);
return locale.format(inputDate, {
selector: "date",
datePattern: "MMMM d, y"
});
}
function fetchRecords(objectIds) {
if (objectIds.length > 0) {
updatePageInformation(objectIds);
queryRecordsByPage(1);
} else {
grid.showMessage("No matching records");
grid.setStore(null);
}
}
function updatePageInformation(objectIds, page) {
pageInfo = {
objectIds: objectIds,
totalRecords: objectIds.length,
totalPages: Math.ceil(objectIds.length / 15),
currentPage: page || 0,
recordsPerPage: 15
};
dom.byId("pageInfo").innerHTML = pageInfo.currentPage + "/" + pageInfo.totalPages;
dom.byId("recordsInfo").innerHTML = pageInfo.totalRecords;
if (pageInfo.currentPage > pageInfo.totalPages) {
queryRecordsByPage(pageInfo.currentPage - 1);
}
}
function queryRecordsByPage(pageNumber) {
// check if the page number is valid
if (pageNumber < 1 || pageNumber > pageInfo.totalPages) {
return;
}
//grid.showMessage("Fetching records...");
var begin = pageInfo.recordsPerPage * (pageNumber - 1);
var end = begin + pageInfo.recordsPerPage;
// create the query
var query = new Query();
query.objectIds = pageInfo.objectIds.slice(begin, end);
query.outFields = ["*"];
// Query for the records with the given object IDs and populate the grid
featureLayer.queryFeatures(query, function (featureSet) {
updateGrid(featureSet, pageNumber);
});
}
function updateGrid(featureSet, pageNumber) {
var data = arrayUtils.map(featureSet.features, function (entry, i) {
return {
name: entry.attributes.Name,
magnitude: entry.attributes.Magnitude,
deaths: entry.attributes.Num_Deaths,
date: entry.attributes.Date_
};
});
grid.store.setData(data);
grid.refresh();
// update application state
pageInfo.currentPage = pageNumber;
dom.byId("pageInfo").innerHTML = pageInfo.currentPage + "/" + pageInfo.totalPages;
}
});
</script>
</head>
<body>
<p>
Total records:
<span id="recordsInfo">0</span>
|
<button id="prev">Prev Page</button>
<span id="pageInfo"></span>
<button id="next">Next Page</button>
</p>
<!-- dgrid will be created in this div -->
<div id="grid"></div>
</body>
</html> If I understand the code correctly, this section gives the total number or records at the top of the table: function updatePageInformation(objectIds, page) {
pageInfo = {
objectIds: objectIds,
totalRecords: objectIds.length,
totalPages: Math.ceil(objectIds.length / 15),
currentPage: page || 0,
recordsPerPage: 15
};
dom.byId("pageInfo").innerHTML = pageInfo.currentPage + "/" + pageInfo.totalPages;
dom.byId("recordsInfo").innerHTML = pageInfo.totalRecords; The example gives a table with earthquake name and Magnitute. At the top it list the total records: 29. Now this is where I need some help. What would I need to add to the code to illustrate a list of how many of each there are. I need a summary on the name. Example: JAPAN: HONSHU: W COAST : 2 KYRGYZSTAN: NURA: 1 HONDURAS : 1 ...etc. Does this make sense? Any help is much appreciated.
... View more
09-09-2013
10:28 AM
|
0
|
5
|
2581
|
POST
|
I am using a template with An ArcGIS rest service. The layer that I want to use says 'Has Labels: true' Now I want the label to show up in my ESRI JSapi web application. the Template I am using has the following code
operationalLayers: [{
type: "feature",
url: "http://.....6080/arcgis/rest/services/........../MapServer/5",
title: "Tanks - Scada Sites",
options: {
id: "tanks",
opacity: 1.0,
visible: true,
outFields: ["*"],
infoTemplate: new InfoTemplate("tank name", "${*}"),
mode: 0
}, My question is....Is there an option that I need to add that makes the labels appear...because they are not on. Does this make sense? Thanks in Advance. is it possible with the code provided above, to add the labels that are at my rest service layer? Maybe I'm not describing this correctly. I just want the labels to appear. Thanks,
... View more
08-12-2013
09:00 AM
|
0
|
0
|
286
|
POST
|
OK....then where or how do I add the labels for this layer?
... View more
08-09-2013
07:04 AM
|
0
|
0
|
286
|
POST
|
I am using a template with An ArcGIS rest service. The layer that I want to use says 'Has Labels: true' Now I want the label to show up in my ESRI JSapi web application. the Template I am using has the following code
operationalLayers: [{
type: "feature",
url: "http://.....6080/arcgis/rest/services/........../MapServer/5",
title: "Tanks - Scada Sites",
options: {
id: "tanks",
opacity: 1.0,
visible: true,
outFields: ["*"],
infoTemplate: new InfoTemplate("tank name", "${*}"),
mode: 0
}, My question is....Is there an option that I need to add that makes the labels appear...because they are not on. Does this make sense? Thanks in Advance.
... View more
08-09-2013
06:20 AM
|
0
|
4
|
484
|
POST
|
I am having problems with the full extent button...it doesn't work. Here is a snippet of my code: var popup = new esri.dijit.Popup(null, dojo.create("div"));
map = new esri.Map("map",{
basemap: "topo",//{"opacity":0.5},//streets | satellite | hybrid | topo | gray | oceans | national-geographic | osm
center: [-98.10467, 38.28937], //long, lat
zoom: 8,
slider: true,
infoWindow: popup,
//showInfoWindowOnClick: false
sliderStyle: 'small',
wrapAround180: !configOptions.constrainmapextent,
showAttribution: true,
//set wraparound to false if the extent is limited.
logo: !configOptions.customlogo.image //hide esri logo if custom logo is provided
});
//Add Zoom Toolbar
navToolbar = new esri.toolbars.Navigation(map);
navToolbar.zoomToFullExtent = function () {
var map = this.map;
map.setExtent(map);
} Any suggestions? Bill
... View more
02-07-2013
06:04 AM
|
0
|
0
|
687
|
POST
|
I have this for my legend function: function addLayerList(layers) {
var layerList = [];
dojo.forEach(layers, function(layer){
if(layer.layerInfos){
dojo.forEach(layer.layerInfos, function(info,index){
info.id = layer.id;
info.subId = index;
layerList.push(info);
})
}else{
layerList.push(layer);
}
});
if (layerList.length > 0) {
//create a menu of layers
layerList.reverse();
var menu = new dijit.Menu({
id: 'layerMenu'
});
dojo.forEach(layerList, function (layer) {
menu.addChild(new dijit.CheckedMenuItem({
label: layer.name || layer.title,
checked: layer.visible,
onChange: function (e) {
if (layer && layer.declaredClass === 'esri.layers.LayerInfo') {
var l = map.getLayer(layer.id);
var ids = []
if(e){
ids.push(layer.subId)
}else{
ids.push(-1);
}
l.setVisibleLayers(ids);
} else if (layer.type === 'Feature Layer'){
layer.setVisibility(!layer.visible);
}
}
}));
});
var button = new dijit.form.DropDownButton({
label: i18n.tools.layers.label,
id: "layerBtn",
iconClass: "esriLayerIcon",
title: i18n.tools.layers.title,
dropDown: menu
});
dojo.byId('webmap-toolbar-center').appendChild(button.domNode);
} Is there a way to specify which on the my services are visible and which are not by using there ID Numbers? Any help is much appreciated. Bill
... View more
01-28-2013
09:35 AM
|
0
|
1
|
2126
|
POST
|
Is it possible to add this toolbar to the Basic Javascript viewer: http://help.arcgis.com/en/webapi/javascript/arcgis/samples/toolbar_navigation/index.html if so, does it go in the layout.js file? Thanks, BIll With a little work I think I got it to work. I added this style code to the basicviewer.html file at the top: <style>
.zoominIcon { background-image:url(images/nav_zoomin.png); width:16px; height:16px; }
.zoomoutIcon { background-image:url(images/nav_zoomout.png); width:16px; height:16px; }
.zoomfullextIcon { background-image:url(images/nav_fullextent.png); width:16px; height:16px; }
.zoomprevIcon { background-image:url(images/nav_previous.png); width:16px; height:16px; }
.zoomnextIcon { background-image:url(images/nav_next.png); width:16px; height:16px; }
.panIcon { background-image:url(images/nav_pan.png); width:16px; height:16px; }
.deactivateIcon { background-image:url(images/nav_decline.png); width:16px; height:16px; }
</style> then added the the navToolbar Id the correct div on the bottom: <div id="webmap-toolbar-center"></div>
<div id="navToolbar" data-dojo-type="dijit.Toolbar">
<div data-dojo-type="dijit.form.Button" id="zoomin" data-dojo-props="iconClass:'zoominIcon', onClick:function(){navToolbar.activate(esri.toolbars.Navigation.ZOOM_IN);}">Zoom In</div>
<div data-dojo-type="dijit.form.Button" id="zoomout" data-dojo-props="iconClass:'zoomoutIcon', onClick:function(){navToolbar.activate(esri.toolbars.Navigation.ZOOM_OUT);}">Zoom Out</div>
<div data-dojo-type="dijit.form.Button" id="zoomfullext" data-dojo-props="iconClass:'zoomfullextIcon', onClick:function(){navToolbar.zoomToFullExtent();}">Full Extent</div>
<div data-dojo-type="dijit.form.Button" id="zoomprev" data-dojo-props="iconClass:'zoomprevIcon', onClick:function(){navToolbar.zoomToPrevExtent();}">Prev Extent</div>
<div data-dojo-type="dijit.form.Button" id="zoomnext" data-dojo-props="iconClass:'zoomnextIcon', onClick:function(){navToolbar.zoomToNextExtent();}">Next Extent</div>
<div data-dojo-type="dijit.form.Button" id="pan" data-dojo-props="iconClass:'panIcon', onClick:function(){navToolbar.activate(esri.toolbars.Navigation.PAN);}">Pan</div>
<div data-dojo-type="dijit.form.Button" id="deactivate" data-dojo-props="iconClass:'deactivateIcon' ,onClick:function(){navToolbar.deactivate();}">Deactivate</div>
<!--Basemap,measure,share,time and layer list tools added if enabled-->
</div>
</div> Next in the layout.js file I added the dogo.requires that are needed to create it dojo.require("esri.toolbars.navigation");
dojo.require("dijit.form.Button");
dojo.require("dijit.Toolbar"); then I added the function ( I think that's what its called: navToolbar = new esri.toolbars.Navigation(map);
navToolbar.zoomToFullExtent = function () {
var map = this.map;
map.setExtent(initialExtent);
} I think that's it and I got it load on the top bar next to the legend.
... View more
01-25-2013
08:49 AM
|
0
|
0
|
687
|
POST
|
Is it possible to add this toolbar to the Basic Javascript viewer: http://help.arcgis.com/en/webapi/javascript/arcgis/samples/toolbar_navigation/index.html if so, does it go in the layout.js file? Thanks, BIll
... View more
01-22-2013
09:05 AM
|
0
|
0
|
687
|
POST
|
Matt that's great! Thank you! I downloaded the file, and placed it in my javascript folder in my Basic Viewer template project site. I then added the following to my index.html file:
<script type="text/javascript" src="javascript/WURadarLayer.js"></script>
I saved this file as a plain file with a .js extension and didn't modify it. I signed up for an API key (###) which I then put in where you showed us in the ReadMe. I put the following line in layout.js at the top ....
require([
"dojo/ready",
"dojo/_base/connect",
"modules/WURadarLayer"
]);
(I guess this new Dojo syntax is a bit different from the past, with things like dojo.require("esri.dijit.Popup"); ) I then put .....
var wuradar = new WURadarLayer('#####');
into my list of layers and put it in my layer loading list...
map.addLayers([wuradar, more layers...)
But I got an error "0x800a1391 - JavaScript runtime error: 'WURadarLayer' is undefined" from Vis Studio / IE. So did I declare right? I am just beginning at Javascript thank you for any help. This was exactly what I was looking for, a radar loop! Thanks to you both! And, does anyone know of an example using the standard RIDGE Radar? http://atlas.resources.ca.gov/ArcGIS/rest/services/Atmosphere_Climate/RIDGE_Precip_Radar/MapServer That may also be helpful as the Wunderground API limits the amount of use. I think I had the same error and the problem I found was that the .js file was in the wrong place and it could be read. I was using firebug to check the error.
... View more
01-18-2013
07:43 AM
|
0
|
0
|
763
|
POST
|
Thank you so much Steve! I set it up using IIS7 and voila, it is working! You are my hero! Thank you!!! No Jeff, it does not work when I run from Aptana. I agree with Steve that this needs more documentation. Ionara, you are not alone. They need to update the tutorials for the javascript API to make it more user friendly for the GIS non-programmers like myself. I'm learning, but my spatially adjusted non-programming mind is having a hard time trying to figure this out.
... View more
01-17-2013
07:28 AM
|
0
|
0
|
517
|
POST
|
Are you looking for Radar? I found something on GitHub and modified it a litte and converted to AMD. http://driskull.github.com/esri-weatherunderground/ https://github.com/driskull/esri-weatherunderground Originally came from this: https://github.com/brandoncopeland/esri-weatherunderground This is just a simple example and could be expanded. I believe there's other API's that can do radar motion as well. OK, if I understand this correctly I will need an api key from http://www.wunderground.com correct to get this to work correctly?
... View more
01-16-2013
07:02 AM
|
0
|
0
|
763
|
POST
|
Flex has a nice weather layer that can be added to a viewer to show the latest weather in Motion. Is there one available for the javascript API? Thanks,
... View more
01-15-2013
11:34 AM
|
0
|
8
|
3663
|
POST
|
I've attached a simplified version of the basic viewer that doesn't use an arcgis.com web map. Note that you'll have to add back in popups for layers and if your layers are editable or time-aware you'd have to add logic in to handle that functionality too. Take a look at the createMap function to see how the template was modified. Kelly, Where do you add in the popup info and where is the 'createMap function'? Thanks,
... View more
12-19-2012
09:30 AM
|
0
|
0
|
508
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|