|
POST
|
Right, it's all about URL length. If the URL is over 2k characters, you have to do a POST. If the app is not on the same domain as the map service, this requires a proxy. Once you go to a proxy, the JS API works with JSON so the map service will return a URL to an image (which the JS API then inserts into the page) rather than the image itself. Why do you want the image to be returned from the server rather than a URL to the image?
... View more
10-07-2011
10:27 AM
|
0
|
0
|
2441
|
|
POST
|
My previous comment still applies...give it a try and let us know if you have any issues.
... View more
10-06-2011
03:24 PM
|
0
|
0
|
1945
|
|
POST
|
Why are you expecting the server to return an image for a featureLayer? FeatureLayer's are a subclass of graphicsLayer and display vector features. Can you post an example of what you're passing to setDefinitionExpression()?
... View more
10-06-2011
03:19 PM
|
0
|
0
|
2441
|
|
POST
|
Once your KMLLayer loads, call getLayers() on it. This will return the feature layers that make up the KMLLayer (one for each type of geometry present for a possible total of three- points, lines, polygons). Once you have you feature layer, loop through the graphics and look at the attributes.name property for each graphic. If you run this JS on the simple KMLLayer sample:
map.getLayer(map.graphicsLayerIds[0]).graphics[0].attributes.name
It will print "Wyoming(WY)"
... View more
10-06-2011
03:17 PM
|
0
|
0
|
1945
|
|
POST
|
At 2.5, the KMLLayer can handle time. Time-enabled KML seems to be almost non-existent on the web but our KMLLayer does work with vector features. When you create a KMLLayer with time enabled features, you can then connect your layer to a time slider. Unfortunately, your time enabled features are ground overlays. In it's current state, the KMLLayer doesn't work with time enabled ground overlays. I'll see if we can get this in for the next release. Until then...it'll take some work. My first thought is to still use a KMLLayer, pull out the map images that are returned, parse the name property since it contains the time and then set up a way animate through them. You could still use a time slider...
... View more
10-06-2011
02:47 PM
|
0
|
0
|
780
|
|
POST
|
Hi Samir, To show/hide a graphicsLayer, just call the layer's show() or hide() method(which is inherited from esri.layers.Layer). The same applies for a feaureLayer.
... View more
10-06-2011
02:00 PM
|
0
|
0
|
1726
|
|
POST
|
Here's a thread talking about how to do it: http://forums.arcgis.com/threads/41009 Relevant code:
// create and add the layer
var mil = new esri.layers.MapImageLayer({
'id': 'usgs_screen_overlay'
});
map.addLayer(mil);
// create an add the actual image
var mi = new esri.layers.MapImage({
'extent': { 'xmin': -8864908, 'ymin': 3885443, 'xmax': -8762763, 'ymax': 3976997, 'spatialReference': { 'wkid': 3857 }},
'href': 'http://hdds.usgs.gov/hdds2/view/overlay_file/AM01N33_269827W079_1773002011082800000000MS00'
});
mil.addImage(mi);
... View more
10-06-2011
09:20 AM
|
0
|
0
|
923
|
|
POST
|
Answered in another thread: http://forums.arcgis.com/threads/41009-Use-of-esri.layers.MapImageLayer-in-ArcGIS-API-for-Javascript?p=139257&viewfull=1#post139257
... View more
10-05-2011
03:36 PM
|
0
|
0
|
836
|
|
POST
|
Yes, it's possible. We didn't publish any samples that directly use this class as it was introduced with the KMLLayer and is used internally by the KMLLayer to display ground overlays. Anyway, the code you posted was pretty close. The missing piece is to create and pass an esri.layers.MapImage object to .addImage() instead of a plain JS object. Here's some sample code:
<!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.5/js/dojo/dijit/themes/tundra/tundra.css">
<link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.5/js/esri/dijit/css/Popup.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/?v=2.5"></script>
<script>
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("esri.map");
dojo.require("esri.layers.MapImageLayer");
var map;
function init() {
var initExtent = new esri.geometry.Extent({"xmin":-9005991,"ymin":3866418,"xmax":-8620442,"ymax":4022043,"spatialReference":{"wkid":102100}});
map = new esri.Map("map",{extent:initExtent});
var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer");
map.addLayer(basemap);
// create and add the layer
var mil = new esri.layers.MapImageLayer({
'id': 'usgs_screen_overlay'
});
map.addLayer(mil);
// create an add the actual image
var mi = new esri.layers.MapImage({
'extent': { 'xmin': -8864908, 'ymin': 3885443, 'xmax': -8762763, 'ymax': 3976997, 'spatialReference': { 'wkid': 3857 }},
'href': 'http://hdds.usgs.gov/hdds2/view/overlay_file/AM01N33_269827W079_1773002011082800000000MS00'
});
mil.addImage(mi);
dojo.connect(map, 'onLoad', function() {
dojo.connect(dijit.byId('map'), 'resize', map, map.resize);
});
}
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>
... View more
10-05-2011
03:36 PM
|
0
|
0
|
1052
|
|
POST
|
This forum is for the ArcGIS API for JavaScript. For a such a general GIS question, I suggest you ask it on the GIS stack exchange.
... View more
10-05-2011
09:47 AM
|
0
|
0
|
4229
|
|
POST
|
Being that it's IE7 and 8, it's bound to be something VML related. Beyond that, I'm not sure. As far as optimizations go, I don't see much room for improvement. Do as little as possible and use simple symbols. How about asking IE users to install Google Chrome Frame (doesn't require admin rights anymore)?
... View more
10-05-2011
09:43 AM
|
0
|
0
|
2511
|
|
POST
|
I haven't been able to isolate a specific problem with your code but I was able to tweak the Find an Address sample to do a geocode then buffer and not have it throw the error in IE. Let me know if this code works for you:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Find Address</title>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.5/js/dojo/dijit/themes/claro/claro.css">
<style>
html, body {
height: 100%; width: 100%;
margin: 0; padding: 0;
}
#map{
padding:0;
border:solid 1px #343642;
margin:5px 5px 5px 0px;
}
#leftPane{
width:20%;
border-top: solid 1px #343642;
border-left: solid 1px #343642;
border-bottom: solid 1px #343642;
background-color:#DCDAC5;
margin:5px 0px 5px 5px;
color: #343642;
font:100% Georgia,"Times New Roman",Times,serif;
letter-spacing: 0.05em;
}
</style>
<script type="text/javascript">var dojoConfig = { parseOnLoad: true };</script>
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.5"></script>
<script type="text/javascript">
dojo.require("esri.map");
dojo.require("esri.tasks.locator");
dojo.require("dojo.number");
dojo.require("dijit.form.Button");
dojo.require("dijit.form.Textarea");
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
var map, locator, gs, bufferGraphics;
function init() {
var initExtent = new esri.geometry.Extent({"xmin":-13343554,"ymin":2967656,"xmax":-7473190,"ymax":5902838,"spatialReference":{"wkid":102100}});
map = new esri.Map("map", { extent: initExtent});
var tms = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");
map.addLayer(tms);
dojo.connect(map, 'onLoad', function(map) {
dojo.connect(dijit.byId('map'), 'resize', map,map.resize);
});
gs = new esri.tasks.GeometryService('http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer');
locator = new esri.tasks.Locator("http://tasks.arcgisonline.com/ArcGIS/rest/services/Locators/TA_Address_NA_10/GeocodeServer");
dojo.connect(locator, "onAddressToLocationsComplete", showResults);
bufferGraphics = new esri.layers.GraphicsLayer();
dojo.connect(bufferGraphics, 'onLoad', function() {
map.reorderLayer(bufferGraphics, 0);
});
map.addLayer(bufferGraphics);
// hit the locator when a link is clicked
dojo.forEach(dojo.query('a', dojo.byId('leftPane')), function(anchor) {
dojo.connect(anchor, 'onclick', function() {
console.log('clicked a link, sending: ', this.innerHTML);
locate(this.innerHTML);
});
});
}
function locate() {
map.graphics.clear();
bufferGraphics.clear();
var address;
arguments.length ? address = arguments[0] :
address = dojo.byId('address').value;
var address = { "SingleLine": address };
locator.outSpatialReference= map.spatialReference;
locator.addressToLocations(address,["Loc_name"]);
}
function showResults(candidates) {
var candidate;
var geom;
var symbol = new esri.symbol.SimpleMarkerSymbol();
var infoTemplate = new esri.InfoTemplate("Location", "Address: ${address}<br />Score: ${score}<br />Source locator: ${locatorName}");
dojo.every(candidates,function(candidate){
// console.log(candidate.score);
if (candidate.score > 80) {
// add a point for the graphic
var attributes = { address: candidate.address, score:candidate.score, locatorName:candidate.attributes.Loc_name };
geom = candidate.location;
var graphic = new esri.Graphic(geom, symbol, attributes, infoTemplate);
map.graphics.add(graphic);
// buffer the point
doBuffer([geom], handleBuffer, errorHandler);
return false; //break out of loop after one candidate with score greater than 80 is found.
}
});
if(geom !== undefined){
map.centerAndZoom(geom,12);
}
}
function doBuffer(geoms, callback, err) {
var bufferParams = new esri.tasks.BufferParameters();
bufferParams.distances = [1];
bufferParams.bufferSpatialReference = map.spatialReference;
bufferParams.outSpatialReference = map.spatialReference;
bufferParams.unit = esri.tasks.GeometryService.UNIT_STATUTE_MILE;
bufferParams.geometries = geoms;
gs.buffer(bufferParams, callback, err);
}
function handleBuffer(bufferResults) {
// console.log('buffer came back: ', bufferResults);
var symbol = new esri.symbol.SimpleFillSymbol(
esri.symbol.SimpleFillSymbol.STYLE_SOLID,
new esri.symbol.SimpleLineSymbol(
esri.symbol.SimpleLineSymbol.STYLE_SOLID,
new dojo.Color([5, 95, 158, 0.65]),
2
),
new dojo.Color([145, 209, 255, 0.35])
);
// add the buffer graphic
// then move it back so that address point show up on top
bufferGraphics.add(
new esri.Graphic(
bufferResults[0],
// new esri.symbol.SimpleFillSymbol()
symbol
)
);
}
function errorHandler(err) {
console.log('buffer failed...');
}
dojo.ready(init);
</script>
</head>
<body class="claro">
<div id="mainWindow" dojotype="dijit.layout.BorderContainer" design="sidebar" gutters="false" style="width:100%; height:100%;">
<div id="leftPane" dojotype="dijit.layout.ContentPane" region="left">
Enter an input address and the application will use the sample address locator to return the location for
street addresses in the United States.
<br />
<textarea type="text" id="address"/>380 New York St, Redlands</textArea>
<br />
<button dojotype="dijit.form.Button" onclick="locate()"> Locate</button>
<br />
<a href="#">1060 West Addison, Chicago, IL</a><br />
<a href="#">380 New York Street, Redlands, CA</a><br />
<a href="#">1600 Pennsylvania Ave. Washington, DC</a><br />
</div>
<div id="map" dojotype="dijit.layout.ContentPane" region="center">
</div>
</div>
</body>
</html>
... View more
10-04-2011
03:52 PM
|
0
|
0
|
2511
|
|
POST
|
No plans yet. You could add it to the default basemap gallery with something like this: function createBasemapGallery() {
//add the basemap gallery, in this case we'll display maps from ArcGIS.com including bing maps
var basemapGallery = new esri.dijit.BasemapGallery({
showArcGISBasemaps: true,
bingMapsKey: 'Av1bH4keF8rXBtxWOegklgWGCYYz8UGYvBhsWKuvc4Z15kT76xVFOERk8jkKEDvT',
map: map
}, "basemapGallery");
basemapGallery.startup();
dojo.connect(basemapGallery, 'onLoad', function(bm) {
// find a base map to remove
// in this case, it'll be the one named "Terrain"
var bm = dojo.filter(basemapGallery.basemaps, function(bm) {
return bm.title == 'Terrain';
})[0];
// remove the basemap from the gallery
basemapGallery.remove(bm.id);
// create a BasemapLayer and Basemap with the
// ligh gray basemap
var grayLayer = new esri.dijit.BasemapLayer({
url:"http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer"
});
var grayBasemap = new esri.dijit.Basemap({
layers:[grayLayer],
title:"Light Gray",
thumbnailUrl:"http://www.arcgis.com/sharing/content/items/8b3d38c0819547faa83f7b7aca80bd76/info/thumbnail/lightgray_thumb_webmap2.png"
});
// add the light gray basemap
basemapGallery.add(grayBasemap);
});
}
Or you can manually add it by building your own basemap gallery, see this sample: http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/widget_basemapManual.html
... View more
10-04-2011
10:59 AM
|
0
|
0
|
1251
|
|
POST
|
Does this code repro the issue for you:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test IE8 Buffer / Graphics Layer Bug</title>
<link type="text/css" rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.5/js/dojo/dijit/themes/tundra/tundra.css"/>
<style type="text/css">
body { font-size: 100%; font-family: Verdana; }
#map { height: 600px; width: 800px; margin: 50 auto; }
</style>
<script>var dojoConfig = { parseOnLoad: true };</script>
<script src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.5"></script>
<script>
dojo.require("esri.map");
dojo.require("esri.tasks.locator");
var map, locator, addressGraphicSymbol, GEOMETRY_SERVICE;
var spatialReferenceWKID_BING = 102113;
function init() {
// console.log('into init...');
var initExtent = new esri.geometry.Extent({ "xmin": -13056017, "ymin": 4028145, "xmax": -13030946, "ymax": 4042916, "spatialReference": { "wkid": 102100}});
map = new esri.Map("map", { extent: initExtent });
locator = new esri.tasks.Locator("http://tasks.arcgisonline.com/ArcGIS/rest/services/Locators/TA_Address_NA_10/GeocodeServer");
// dojo.connect(locator, "onAddressToLocationsComplete", showResults);
dojo.connect(locator, "onAddressToLocationsComplete", placeAddressGraphic);
//Add the topographic layer to the map. View the ArcGIS Online site for services http://arcgisonline/home/search.html?t=content&f=typekeywords:service
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) {
//resize the map when the browser resizes
dojo.connect(dijit.byId('map'), 'resize', map, map.resize);
});
addressGraphicSymbol = new esri.symbol.SimpleMarkerSymbol();
GEOMETRY_SERVICE = new esri.tasks.GeometryService('http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer');
}
function geocodeAddress() {
// map.graphics.clear();
var address = { "SingleLine": dojo.byId("address").value };
locator.outSpatialReference= map.spatialReference;
locator.addressToLocations(address,["Loc_name"]);
}
function placeAddressGraphic(c) {
// c is a candidates object
// console.log('candidates: ', c);
var x = c[0].location.x, y = c[0].location.y;
// Create the Address Layer on the map
//------------------------------------
var addressLayer = createGraphicsLayer("addressBufferLayer");
if (addressLayer) {
reorderGraphicsLayer("addressBufferLayer", 0);
// Must add Graphic to map
//------------------------
var point = new esri.geometry.Point(x, y, new esri.SpatialReference({ "wkid": spatialReferenceWKID_BING }));
var graphic = new esri.Graphic(point, addressGraphicSymbol);
var focusRadius = 1;
if (graphic != undefined && graphic != null) {
// Create buffer parameters for buffer query
//------------------------------------------
var params = new esri.tasks.BufferParameters();
params.distances = [focusRadius];
params.bufferSpatialReference = new esri.SpatialReference({ "wkid": spatialReferenceWKID_BING });
params.outSpatialReference = map.spatialReference;
params.unit = esri.tasks.GeometryService.UNIT_STATUTE_MILE;
params.geometries = [graphic.geometry];
// console.log('params: ', params);
GEOMETRY_SERVICE.buffer(params,
function (features) {
// alert('buffer callback');
if (features != undefined && features != null) {
var bufferGraphic = null;
var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID,
new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([5, 95, 158, 0.65]), 2),
new dojo.Color([145, 209, 255, 0.35]));
dojo.forEach(features, function (feature) {
bufferGraphic = new esri.Graphic(feature, symbol);
var layer = getGraphicsLayer("addressBufferLayer");
if (layer == null) {
layer = createGraphicsLayer("addressBufferLayer");
reorderGraphicsLayer("addressBufferLayer", 0);
}
if (layer != null) {
layer.clear();
layer.add(bufferGraphic);
layer.add(graphic);
}
});
if (bufferGraphic != undefined && bufferGraphic != null) {
map.setExtent(bufferGraphic.geometry.getExtent().expand(1.5));
}else{
alert("There was a problem drawing buffer. bufferGraphic is null or undefined.");
}
}else{
alert("There was a problem executing buffer. No features were returned");
}
},
function (Error) {
var message = "The geometry service's buffer() method failed. \r\nCode: " +
Error.code + "\r\nMessage: " + Error.message + "\r\nDetails:" + Error.details;
alert(message);
}
);
}
}
}
function createGraphicsLayer(layerID) {
var layer = null;
var oldLayer = null;
// Create graphics layer and remove any layer that is
// there with the same ID
//---------------------------------------------------
if (map.getLayer(layerID)) {
oldLayer = map.getLayer(layerID);
layer = new esri.layers.GraphicsLayer({ id: "newLayer" });
map.removeLayer(oldLayer);
layer.id = layerID;
}
else {
layer = new esri.layers.GraphicsLayer({ id: layerID });
}
// Add new layer to map
//---------------------
map.addLayer(layer);
return layer;
}
function reorderGraphicsLayer (layerID, index) {
// Check for invalid indexes
//--------------------------
if (index < 0 || (map.graphicsLayerIds != undefined && index > map.graphicsLayerIds.length)) {
alert("reorderGraphicsLayer failed. Index (" + index + ") is out of range");
return null;
}
var layer = map.getLayer(layerID);
if (layer == undefined || layer == null) {
alert("reorderGraphicsLayer failed. Layer (" + layerID + ") not found.");
return null;
}
map.reorderLayer(layer, index);
}
function getGraphicsLayer (layerID) {
var layer = map.getLayer(layerID);
if (layer == undefined || layer == null) {
alert("GetGraphicsLayer failed. Layer (" + layerID + ") is undefined or null");
return null;
}
return layer;
}
dojo.ready(init);
</script>
</head>
<body class="tundra">
<div class="search">
<span>SEARCH:</span>
<input type="text" id="address" value="1600 Pennsylvania Ave. Washington, DC" />
<input type="button" value="Search" onclick="geocodeAddress();" />
<br />
<span>
380 New York Street, Redlands, CA<br />
1600 Pennsylvania Ave. Washington, DC<br />
1060 W. Addison Street, Chicago, IL<br />
</span>
</div>
<div id="map"></div>
</body>
</html>
... View more
10-04-2011
10:38 AM
|
0
|
0
|
2511
|
| 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
|