|
POST
|
Your polygon coordinates appear to be in geographic/WGS84 but your wkid is for Web Mercator. Change your spatialReference.wkid to 4326 (the wkid for WGS84) and it works:
<!doctype html>
<html lang="en">
<head>
<meta 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></title>
<link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.2/js/dojo/dijit/themes/tundra/tundra.css">
<link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.2/js/esri/css/esri.css">
<style>
html, body { height: 100%; width: 100%; margin: 0; padding: 0; }
#map{ margin: 0; padding: 0; }
</style>
<script>var dojoConfig = { parseOnLoad: true };</script>
<script src="http://serverapi.arcgisonline.com/jsapi/arcgis/3.2/"></script>
<script>
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("esri.map");
var map;
function init() {
var ext = new esri.geometry.Extent({"xmin":-17878954,"ymin":-2368856,"xmax":11003235,"ymax":12170078,"spatialReference":{"wkid":102100}});
map = new esri.Map("map",{ extent: ext, wrapAround180: true });
var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer");
map.addLayer(basemap);
// polygon JSON
// coordinates are in wgs84 so wkid should be 4326, not 102100
var geom = {"rings": [[[-73.7104093,40.54816076],[-73.7519722,40.5871111],[-73.7601326,40.61371559],[-73.7615556,40.8149722],[-73.7562433,40.8320452],[-73.7265199,40.86482226],[-73.6309606,40.8962101],[-73.5906812,40.90843197],[-73.5679025,40.91454289],[-73.3965069,40.9539866],[-71.9822949,41.2742658],[-71.85812147,41.07093545],[-71.85784367,41.0701021],[-71.8675662,41.0606577],[-71.8772889,41.05565774],[-71.91034587,41.04371326],[-72.044796,40.99537948],[-72.39814118,40.8689892],[-72.4800884,40.8420448],[-72.5287016,40.8267668],[-73.0403879,40.6720437],[-73.04316579,40.67121038],[-73.0576108,40.66732155],[-73.1362248,40.6473219],[-73.20219949,40.6340722],[-73.7104093,40.54816076],[-73.7104093,40.54816076]]],"spatialReference": {"wkid": 4326} };
console.log("geom is: ", geom);
dojo.connect(map, "onLoad", function() {
dojo.connect(dijit.byId("map"), "resize", map, map.resize);
// create a polygon object from JSON
var wgs84 = new esri.geometry.Polygon(geom);
// convert wgs84 polygon to web mercator
var webMercator = esri.geometry.geographicToWebMercator(wgs84);
// create a graphic
var graphic = new esri.Graphic(webMercator, new esri.symbol.SimpleFillSymbol());
// add it to the map
map.graphics.add(graphic);
// zoom to the graphic
map.setExtent(esri.graphicsExtent(map.graphics.graphics), true);
console.log("added and zoomed to polygon");
});
}
dojo.ready(init);
</script>
</head>
<body class="tundra">
<div data-dojo-type="dijit.layout.BorderContainer"
data-dojo-props="design:'headline',gutters:false"
style="width: 100%; height: 100%; margin: 0;">
<div id="map"
data-dojo-type="dijit.layout.ContentPane"
data-dojo-props="region:'center'">
</div>
</div>
</body>
</html>
On jsfiddle: http://jsfiddle.net/taf8Q/
... View more
10-11-2012
08:29 AM
|
1
|
1
|
2056
|
|
POST
|
I don't see a good reason for doing what you're doing in your class but hey, everybody's got their reasons. On line 21, you reference agsid when you're building this.URL. This should be ags_id as that's what you use at the top of your constructor. Here's a working example: define(["dojo/_base/declare", "esri/layers/FeatureLayer", "esri/layers/agstiled", "esri/layers/dynamic"], function (declare, FeatureLayer, TiledLayer, DynamicLayer) { return declare([], { id: null, agsid: null, URL: null, layertype: null, maplayer: null, constructor: function (lyr) { this.id = lyr.Layer_ID; this.ags_id = lyr.AGS_ID; this.layertype = lyr.LayerType; switch (this.layertype) { case "featurelayer": this.URL = lyr.Service_URL + "/FeatureServer/" + this.ags_id; // was previously agsid ... missing underscore this.maplayer = new esri.layers.FeatureLayer(this.URL, { mode: esri.layers.FeatureLayer.MODE_ONDEMAND, outFields: ["*"] }); break; case "tiled": this.URL = lyr.Service_URL + "/MapServer" + ((this.agsid) ? ("/" + this.agsid) : ("")); this.maplayer = new TiledLayer(this.URL); break; case "dynamic": this.URL = lyr.Service_URL + "/MapServer" + ((this.agsid) ? ("/" + this.agsid) : ("")); this.maplayer = new DynamicLayer(this.URL); //this.maplayer = new esri.layers.ArcGISDynamicMapServiceLayer(this.URL); break; default: this.URL = lyr.Service_URL + "/MapServer" + ((this.agsid) ? ("/" + this.agsid) : ("")); this.maplayer = new DynamicLayer(this.URL); //this.maplayer = new esri.layers.ArcGISDynamicMapServiceLayer(this.URL); break; } } }); }); And the page that uses the class: <!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" /> <!--The viewport meta tag is used to improve the presentation and behavior of the samples on iOS devices--> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"> <title></title> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.2/js/esri/css/esri.css" /> <style> html, body { height: 100%; width: 100%; margin: 0; padding: 0; } .esriScalebar{ padding: 20px 20px; } #map{ padding:0; } </style> <script> var dojoConfig = { packages: [{ "name": "extras", "location": location.pathname.replace(/\/[^/]+$/, '') + "" }] }; </script> <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/3.2compact"></script> <script type="text/javascript"> var map; require([ "dojo/parser", "dijit/layout/BorderContainer", "dijit/layout/ContentPane", "esri/map", "extras/LayerWrapper" ], function(parser, BC, CP, Map, Layer) { // create layout dijits parser.parse(); // create a map map = new esri.Map("map", { "extent": new esri.geometry.Extent({"xmin":-13635599,"ymin":4545388,"xmax":-13632458,"ymax":4546651,"spatialReference":{"wkid":102100}}) }); // add streets var url = "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"; var tiled = new esri.layers.ArcGISTiledMapServiceLayer(url); map.addLayer(tiled); // add the feautre layer, via the layer wrapper var flInfo = { "Layer_ID": "counties", "AGS_ID": 0, "LayerType": "featurelayer", "Service_URL": "http://sampleserver6.arcgisonline.com/arcgis/rest/services/SF311" }; var fl = new Layer(flInfo); console.log("created fl: ", fl); map.addLayer(fl.maplayer); }); </script> </head> <body> <div dojotype="dijit.layout.BorderContainer" design="headline" gutters="false" style="width: 100%; height: 100%; margin: 0;"> <div id="map" dojotype="dijit.layout.ContentPane" region="center" style="border:1px solid #000;padding:0;"> </div> </div> </body> </html>
... View more
10-10-2012
04:48 PM
|
0
|
0
|
1102
|
|
POST
|
Once a map's levels are set they can't be changed. Using options.lods for the map constructor isn't the most straightforward thing (and we'll hopefully change this soon) but it does work. Here's an example:
<!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" />
<!--The viewport meta tag is used to improve the presentation and behavior of the samples on iOS devices-->
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
<title>Topographic Map</title>
<link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.2/js/dojo/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.2/js/esri/css/esri.css">
<style>
html, body { height: 100%; width: 100%; margin: 0; padding: 0; }
#map { padding:0; }
</style>
<script>var dojoConfig = {parseOnLoad: true};</script>
<script src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.2"></script>
<script>
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("esri.map");
var map;
function init() {
var bounds = new esri.geometry.Extent({"xmin":-8500293,"ymin":4590772,"xmax":-8299263,"ymax":4671642,"spatialReference":{"wkid":102100}});
map = new esri.Map("map",{
extent: bounds,
lods: [
{"level" : 6, "resolution" : 2445.98490512499, "scale" : 9244648.868618},
{"level" : 7, "resolution" : 1222.99245256249, "scale" : 4622324.434309},
{"level" : 8, "resolution" : 611.49622628138, "scale" : 2311162.217155},
{"level" : 9, "resolution" : 305.748113140558, "scale" : 1155581.108577},
{"level" : 10, "resolution" : 152.874056570411, "scale" : 577790.554289},
{"level" : 11, "resolution" : 76.4370282850732, "scale" : 288895.277144},
{"level" : 12, "resolution" : 38.2185141425366, "scale" : 144447.638572},
{"level" : 13, "resolution" : 19.1092570712683, "scale" : 72223.819286},
{"level" : 14, "resolution" : 9.55462853563415, "scale" : 36111.909643},
{"level" : 15, "resolution" : 4.77731426794937, "scale" : 18055.954822},
{"level" : 16, "resolution" : 2.38865713397468, "scale" : 9027.977411}
]
});
var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer");
map.addLayer(basemap);
dojo.connect(map, "onLoad", function(theMap) {
dojo.connect(dijit.byId("map"), "resize", map, map.resize);
});
}
dojo.ready(init);
</script>
</head>
<body class="claro">
<div dojotype="dijit.layout.BorderContainer" design="headline" gutters="false" style="width: 100%; height: 100%; margin: 0;">
<div id="map" dojotype="dijit.layout.ContentPane" region="center" style="border:1px solid #000;padding:0;">
</div>
</div>
</body>
</html>
I pulled those levels from here: http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer?f=pjson If you're not using a web mercator basemap, you can pull levels for your map from your services directory.
... View more
10-10-2012
02:33 PM
|
0
|
0
|
1795
|
|
POST
|
Are you not able to use map.lods to specify your levels of detail when the map is created?
... View more
10-10-2012
12:18 PM
|
0
|
0
|
1795
|
|
POST
|
I can't believe I got it work! This method executes much faster than the forum example, so I'm glad I switched. That's awesome! Glad you got it working.
... View more
10-09-2012
08:57 AM
|
0
|
0
|
2472
|
|
POST
|
I see now that I still had all my references to version 2.5 <snip> That will make a big difference. Glad you moved up to 3.2. The code still isn't working right, but at least I'm past the first error. Post the code you're currently using and a description of what isn't working?
... View more
10-09-2012
08:35 AM
|
0
|
0
|
3849
|
|
POST
|
I have setup the two callback functions Dojo.connect doesn't work that way. The behavior of dojo.connect changes depending on how many arguments are provided. By providing four args, you're causing your 3rd argument to be treated as a JS context for the 4th argument. In this case, I recommend using three arguments to dojo.connect and check for success or failure of loading your layers looking at result.success to see if your layer was loading successfully or not.
... View more
10-09-2012
07:53 AM
|
0
|
0
|
817
|
|
POST
|
I think find is enabled by default when you publish a map service. You could ask in the AGS forum for a definite answer. Did you uncheck Query when publishing your map service? Do you see "find" listed as a supported operation when you look at your service via your REST services directory?
... View more
10-09-2012
07:44 AM
|
0
|
0
|
438
|
|
POST
|
I"m not sure why I would use an esri.request to the query endpoint as opposed to executing a standard query task. I usually execute my query tasks with a callback to generate my featureset. Is is faster to request the data or formatted differently if I use esri.request instead? You could use a QueryTask to pull your features out. I said esri.request because it's always available (no additional modules to load) and you don't need any of Query's special functionality. I wouldn't expect a noticeable performance difference between the two.
... View more
10-09-2012
07:30 AM
|
0
|
0
|
3849
|
|
POST
|
If you're using ArcGIS Server services, why not use ArcGISDynamicMapServiceLayer?
... View more
10-08-2012
09:57 AM
|
0
|
0
|
1051
|
|
POST
|
Incorrect scale for level 2, it should be 147914381.897889. Alternatively, use the WebTiledLayer class to avoid having to manually set up a TileInfo object.
... View more
10-08-2012
08:31 AM
|
0
|
0
|
525
|
|
POST
|
Are you using setDynamicLayerInfos on your dynamic service before re-creating your legend?
... View more
10-05-2012
02:32 PM
|
0
|
0
|
693
|
|
POST
|
One of the parameters for cluster layer is "data". As noted in the sample description, data is an array of objects and each object has the following properties: x, y and attributes. Here's the workflow to get data from a layer in a map service or feature service in this format: send a request to the layer's query endpoint with esri.request when data comes back, use dojo.map to create an array of objects with x, y and attributes properties pass the result from dojo.map to the cluster layer That's a high level overview. Can one of you take a crack at coding it up and post back here? I can provide further help if you can't make it work.
... View more
10-05-2012
10:09 AM
|
0
|
0
|
3849
|
|
POST
|
I'm having a hard time understanding this. A bbox request is issued, but multiple images come back? Maybe OpenLayers is doing something different under the hood. Is there a public example of OpenLayers using this service somewhere?
... View more
10-05-2012
08:11 AM
|
0
|
0
|
2258
|
|
POST
|
I would suggest using the WebTiledLayer. Here's a working example: <!doctype html> <html lang="en"> <head> <meta 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></title> <link rel="stylesheet" href="http://servicesbeta.esri.com/jsapi/arcgis/3.2/js/dojo/dijit/themes/nihilo/nihilo.css"> <link rel="stylesheet" href="http://servicesbeta.esri.com/jsapi/arcgis/3.2/js/esri/css/esri.css" /> <style type="text/css"> html, body { height: 100%; width: 100%; margin: 0; padding: 0; } body{ background-color: #fff; overflow:hidden; font-family: sans-serif; } #header { padding: 4px 15px 4px 0; background-color: #F2F2EC; color: #575757; font-size: 16pt; text-align: right; font-weight: bold; height:55px; } .ds { background: #000; overflow: hidden; position: absolute; z-index: 2; } #ds-h div { width: 100%; } #ds .o1 { filter: alpha(opacity=10); opacity: .1; } #ds .o2 { filter: alpha(opacity=8); opacity: .08; } #ds .o3 { filter: alpha(opacity=6); opacity: .06; } #ds .o4 { filter: alpha(opacity=4); opacity: .04; } #ds .o5 { filter: alpha(opacity=2); opacity: .02; } #ds .h1 { height: 1px; } #ds .h2 { height: 2px; } #ds .h3 { height: 3px; } #ds .h4 { height: 4px; } #ds .h5 { height: 5px; } </style> <script>var dojoConfig = { parseOnLoad: true }; </script> <script src="http://servicesbeta.esri.com/jsapi/arcgis/3.2/"></script> <script> dojo.require("dijit.layout.BorderContainer"); dojo.require("dijit.layout.ContentPane"); dojo.require("esri.map"); dojo.require("esri.layers.WebTiledLayer"); var map; function init() { var ext = esri.geometry.Extent; var bounds = new ext({"xmin":-6993870,"ymin":6864998,"xmax":19246655,"ymax":15161779,"spatialReference":{"wkid":102100}}); map = new esri.Map("map", { extent: bounds, wrapAround180: false }); dojo.connect(map, "onLoad", function(map) { dojo.connect(dijit.byId("map"), "resize", map, map.resize); }); var wtl = esri.layers.WebTiledLayer; // optional, but useful when a tiled layer only has a few levels var tileInfo = tileInfo = new esri.layers.TileInfo({ "rows" : 256, "cols" : 256, "dpi" : 96, "format" : "JPEG", "compressionQuality" : 0, "origin" : { "x" : -20037508.340000, "y" : 20037508.340000 }, "spatialReference" : { "wkid" : 102100 }, "lods" : [ {"level" : 0, "resolution" : 156543.033928, "scale" : 591657528}, {"level" : 1, "resolution" : 78271.51695000000472646207, "scale" : 295828764}, {"level" : 2, "resolution" : 39135.75847500000236323103, "scale" : 147914382}, {"level" : 3, "resolution" : 19567.87923750000118161552, "scale" : 73957191}, {"level" : 4, "resolution" : 9783.93961875000059080776, "scale" : 36978595}, {"level" : 5, "resolution" : 4891.96980937500029540388, "scale" : 18489298}, {"level" : 6, "resolution" : 2445.98490468750014770194, "scale" : 9244649}, {"level" : 7, "resolution" : 1222.99245234375007385097, "scale" : 4622324}, {"level" : 8, "resolution" : 611.49622617187503692548, "scale" : 2311162} ] }); var modis = new wtl("http://map1.vis.earthdata.nasa.gov/wmts-geo/wmts.cgi?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=MODIS_Terra_CorrectedReflectance_TrueColor&STYLE=&TILEMATRIXSET=EPSG4326_250m&TILEMATRIX=${level}&TILEROW=${row}&TILECOL=${col}&FORMAT=image%2Fjpeg", { "copyright": "NASA", "id": "NASA", "tileInfo": tileInfo }); map.addLayer(modis); } //show map on load dojo.ready(init); </script> </head> <body class="nihilo"> <div id="mainWindow" data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="design:'headline',gutters:false" style="width: 100%; height: 100%; margin: 0;"> <div id="header" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'top'"> NASA Modis </div> <div id="map" class="shadow" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'center'"> <!-- drop shadow divs --> <div id="ds"> <div id="ds-h"> <div class="ds h1 o1"></div> <div class="ds h2 o2"></div> <div class="ds h3 o3"></div> <div class="ds h4 o4"></div> <div class="ds h5 o5"></div> </div> </div> <!-- end drop shadow divs --> </div> </div> </body> </html> On jsfiddle: http://jsfiddle.net/ZfGm2/
... View more
10-04-2012
10:55 AM
|
0
|
0
|
1753
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 01-23-2012 07:54 AM | |
| 1 | 05-28-2010 08:31 AM | |
| 1 | 11-12-2012 08:12 AM | |
| 3 | 02-23-2012 10:57 AM | |
| 1 | 06-27-2011 08:51 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:23 AM
|