|
POST
|
I'm setting the map extent to a dynamic layer once it's loaded using the following code. layerDynamic.on("load", function () { var deferred = new Deferred(); deferred = map.setExtent(layerDynamic.initialExtent, true); deferred.then(function () { console.log("map xmin: " + map.extent.xmin + ", ymin: " + map.extent.ymin + ", xmax: " + map.extent.xmax + ", ymax: " + map.extent.ymax) console.log("layer xmin: " + layerDynamic.initialExtent.xmin + ", ymin: " + layerDynamic.initialExtent.ymin + ", xmax: " + layerDynamic.initialExtent.xmax + ", ymax: " + layerDynamic.initialExtent.ymax) }); }); However, this doesn't always work. When I refresh the page, it often zooms out way too far. This is what the extents usually are when it doesn't zoom correctly map xmin: -27374674.768619433, ymin: -2290122.0955929635, xmax: -6828401.565569537, ymax: 6241473.253482993 layer xmin: -14166895.9892999, ymin: 5762234.783315, xmax: -13598348.0746001, ymax: 6211946.863385 Why doesn't that code work upon a refresh?
... View more
07-30-2013
01:15 PM
|
0
|
4
|
2225
|
|
POST
|
What I was suggesting is to try this with a test service that isn't secured. If that works correctly, then there may be a bug when working with secured services. For example, this code works as expected. Try substituting your service in to see what happens.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<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>TOC</title>
<link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.4/js/dojo/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.4/js/esri/css/esri.css">
<style>
html, body
{
height: 100%;
width: 100%;
margin: 0;
padding: 0px;
font-family: helvetica, arial, sans-serif;
font-size: 90%;
}
#leftPane
{
width: 280px;
overflow: auto;
}
/* this line hide layers when out of scale for the inline TOC */
#scaleDiv .agsTOCOutOfScale
{
display: none;
}
</style>
<script type="text/javascript">
var djConfig = {
parseOnLoad: true,
packages: [{
"name": "agsjs",
"location": location.pathname.replace(/\/[^/]+$/, "") + '/agsjs'
//"location": 'http://gmaps-utility-gis.googlecode.com/svn/tags/agsjs/2.05/xbuild/agsjs' // for xdomain load
}]
};
</script>
<script src="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/"></script>
<script type="text/javascript">
var map;
var identifyTask, identifyParams;
var urlSEFCRI = "http://egisws02.nos.noaa.gov/ArcGIS/rest/services/biogeo/SEFCRI/MapServer";
var layerDynamic;
var oldLayerName;
var clickGraphicLayer;
var visibleLayers;
var initialExtent;
require([
"dojo/_base/connect",
"dojo/_base/array",
"dojo/parser",
"dojo/ready",
"dojo/Deferred",
"dojo/dom",
"dojo/domReady",
"dijit/layout/ContentPane",
"dijit/layout/TabContainer",
"dijit/registry",
"dijit/Dialog",
"esri/map",
"esri/InfoTemplate",
"esri/dijit/Basemap",
"esri/dijit/BasemapGallery",
"esri/dijit/BasemapLayer",
"esri/dijit/InfoWindow",
"agsjs/dijit/TOC",
"esri/arcgis/utils",
"dijit/Menu",
"dijit/form/DropDownButton",
"dijit/layout/BorderContainer",
"dojo/domReady!"
], function (
connect, array, parser, ready, Deferred, dom, domReady,
ContentPane, TabContainer, registry, Dialog,
Map, InfoTemplate,
Basemap, BasemapGallery, BasemapLayer, InfoWindow) {
ready(function () {
//parser.parse();
});
map = new Map("map", {
basemap: "oceans",
showAttribution: false,
logo: false,
center: [-80.2, 26.67],
zoom: 11
});
map.resize();
layerDynamic = new esri.layers.ArcGISDynamicMapServiceLayer(urlSEFCRI, {
id: 'Dynamic'
});
map.addLayers([layerDynamic]);
layerDynamic.setVisibleLayers([0]);
map.on("layers-add-result", function (event) {
console.log("layers-add-result");
try {
var toc = new agsjs.dijit.TOC({
map: map,
layerInfos: [{
layer: layerDynamic,
title: "Legend",
slider: true
}]
}, 'tocDiv');
toc.startup();
}
catch (e) {
console.log(e.message);
}
mapReady(map);
});
layerDynamic.on("load", function () {
var deferred = new Deferred();
deferred = map.setExtent(layerDynamic.initialExtent, true);
deferred.then(function () {
console.log("Extent set");
initialExtent = map.extent;
});
});
var resizeTimer;
map.on("load", function (theMap) {
connect.connect(dijit.byId('map'), 'resize', function () { //resize the map if the div is resized
clearTimeout(resizeTimer);
resizeTimer = setTimeout(function () {
map.resize();
map.reposition();
}, 500);
});
});
function mapReady(map) {
console.log("MapReady");
map.on("click", executeIdentifyTask);
identifyTask = new esri.tasks.IdentifyTask(urlSEFCRI);
identifyParams = new esri.tasks.IdentifyParameters();
identifyParams.tolerance = 3;
identifyParams.returnGeometry = true;
//identifyParams.layerIds = [0, 117];
identifyParams.layerIds = layerDynamic.visibleLayers;
identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL;
identifyParams.width = map.width;
identifyParams.height = map.height;
map.infoWindow.resize(415, 200);
map.infoWindow.setTitle("Results");
}
function executeIdentifyTask(evt) {
map.graphics.clear();
identifyParams.geometry = evt.mapPoint;
identifyParams.mapExtent = map.extent;
identifyParams.layerIds = layerDynamic.visibleLayers;
oldLayerName = "";
var deferred = identifyTask.execute(identifyParams);
deferred.addCallback(function (response) {
return dojo.map(response, function (result) {
var feature = result.feature;
var infoTemplate = new esri.InfoTemplate("test", "${*}");
var contentString = "";
var sp = new Array();
var sp = feature.attributes;
contentString += "<b>" + result.layerName + "</b><hr width = '90%'>";
for (x in sp) {
if (x != "OBJECTID" && x != "Shape") {
contentString += "<i>" + x + "</i>: " + feature.attributes + "<br/>";
}
}
var infoTemplate = new esri.InfoTemplate();
infoTemplate.setTitle("Results");
infoTemplate.setContent(contentString);
var data = {
identifier: "OBJECTID",
label: "ID",
items: sp
};
feature.setInfoTemplate(infoTemplate);
return feature;
});
});
map.infoWindow.setFeatures([deferred]);
map.infoWindow.show(evt.mapPoint);
}
});
</script>
</head>
<body class="claro">
<div id="content" dojotype="dijit.layout.BorderContainer" design="headline" gutters="true" style="width: 100%; height: 100%; margin: 0;">
<div dojotype="dijit.layout.ContentPane" id="leftPane" region="left" splitter="true">
<div id="tocDiv">
</div>
</div>
<div id="map" dojotype="dijit.layout.ContentPane" region="center">
</div>
</div>
</body>
</html>
... View more
07-30-2013
11:16 AM
|
0
|
0
|
360
|
|
POST
|
What's the code for initializing the TOC widget? Also, please put your code inside the CODE tags. You can do this by clicking on the # tool above.
... View more
07-30-2013
11:13 AM
|
0
|
0
|
1244
|
|
POST
|
Have you tried a case that doesn't use a secured service?
... View more
07-30-2013
11:08 AM
|
0
|
0
|
2267
|
|
POST
|
Can you post your full code or make a Fiddle that shows the problem?
... View more
07-30-2013
09:32 AM
|
0
|
0
|
2267
|
|
POST
|
function mapReady(map) {
dojo.connect(map, "onClick", executeIdentifyTask);
//create identify tasks and setup parameters
identifyTask = new esri.tasks.IdentifyTask("http://maps101.gis.halff.com/ladon/rest/services/Lubbock/LubbockCCTVAssets/MapServer/");
identifyParams = new esri.tasks.IdentifyParameters();
identifyParams.tolerance = 3;
identifyParams.returnGeometry = true;
identifyParams.layerIds = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17];
identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL;
identifyParams.width = map.width;
identifyParams.height = map.height;
}
You can set the layerIds property to the visible layers (setting this property any time you change the visibility of one of the layers) or you can leave that property off and set the layerOption property to esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE
... View more
07-30-2013
09:11 AM
|
0
|
0
|
2267
|
|
POST
|
What are the parameters you're setting for the IdentifyTask? This should return just the visible layers
identifyTask = new esri.tasks.IdentifyTask(yourUrl);
identifyParams = new esri.tasks.IdentifyParameters();
identifyParams.tolerance = 3;
identifyParams.returnGeometry = true;
identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE;
identifyParams.width = map.width;
identifyParams.height = map.height;
... View more
07-30-2013
07:55 AM
|
0
|
0
|
2267
|
|
POST
|
Great update, Nianwei! I really like the widget and am quite thankful that you took the time to create it.
... View more
07-26-2013
11:13 AM
|
0
|
0
|
4399
|
|
POST
|
You can use this syntax
Function FindLabel ( [HOUSE], [NUMBER] )
if IsNumeric( [HOUSE] ) then
Findlabel = [HOUSE] & [NUMBER]
else
FindLabel = [NUMBER] & [HOUSE]
end if
End Function
... View more
07-26-2013
07:17 AM
|
0
|
0
|
1659
|
|
POST
|
In a Fiddle, you have to use this as the TOC location
<script>
var dojoConfig = {
parseOnLoad: true,
packages: [{
"name": "agsjs",
//"location": location.pathname.replace(/\/[^/]+$/, "") + '/agsjs'
"location": 'http://gmaps-utility-gis.googlecode.com/svn/tags/agsjs/2.04/xbuild/agsjs' // for xdomain load
}]
};
</script>
... View more
07-25-2013
10:43 AM
|
0
|
0
|
465
|
|
POST
|
I was asked to add an html header to my Flex application. However, I'm running into an issue of trying to set the height of the body where the swf file resides. The standard html template contains this css information <style type="text/css" media="screen">
html, body { height:100%; }
body { margin:0; padding:0; overflow:auto; text-align:center;
background-color: ${bgcolor}; }
object:focus { outline:none; }
#flashContent { display:none; }
</style> If I add in another div with the header content above "flashContent", then I'll get a scroll bar on the side and the swf isn't fitted into the remaining space in the browser. Our IT department suggested making this change to the css file, changing the height and overflow properties <style type="text/css" media="screen">
html, body { height:97%; width:100% }
body { margin:0; padding:0; overflow:none; text-align:center;
background-color: #ffffff; }
object:focus { outline:none; }
#flashContent { display:none; }
</style> and adding additional css styles using an external css file. However, as seen here for one of their sites, it doesn't quite work. If the browser height is reduced, the scale bar and the lat/long/scale information falls off the bottom of the screen. How can I do this properly?
... View more
07-25-2013
10:16 AM
|
0
|
0
|
755
|
|
POST
|
Take a look at this sample on how to draw something on the map display.
... View more
07-24-2013
12:10 PM
|
0
|
0
|
903
|
|
POST
|
Betsy, I'm using an infoWindow with a TabContainer to show the results of an IdentifyTask, but I've never run into an issue where clicking on a location with no data in a visible layer will return a tab with no results. That's shown in this Fiddle.
... View more
07-24-2013
10:04 AM
|
0
|
0
|
1172
|
|
POST
|
Glad to help. We all start as beginners! Don't forget to click the check to mark the thread answered (and the up arrow to mark it as helpful).
... View more
07-24-2013
07:20 AM
|
0
|
0
|
1013
|
|
POST
|
There are two videos available from the recent Developers Summit of the technical sessions. .NET Add-ins for ArcGIS for Desktop Developing .NET Applications for ArcGIS Engine
... View more
07-24-2013
07:18 AM
|
0
|
0
|
986
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-04-2025 06:39 AM | |
| 1 | 05-01-2026 08:26 AM | |
| 1 | 04-10-2026 12:01 PM | |
| 1 | 04-13-2026 09:11 AM | |
| 1 | 10-11-2023 06:18 AM |
| Online Status |
Offline
|
| Date Last Visited |
Tuesday
|