|
POST
|
The same strategy applies. After you grab the URL using esri.urlToObject(), create a dynamic map service layer and add it to the map.
... View more
07-26-2011
11:39 AM
|
0
|
0
|
1726
|
|
POST
|
Oops, previously forgot a link to the thread I was referencing. I updated my post. Not sure if the forum notifies you when I edit so I'm posting again...
... View more
07-26-2011
11:14 AM
|
0
|
0
|
1656
|
|
POST
|
Yes, the "Border and Margin" ArcGIS.com sample show this. Here's the URL for the sample: http://help.arcgis.com/en/webapi/javascript/arcgis/demos/ags/ags_fullmaplayoutwithborderandmargin.html And here it is with a URL parameter for a webmap: http://help.arcgis.com/en/webapi/javascript/arcgis/demos/ags/ags_fullmaplayoutwithborderandmargin.html?webmap=d902ef17333c4dbe9e0caa05e067ec89
... View more
07-26-2011
11:10 AM
|
0
|
0
|
1726
|
|
POST
|
Geometry service is the way to go. Here's an 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://serverapi.arcgisonline.com/jsapi/arcgis/2.4/js/dojo/dijit/themes/tundra/tundra.css">
<style>
html, body { height: 100%; width: 100%; margin: 0; padding: 0; }
#map{ margin: 0; padding: 0; }
#info {
position: absolute;
top: 10px;
right: 10px;
width: 160px;
height: 80px;
z-index: 40;
background: #fff;
padding: 5px;
color: #000;
font-family: arial;
}
#results { color: red; }
</style>
<script>var dojoConfig = { parseOnLoad: true };</script>
<script src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.4"></script>
<script>
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("esri.map");
dojo.require("esri.tasks.geometry");
var map, resizeTimer, gsvc;
function init() {
var initExtent = new esri.geometry.Extent({"xmin":13410892.167988224,"ymin":394170.65114215855,"xmax":13413646.353547676,"ymax":395793.8403501995,"spatialReference":{"wkt":"PROJCS[\"NAD_1983_StatePlane_Michigan_South_FIPS_2113_IntlFeet\",GEOGCS[\"GCS_North_American_1983\",DATUM[\"D_North_American_1983\",SPHEROID[\"GRS_1980\",6378137.0,298.257222101]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Lambert_Conformal_Conic\"],PARAMETER[\"False_Easting\",13123359.58005249],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",-84.36666666666666],PARAMETER[\"Standard_Parallel_1\",42.1],PARAMETER[\"Standard_Parallel_2\",43.66666666666666],PARAMETER[\"Latitude_Of_Origin\",41.5],UNIT[\"Foot\",0.3048]]"}});
map = new esri.Map("map",{extent:initExtent});
var basemap = new esri.layers.ArcGISDynamicMapServiceLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer");
map.addLayer(basemap);
gsvc = new esri.tasks.GeometryService("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
dojo.connect(map, 'onClick', projectPoint);
dojo.connect(map, 'onLoad', function() {
dojo.connect(dijit.byId('map'), 'resize', function() {
clearTimeout(resizeTimer);
resizeTimer = setTimeout( function() {
map.resize();
map.reposition();
}, 500);
});
});
}
function projectPoint(evt) {
// console.log(evt.mapPoint);
map.graphics.clear();
map.graphics.add(new esri.Graphic(
evt.mapPoint,
new esri.symbol.SimpleMarkerSymbol()
));
var outSR = new esri.SpatialReference({ wkid: 102113});
gsvc.project([evt.mapPoint], outSR, function(result) {
// console.log('success: ', result);
dojo.byId('results').innerHTML = result[0].x.toFixed() +
', ' + result[0].y.toFixed();
});
}
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 id="info">
<div id="instructions">Click the map to convert the click point to Web Mercator.</div>
<div id="results"></div>
</div>
</div>
</div>
</body>
</html>
Don't let the well-known text in the initial extent's spatial reference throw you off, it works the same if you use a WKID.
... View more
07-26-2011
11:05 AM
|
0
|
0
|
3118
|
|
POST
|
It's supported in newer browsers: http://stackoverflow.com/questions/4309958/can-i-write-files-with-html5-js/4309968#4309968
... View more
07-26-2011
06:54 AM
|
0
|
0
|
2355
|
|
POST
|
The geographicToWebMercator helper method only converts lat, long coordinates to web mercator while the geometry service's project method does not have this restriction. The geometry service supports re-projecting from any of the coordinate systems listed in the help: http://help.arcgis.com/en/arcgisserver/10.0/apis/rest/pcs.html http://help.arcgis.com/en/arcgisserver/10.0/apis/rest/gcs.html Also, geographicToWebMercator works on a single geometry while the geometry service can works with one or more geometries. The only downside of the geometry service is that it requires a server round trip while geographicToWebMercator is all client side.
... View more
07-26-2011
06:51 AM
|
0
|
0
|
1654
|
|
POST
|
Hi Steve, Identify always returns all attributes...see: http://help.arcgis.com/en/arcgisserver/10.0/apis/rest/identify.html You could not expose certain fields in your map service but that's probably not ideal. For the aliases, take a look at this post: http://forums.arcgis.com/threads/7793-Identify-How-to-show-Alias-filed-instead-of-Field-Name?p=24158&viewfull=1#post24158
... View more
07-25-2011
10:23 PM
|
0
|
0
|
533
|
|
POST
|
They do two different things. getLength calculates a Eudclidean distance AKA planar distance which assumes the world is flat. This is appropriate for short distances and/or when you're using a projected coordinate system, e.g. a UTM zone or State Plane. geodesicLengths calculates a geodesic distance which is a measurement on a sphere. This is appropriate when you're measuring long distances on a globe. I'll also throw in a plug for a blog post Sterling from the server team did a while back about using the right coordinate system when measuring distances in a web app: Measuring distances and areas when your map uses the Mercator projection.
... View more
07-25-2011
12:40 PM
|
0
|
0
|
1656
|
|
POST
|
Please provide more info on exactly what you're trying to do. Are you trying to get an image from a dynamic map service? Please be specific.
... View more
07-25-2011
12:29 PM
|
0
|
0
|
2355
|
|
POST
|
Yes, it's a bug. A fix will be rolled out with the next release of ArcGIS Online (probably two weeks).
... View more
07-25-2011
12:28 PM
|
0
|
0
|
1661
|
|
POST
|
Can you follow the pattern in the Feature Layer On Demand sample where you load your feature layers after the map loads? Relevant code:
function init() {
map = new esri.Map("map", { extent: esri.geometry.geographicToWebMercator(extent)});
dojo.connect(map, "onLoad", initOperationalLayer);
}
function initOperationalLayer(map) {
var content = "<b>Type</b>: ${ftype}" +
"<br /><b>Code</b>: ${fcode}";
var infoTemplate = new esri.InfoTemplate("Rivers", content);
var featureLayer = new esri.layers.FeatureLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Hydrography/Watershed173811/FeatureServer/1",{
mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
outFields: ["*"],
infoTemplate: infoTemplate
});
map.addLayer(featureLayer);
} Also, it looks like the map.setExtent function call in your init function is unnecessary.
... View more
07-25-2011
07:39 AM
|
0
|
0
|
2450
|
|
POST
|
Technically, it's wouldn't be an error in Firebug, just a warning. What do you see in the console? Are there any messages? Can you modify your view to include your layer's objectID?
... View more
07-25-2011
07:24 AM
|
0
|
0
|
1774
|
|
POST
|
I modified the find task with results in a grid to use an identify task:
<!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" />
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
<title>Display Identify Task results in Dojo DataGrid</title>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.4/js/dojo/dijit/themes/claro/claro.css">
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.4/js/dojo/dojox/grid/resources/Grid.css">
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.4/js/dojo/dojox/grid/resources/claroGrid.css">
<script type="text/javascript">dojoConfig = { parseOnLoad:true }</script>
<style>
html, body { height: 100%; width: 100%; margin: 0; padding: 0; }
</style>
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.4"></script>
<script type="text/javascript">
dojo.require("esri.map");
dojo.require("dojox.grid.DataGrid");
dojo.require("dojo.data.ItemFileReadStore");
dojo.require("esri.tasks.identify");
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.form.Button");
var idTask, idParams;
var map, startExtent;
var grid, store;
function init() {
dojo.connect(grid, "onRowClick", onRowClickHandler);
//Create map and add the ArcGIS Online imagery layer
startExtent = new esri.geometry.Extent({"xmin":-9275203,"ymin":5248350,"xmax":-9271966,"ymax":5249253,"spatialReference":{"wkid":102100}});
map = new esri.Map("map", { extent: startExtent});
var streetMapLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");
map.addLayer(streetMapLayer);
// Dynamic map service used by the Identify task
// Uncomment the next two lines to see parcel boundaries
// var parcelLayer = new esri.layers.ArcGISDynamicMapServiceLayer('http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/TaxParcel/TaxParcelQuery/MapServer');
// map.addLayer(parcelLayer);
//Create Identify Task using the URL of the map service to search
idTask = new esri.tasks.IdentifyTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/TaxParcel/TaxParcelQuery/MapServer");
//Create the identify parameters
idParams = new esri.tasks.IdentifyParameters();
idParams.returnGeometry = true;
idParams.layerIds = [0];
idParams.tolerance = 3;
idParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL;
idParams.width = map.width;
idParams.height = map.height;
dojo.connect(map, 'onClick', doIdentify);
var resizeTimer;
dojo.connect(map, 'onLoad', function(theMap) {
dojo.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 doIdentify(evt) {
//Set the search text to the value in the box
idParams.geometry = evt.mapPoint;
idParams.mapExtent = map.extent;
console.log('do ID: ', evt, '; params: ', idParams);
idTask.execute(idParams, showResults);
}
function showResults(results) {
console.log('got results: ', results);
map.graphics.clear();
var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([98,194,204]), 2), new dojo.Color([98,194,204,0.5]));
//create array of attributes
var items = dojo.map(results,function(result){
var graphic = result.feature;
graphic.setSymbol(symbol);
map.graphics.add(graphic);
return result.feature.attributes;
});
//Create data object to be used in store
var data = {
identifier: "PARCELID", //This field needs to have unique values
label: "PARCELID", //Name field for display. Not pertinent to a grid but may be used elsewhere.
items: items
};
//Create data store and bind to grid.
store = new dojo.data.ItemFileReadStore({ data:data });
var grid = dijit.byId('grid');
grid.setStore(store);
//Zoom back to the initial map extent
map.setExtent(startExtent);
}
//Zoom to the parcel when the user clicks a row
function onRowClickHandler(evt){
var clickedTaxLotId = grid.getItem(evt.rowIndex).PARCELID;
var selectedTaxLot;
dojo.forEach(map.graphics.graphics,function(graphic){
if((graphic.attributes) && graphic.attributes.PARCELID === clickedTaxLotId){
selectedTaxLot = graphic;
return;
}
});
var taxLotExtent = selectedTaxLot.geometry.getExtent();
map.setExtent(taxLotExtent);
}
dojo.addOnLoad(init);
</script>
</head>
<body class="claro">
<div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="design:'headline'" style="width:100%;height:100%;margin:0;">
<div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'top'" style="height:40px;">
Identify Task + Dojo Data Grid
</div>
<div id="map" data-dojo-props="region:'center'" data-dojo-type="dijit.layout.ContentPane" style="border:1px solid #000;"></div>
<div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'bottom'" style="height:150px;">
<table data-dojo-type="dojox.grid.DataGrid" data-dojo-id="grid" id="grid" data-dojo-props="rowsPerPage:'5', rowSelector:'20px'">
<thead>
<tr>
<th field="PARCELID">Parcel ID</th>
<th field="OWNERNME1" >Owner 1</th>
<th field="OWNERNME2">Owner 2</th>
<th field="RESYRBLT ">Year Built</th>
<th field="SITEADDRESS" width="100%">Address</th>
</tr>
</thead>
</table>
</div>
</div>
</body>
</html>
Two big changes: switch to an identify task and set up a map click handler; I didn't have to change any of the logic in the callback that handles the results from the identify task.
... View more
07-22-2011
10:06 AM
|
0
|
0
|
1458
|
|
POST
|
I think we should clarify some terms... When I said popup, I was referring to the popup widget that was introduced with version 2.3 of the API. I'm not sure what you mean by dojo popup but let's ignore that for now. If you define an infoTemplate when you create your feature layer, you should see an info window when you click your features. See the ON_DEMAND feature layer sample for an example.
... View more
07-22-2011
07:06 AM
|
0
|
0
|
2450
|
| 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
|