|
POST
|
Actually in production it will be an XY event from a SQL Server business application. There's nothing in the JS API documentation that mentions the type of data source it has to be. It's happening at the service, though, because I can try a query from the REST endpoint and it doesn't work properly there either. I guess I'll have to keep my 'removeDuplicates' function after all.
... View more
08-26-2015
11:49 AM
|
0
|
2
|
2605
|
|
POST
|
Since I want to look at all records, I used query.where = '1=1'. It doesn't make a difference. Generally if there's something very wrong with the query clause it won't execute at all. I got that syntax from another thread. I realize it might be something different, depending on the geodatabase format. This happens to be a file geodatabase. 1=1 should do work, though, no matter the format.
... View more
08-26-2015
11:11 AM
|
0
|
4
|
2605
|
|
POST
|
I have a queryTask based on the URL of my featureLayer. This layer has 508 features in this layer. My maximum record count on my service is much higher than that, to accommodate another layer with more features in it. I'm using AGS 10.2.2 and Advanced Query Support says 'true'. I'm using this queryTask as the source for a dropdown list, so I need to get just the distinct values from my AgencyAcronym field. My queryTask executes, but instead of the 18 distinct values for this field, I'm still getting 508 features returned. I'm having to run these through another function to remove the duplicates and I don't think I should have to do this. I've tried a where clause of '1=1', because I want to check all records, but that doesn't make a difference, I still get all 508 features. I have my queryTask set up as: //populates the pick list searching state facilities by agency
populateBuildingList: function(){
app.buildingAgencyList.length = 0;
var queryTask2 = new QueryTask(app.buildingLayer.url);
var query = new Query();
query.where = "AgencyAcronym is not null";
query.outFields = ["AgencyAcronym"];
query.orderByFields = ["AgencyAcronym"];
query.returnGeometry = false;
query.returnDistinctValues = true;
on(queryTask2, 'error', function(err){
console.log('error populating building list: ' + err.error)
});
queryTask2.execute(query, lang.hitch(this, updateBGridHandler));
function updateBGridHandler(results){
console.log('results of updateBGridHandler :' + results.features.length + " records" ); //all 508 records returned.
arrayUtils.forEach(results.features, function(feature){
var agencyName = feature.attributes.AgencyAcronym;
agencyName = agencyName.replace(/^\s+|\s+$/g,'');
app.buildingAgencyList.push(agencyName);
});
app.buildingAgencyList.sort();
var sortedList = common.sortAndRemoveDuplicates(app.buildingAgencyList); //a function I'm having to use because the values aren't unique
var data = arrayUtils.map(sortedList, function(itm, idx){
return {
"id": idx,
"name": itm,
"value": itm
}
})
var currentMemory = new Memory({
data: data,
idProperty: 'id'
});
app.agencyDropdown.set("store", currentMemory); //a grid created earlier
app.agencyDropdown.sort('name');
}
}
... View more
08-26-2015
09:33 AM
|
0
|
14
|
6419
|
|
POST
|
I finally solved this by waiting until the secured layers were getting loaded. I put a load listener on a featureLayer to create the basemapGallery then. No more errors and switching basemaps works as well. on(app.secureLayer, 'load', function (evt){ var basemapGallery = new BasemapGallery({ showArcGISBasemaps: true, map: app.map }, "basemapGalleryDiv"); basemapGallery.startup(); on(basemapGallery, "error", function(msg){ console.log("basemap gallery error: ", msg.message); }); });
... View more
08-25-2015
11:10 AM
|
0
|
0
|
2097
|
|
POST
|
The initial error seems to come from this ServerInfo definition: var serverInfo = new ServerInfo(); serverInfo.server = pathName; serverInfo.tokenServiceUrl = pathName+"/arcgis/tokens/generateToken"; I'm not sure why I had that in the first place. I commented these lines out and there is no error when I load the map. I'm still getting the error when I try to switch basemaps, though.
... View more
08-25-2015
08:54 AM
|
0
|
1
|
2097
|
|
POST
|
I finally took the plunge a couple weeks ago and decided I really needed to break up my code. I think 'break it into modules' sounds good, but it doesn't really explain how to do it. First of all, you don't have to have break it up into tiny pieces. Just breaking the major functionality of my code into separate files has helped me keep track. So far I am mostly just using my code for functions. First I create a new folder in your project. This one is called extras, although it could be anything as long as you keep track of the name. Then I add this folder to my dojoConfig as an additional package. I've also been using bootstrap-map, so there's an entry for it as well. <script type="text/javascript">
window.dojoConfig = {
async: true,
parseOnLoad:false,
packages: [
{
name: 'bootstrap-map-js',
location: '//esri.github.io/bootstrap-map-js/src/'
},{
name: 'extras',
location: window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/')) + "/extras"
}
]
};
</script> Then in my extras folder, I create my .js files You only need to define the components you're using for this js file as opposed to 'spaghetti' mode where you have a huge list of all modules you need in your code. This particular.js file does one thing, create your map. There are a few syntax difference between having your functions in index.html and their own .js file. 1) Instead of 'require' now that it's in your .js file, you'll using 'define' instead. After the function, you'll see return { createMap: function (mapDiv,pathName) 2) This is another syntax difference, the word 'function' doesn't come first, the name of the function does, followed by a colon, then the word 'function' and whatever arguments you will be passing. define ([
"dojo/dom-construct",
"dojo/on",
"dojo/dom",
"esri/dijit/Popup",
"esri/SpatialReference",
"esri/geometry/Extent",
"esri/layers/FeatureLayer",
"esri/layers/LabelLayer",
"esri/symbols/SimpleMarkerSymbol",
"esri/symbols/SimpleLineSymbol",
"esri/symbols/TextSymbol",
"esri/Color",
"esri/renderers/SimpleRenderer",
'bootstrap-map-js/js/bootstrapmap'
], function (
domConstruct,on,dom,Popup,SpatialReference, Extent,
FeatureLayer, LabelLayer,
SimpleMarkerSymbol, SimpleLineSymbol,TextSymbol,
Color,SimpleRenderer,BootstrapMap) {
return {
createMap: function(mapDiv, pathName){
config = {
countyLayerUrl: pathName + '/arcgis/rest/services/BaseMap/county_simple/MapServer/0'
}
app.spatialReference = new SpatialReference({
wkid: 102100
});
var startExtent = new Extent(-10583000, 4287025, -9979000, 4980462, app.spatialReference);
app.currentExtent = startExtent;
var popup = new Popup({
markerSymbol: new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 22, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255, 255, 0]), 2), new Color([255, 255, 0, 0.5]))
}, domConstruct.create("div"));
var 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]));
var simpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 8, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255, 0, 0]), 2), new Color([255, 0, 0, 0.5]));
var popup = new Popup({
markerSymbol: highlightMarkerSymbol
}, domConstruct.create("div"));
app.map = BootstrapMap.create(mapDiv, {
basemap: "gray",
extent: startExtent,
sliderPosition: 'upper-left',
autoResize: true,
scrollWheelZoom: true,
fitExtent: true,
infoWindow: popup
});
var countyLayer = new FeatureLayer(config.countyLayerUrl, {
id: "countyLayer",
mode: FeatureLayer.MODE_ONDEMAND,
outFields: ["COUNTYNAME"]
});
//label the counties feature layer
var countyColor = new Color("#666");
var countyText = new TextSymbol();
countyText.setColor(countyColor);
countyText.font.setSize("7pt");
var countyLabelRenderer = new SimpleRenderer(countyText);
countyLabelLayer = new LabelLayer({
id: "countyLabels",
maxScale: 1155582
});
countyLabelLayer.addFeatureLayer(countyLayer, countyLabelRenderer, '{COUNTYNAME}');
app.map.addLayers([ countyLayer, countyLabelLayer]);
}
}
}); In my index.html, I've been creating a variable window.app = {}. This is a handy container for defining objects that continue to be available to other modules. Since I know I will need map, spatialReference etc in other parts of my code, I have defined them in myMap.js as app.map and app.spatialReference, where they'll reside in the app variable to be used again. Lastly, you need to require myMap, just like you do any others. Since the createMap function has two arguments, you'll need to pass the pathName and the mapDiv where you want your map to be displayed: <!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Map - Modules</title>
<link rel="stylesheet" href="https://community.esri.com//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="https://community.esri.com//js.arcgis.com/3.13/esri/css/esri.css">
<link rel="stylesheet" type="text/css" href="https://community.esri.com//esri.github.io/bootstrap-map-js/dist/css/bootstrapmap.min.css">
<link rel="stylesheet" href="https://community.esri.com//xsokev.github.io/Dojo-Bootstrap/css/styles.css">
<link rel="stylesheet" href="css/app.css">
</head>
<body>
<script type="text/javascript">
window.dojoConfig = {
async: true,
parseOnLoad:false,
packages: [
{
name: 'bootstrap-map-js',
location: '//esri.github.io/bootstrap-map-js/src/'
},{
name: 'extras',
location: window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/')) + "/extras"
}
]
};
</script>
<script type="text/javascript" src="//js.arcgis.com/3.13compact"></script>
<script type="text/javascript">
require(["dojo/parser","dojo/on","dojo/dom","extras/myMap","dojo/domReady!"
],
function(parser,on,dom,myMap
){
parser.parse();
var pathName = "https://yourservername.gov";
window.app = {}; //the app variable will be persistent throughout your code
myMap.createMap(dom.byId('mapDiv'),pathName);
});
</script>
<div id="mapDiv">
</div>
</body>
</html>
... View more
08-25-2015
08:41 AM
|
1
|
0
|
1895
|
|
POST
|
I'm having a very similar problem. I added a proxyRule for my local secure server, but do I need to add another one for the ESRI base maps? I am getting an initial basemap from my map creation. I'm getting errors when creating a BasemapGallery. The error comes when I first load the page: esri.dijit.BasemapGallery: Unable to find the 'map' property in parameters. I use BasemapGallery in nearly all my maps and I know the syntax is pretty straight forward. I have loaded the Search widget using the exact same syntax for the map parameter and it loads just fine. //basemapgallery widget app.basemapGallery = new BasemapGallery({ showArcGISBasemaps: true, map: app.map }, "basemapGalleryDiv"); app.basemapGallery.startup(); app.basemapGallery.on("error", function(msg){ console.log("basemap gallery error: ", msg.message); }); Even with the error, the thumbnails load OK in my side panel, but when I try to change the basemap I'm getting the error basemap gallery error: esri.dijit.BasemapGallery: could not find group for basemaps. The only difference between this map and others is that I have secured services, so I need the proxy set up and I'm using IdentityManager.
... View more
08-25-2015
07:40 AM
|
0
|
0
|
2097
|
|
POST
|
I switched to a native HTML select as well. I found it to works in more situations than either dojo/ComboBox or FilteringSelect.
... View more
08-25-2015
07:12 AM
|
0
|
0
|
1510
|
|
POST
|
You've replicated my results. I'd say if you include a FeatureLayer in your TOC that's based on a field with an alias, then the output uses the actual field name and not the alias. I could load it as a dynamicmapservicelayer instead, but I want to do things like have an infoTemplate and do selections, which I find easier with a featurelayer.
... View more
08-24-2015
11:45 AM
|
0
|
1
|
2300
|
|
POST
|
It looks OK from the service, which is why I was surprised it wasn't right in the TOC. I am loading Alerts as a featureLayer, but not applying a renderer to it. I suppose I could apply a uniqueValueRenderer to it, but that seems like the long way to go about this. These are all secure layers as well, but that doesn't seem like something that would affect the design of the layer. I'm creating it like this: // ---- populates the Table of contents -------- app.map.on("layers-add-result", function (event) { try { var toc = new TOC({ map: app.map, layerInfos: [{ layer:app.alertLayer, title:"Alerts" }, { layer: buildingLayer, title: "Buildings" },{ layer: staffLayer, title: "ITSD staff" }, { layer:regionLayer, title: 'EUS Regions' }] }, 'tocDiv'); toc.startup(); } catch (e) { console.log(e.message); } });
... View more
08-24-2015
11:15 AM
|
0
|
1
|
2300
|
|
POST
|
In my map it looks like this: And in my TOC it looks like this: I don't care about having the field name shown, if styling it to be hidden is an option. I think I have the most recent version of the TOC. I downloaded it 11/2014. When I inspect the element, It falls underneath the agsjsTOCRootLayerLabel (Alerts) I don't know if I can take advantage of teh data-dojo-attach-point or not. It doesn't seem to have any class that I can maniplate.
... View more
08-24-2015
09:30 AM
|
0
|
4
|
2300
|
|
POST
|
I have a layer that uses a field name AlertStatusCode that appears in the TOC this way, even after I have this field an alias of 'Alert Status'. I assumed the widget would look for a field alias and use it instead of the actual field name if it found one. Does anyone have experience with this? Changing the field name in the data is not an option.
... View more
08-24-2015
08:57 AM
|
0
|
8
|
4739
|
|
POST
|
How are you selecting the featureLayer? Have you tried putting in a error handler to get a little more information?
... View more
08-24-2015
08:38 AM
|
0
|
0
|
1304
|
|
POST
|
I add a few more things into my project. Besides IdentityManager, it works best for me to use "esri/urlUtils", and "esri/ServerInfo" as well. var pathName = "myServer.mo.gov" //the path to myserver. urlUtils.addProxyRule({ urlPrefix: pathName proxyUrl: "../../proxy/proxy.ashx" //this is the path to where my proxy config file is located }); var serverInfo = new ServerInfo(); serverInfo.server = pathName serverInfo.tokenServiceUrl = pathName+"/arcgis/tokens/generateToken"; Lastly, if you are trying to run this as localhost (http://127.0.0.1:8000) I've never had that work. It only works for me when I have a fully qualified domain as URL.
... View more
08-24-2015
08:29 AM
|
0
|
1
|
2126
|
|
POST
|
I think both are helpful. I'm not sure whether one methodology is more efficient or faster than the other. It seem like you a few extra lines if you put it in as a module. On the other hand, it ends up getting called the same as the other modules in my js folder, so I'm less likely to lose track of how I'm calling it.
... View more
08-21-2015
09:49 AM
|
0
|
0
|
1339
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-02-2017 02:38 PM | |
| 2 | 03-18-2022 10:14 AM | |
| 2 | 02-18-2016 06:28 AM | |
| 1 | 03-18-2024 07:29 AM | |
| 4 | 08-02-2023 06:08 AM |
| Online Status |
Offline
|
| Date Last Visited |
02-25-2025
01:56 PM
|