|
POST
|
Try this: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<title>Dynamic Map Service Layer with Custom Projection and Extent</title>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/1.6/js/dojo/dijit/themes/tundra/tundra.css">
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=1.6"></script>
<script type="text/javascript">
dojo.require("esri.map");
var map;
function init() {
map = new esri.Map("map"); //, {extent:customExtentAndSR});
//map service layer has a default spatial reference of 102113.
var mapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://maps.ctcog.org/ArcGIS/rest/services/CTTN/TrailMap/MapServer");
map.addLayer(mapServiceLayer);
}
function parkZoom(xmin,ymin,xmax,ymax) {
console.log(xmin,ymin,xmax,ymax);
map.setExtent(new esri.geometry.Extent({
xmin: xmin,
ymin: ymin,
xmax: xmax,
ymax: ymax,
spatialReference: map.spatialReference
}));
}
dojo.addOnLoad(init);
</script>
</head>
<body>
<div id="map" class="tundra" style="position:relative; width:700px; height:700px; border:2px solid #000;background-color:#FFFFFF;"></div>
<div style="position:relative; width:700px; height:80px; border:2px solid #000;background-color:#FFFFFF;">
<form>
<input type="button" onClick="parkZoom(-10879012.737,3627863.523,-10838639.948,3668236.312)"; value="Bell County" style="width:180px">
<input type="button" onClick="parkZoom(-10851234.816,3645620.340,-10848711.517,3648143.640)"; value="Miller Springs Nature Area" style="width:180px">
<input type="button" onClick="parkZoom(-10868184.178,3633926.650,-10863137.580,3638973.249)"; value="Dana Peak Park" style="width:180px">
</form>
</div>
</body>
</html> The biggest change is separating your map initialization code and code that zooms to a specific extent. In the code above there's a function for each.
... View more
06-03-2010
11:32 AM
|
0
|
0
|
1853
|
|
POST
|
For #1: map = new esri.Map("map", {
extent: initExtent,
logo:false
}); http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi_start.htm#jsapi/map.htm#MapConst
... View more
06-02-2010
01:28 PM
|
0
|
0
|
1535
|
|
POST
|
Contact your customer service rep and ask for the ArcGIS API for JavaScript on disk.
... View more
06-02-2010
12:44 PM
|
0
|
0
|
345
|
|
POST
|
Since you're sending an array with geometry (as opposed to graphics), point your code to a 10 geometry service: http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer See http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp_start.htm#jshelp/migration_20.htm
... View more
05-28-2010
08:38 AM
|
0
|
0
|
693
|
|
POST
|
When are you running that dojo.connect statement? I agree with Adam, posting your current code would be helpful.
... View more
05-28-2010
08:33 AM
|
0
|
0
|
617
|
|
POST
|
I don't think there's any native functionality in the API to help you here. But this wouldn't be too hard to do yourself. Check out window.location and dojo.queryToObject.
... View more
05-28-2010
08:31 AM
|
1
|
0
|
2697
|
|
POST
|
We released an update to v2.0 (beta) of the JavaScript API today, here are the highlights of the release: The overview map, originally a code gallery sample, is now part of the JavaScript API. The documentation is here: http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jsapi_start.htm#jsapi/overviewmap.htm And we have three samples showing how to work with the dijit: http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/map_overviewmap.html http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/map_overviewmapexternal.html http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/layout_styledmap.html We�??ve added several samples that show how to work with Image Services, view them in the Image Service folder on the JS API Samples page: http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jssamples_start.htm We added tooltips to the drawToolbar, these are configurable and can be turned off by setting the showTooltips constructor option to false. We added Temporal rendering support for polyline and polygon features, we have a sample for point features. http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/renderer_temporal.html We added the esri logo to the maps, the logo can be turned off by setting the Map constructor option for logo to false. Nice! Thanks for the heads up.
... View more
05-27-2010
12:38 PM
|
0
|
0
|
1260
|
|
POST
|
This is pretty vague...what do you want to do? The JS API doesn't really handle URL parameters but the REST API does.
... View more
05-27-2010
10:34 AM
|
1
|
1
|
2697
|
|
POST
|
I'm not seeing this yet...which url are you using for the JS API? http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.0 ?
... View more
05-27-2010
10:11 AM
|
0
|
0
|
1260
|
|
POST
|
Geocode "380 New York St, Redlands, CA, 92373" and then try something that won't return any candidates like "aksdjwoekf". You'll see an alert box that says "No Candidates" when there are no results: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<title>Find Address</title>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.0/js/dojo/dijit/themes/tundra/tundra.css">
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.0"></script>
<script type="text/javascript">
dojo.require("esri.map");
dojo.require("esri.tasks.locator");
var map, locator;
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 tiledMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");
map.addLayer(tiledMapServiceLayer);
locator = new esri.tasks.Locator("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Locators/ESRI_Geocode_USA/GeocodeServer");
dojo.connect(locator, "onAddressToLocationsComplete", showResults);
}
function locate() {
map.graphics.clear();
var add = dojo.byId("address").value.split(",");
var address = {
Address : add[0],
City: add[1],
State: add[2],
Zip: add[3]
};
locator.addressToLocations(address,["Loc_name"]);
}
function showResults(candidates) {
var candidate;
var symbol = new esri.symbol.SimpleMarkerSymbol();
var infoTemplate = new esri.InfoTemplate("Location", "Address: ${address}<br />Score: ${score}<br />Source locator: ${locatorName}");
symbol.setStyle(esri.symbol.SimpleMarkerSymbol.STYLE_DIAMOND);
symbol.setColor(new dojo.Color([255,0,0,0.75]));
var points = new esri.geometry.Multipoint(map.spatialReference);
if (candidates.length > 0) {
for (var i=0, il=candidates.length; i<il; i++) {
candidate = candidates;
if (candidate.score > 70) {
var attributes = { address: candidate.address, score:candidate.score, locatorName:candidate.attributes.Loc_name };
var geom = esri.geometry.geographicToWebMercator(candidate.location);
var graphic = new esri.Graphic(geom, symbol, attributes, infoTemplate);
map.graphics.add(graphic);
map.graphics.add(new esri.Graphic(geom, new esri.symbol.TextSymbol(attributes.address).setOffset(0, 8)));
points.addPoint(geom);
}
}
map.setExtent(points.getExtent().expand(3));
} else if (candidates.length == 0) {
alert("No Candidates.");
}
}
dojo.addOnLoad(init);
</script>
</head>
<body class="tundra">
Address : <input type="text" id="address" size="60" value="380 New York St, Redlands, CA, 92373" /> <i>(Address, City, State, Zip)</i>
<input type="button" value="Locate" onclick="locate()" /><br />
<br />
<div id="map" style="width:1200px; height:600px; border:1px solid #000;"></div>
</body>
</html>
... View more
05-26-2010
10:44 AM
|
0
|
0
|
758
|
|
POST
|
This might be what you want: http://resources.esri.com/arcgisserver/apis/javascript/arcgis/index.cfm?fa=codeGalleryDetails&scriptId=16189
... View more
05-25-2010
02:58 PM
|
0
|
0
|
417
|
|
POST
|
Also, it's your code. You're free to name variables how you see fit.
... View more
05-25-2010
01:43 PM
|
0
|
0
|
758
|
|
POST
|
I mean candidates because you posted this: dojo.io.script.jsonp_dojoIoScript4._jsonpCallback( {"candidates" : []}); Basically, if the candidates array has any items, i.e. length > 0, the geocode returned results. If length == 0, the geocode did not return any results.
... View more
05-25-2010
01:42 PM
|
0
|
0
|
758
|
|
POST
|
Check candidates.length first. If it's greater than zero, process the results. If it == zero, show your alert.
... View more
05-25-2010
12:53 PM
|
0
|
0
|
758
|
|
POST
|
Glad to help. I think the search functionality of the arcgis.com sites is slowly improving.
... View more
05-25-2010
11:26 AM
|
0
|
0
|
589
|
| 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
|