POST
|
Hi guys, I was wondering If anyone of you know how to do this... I have a query results, I want to make zoom to that query results, I think the properly name of it is Zoom to selected features ... please if anyone knows how to do it help me By the way: In the results I told you about, I receive the X,Y, of what I'm trying to zoom. Any code for it? in JavaScript Alex,
... View more
09-01-2010
01:36 PM
|
0
|
4
|
6276
|
POST
|
I think I'm not follow sorry, It seems like its connecting to the server to do the query but the results doesn't display <!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>Query State Info without Map</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" language="Javascript">
dojo.require("esri.tasks.query");
var queryTask, query;
function init() {
//build query
queryTask = new esri.tasks.QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5");
queryTask = new esri.tasks.QueryTask("http://servarcgisprd/ArcGIS/rest/services/MapaBase/MapServer/4");
//dojo.connect(queryTask, "onComplete", showResults);
//build query filter
query = new esri.tasks.Query();
query.returnGeometry = false;
//query.outFields = ["SQMI", "STATE_NAME", "STATE_FIPS", "SUB_REGION", "STATE_ABBR", "POP2000", "POP2007", "POP00_SQMI", "POP07_SQMI", "HOUSEHOLDS", "MALES", "FEMALES", "WHITE", "BLACK", "AMERI_ES", "ASIAN", "OTHER", "HISPANIC", "AGE_UNDER5", "AGE_5_17", "AGE_18_21", "AGE_22_29", "AGE_30_39", "AGE_40_49", "AGE_50_64", "AGE_65_UP"];
query.outFields = ["POSTE","COORDENADA_X","COORDENADA_Y"];
}
function execute(stateName) {
query.text = stateName;
//execute query
queryTask.execute(query, showResults);
}
function showResults(results) {
var s = "";
for (var i = 0, il = results.features.length; i < il; i++) {
var featureAttributes = results.features.attributes;
for (att in featureAttributes) {
s = s + "<b>" + att + ":</b> " + featureAttributes[att] + "<br />";
}
}
dojo.byId("info").innerHTML = s;
}
dojo.addOnLoad(init);
</script>
</head>
<body>
US state name : <input type="text" id="stateName" value="California" />
<input type="button" value="Get Details" onclick="execute(dojo.byId('stateName').value);" />
<br />
<br />
<div id="info" style="padding:5px; margin:5px; background-color:#eee;">
</div>
</body>
</html> Do you get anything in the js console when you run it? Another thing to try is make sure the server is actually returning something by looking at the requests that the app sends to it. If you're not sure how to do this take a look at firebug for firefox, dev console for IE8 or dev tools for chrome.
... View more
09-01-2010
08:34 AM
|
0
|
0
|
203
|
POST
|
Hi swingley I just want to thank you! I found out was the problem was the one about the distance I told you about like 1 hour ago, what happened was that my "<span id ="span1">" was incorrect it supposed to be "<span id="distance">" but I just changed it and it work just fine! thank you so much!! Alex
... View more
09-01-2010
06:53 AM
|
0
|
0
|
486
|
POST
|
Thank you so much!!! It worked! You know the line sends its lenght to show in the distance space, but it's not showing any distance at all , I think it's because of the tb variable, it seems like its connecting with the geometry service at "http://sampleserver3.arcgisonline.com... " but still doesn't show the distance. thanks for all the help I really really appreciate. I think you're almost there...make tb global and change your markup to something like this: <div id="map" class="tundra" style="width:1024px; height:512px; border:1px solid #000;"></div>
Distance: <span id="distance"></span><br />
<input type="button" value="Desactivar" onclick="tb.deactivate();map.showZoomSlider();" />
<input type="button" value="Line" onclick="tb.activate(esri.toolbars.Draw.LINE);map.hideZoomSlider();" /
... View more
09-01-2010
06:07 AM
|
0
|
0
|
486
|
POST
|
I tried those samples, but with my code It didn't work... <!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>Measure Distances</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"> djConfig = { parseOnLoad: true }</script>
<script src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.0" type="text/javascript"></script>
<script type="text/javascript">
dojo.require("esri.map");
dojo.require("esri.tasks.geometry");
dojo.require("esri.toolbars.draw");
var map, navToolbar;
var bandera = 1;
var geometryService;
function init() {
//identify proxy page to use if the toJson payload to the geometry service is greater than 2000 characters.
//If this null or not available the project and lengths operation will not work. Otherwise it will do a http post to the proxy.
//esriConfig.defaults.map.sliderLabel = null;
//esriConfig.defaults.io.proxyUrl = "/arcgisserver/apis/javascript/proxy/proxy.ashx";
//esriConfig.defaults.io.alwaysUseProxy = false;
//var startExtent = new esri.geometry.Extent(-80.0571, 41.3697, -74.4321, 44.0822, new esri.SpatialReference({ wkid: 32615 }));
var startExtent = new esri.geometry.Extent({
"xmin": 650.24376718739,
"ymin": 1515.85251773739,
"xmax": 807.862232212611,
"ymax": 1673.47098276261,
"spatialReference": { 'wkid': 32615 }
});
var map = new esri.Map("map"); //, { extent: startExtent });
dojo.connect(map, "onLoad", initFunctionality);
//map.addLayer(new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer"));
map.addLayer(new esri.layers.ArcGISDynamicMapServiceLayer("http://servarcgisprd/ArcGIS/rest/services/MapaBase/MapServer"));
geometryService = new esri.tasks.GeometryService("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
dojo.connect(geometryService, "onLengthsComplete", outputDistance);
}
function initFunctionality(map) {
var tb = new esri.toolbars.Draw(map);
var lengthParams = new esri.tasks.LengthsParameters();
//on draw end add graphic, project it, and get new length
dojo.connect(tb, "onDrawEnd", function (geometry) {
map.graphics.clear();
lengthParams.polylines = [geometry];
lengthParams.lengthUnit = esri.tasks.GeometryService.UNIT_METER;
lengthParams.geodesic = true;
//call GeometryService.lengths() with projected geometry
geometryService.lengths(lengthParams);
var graphic = map.graphics.add(new esri.Graphic(geometry, new esri.symbol.SimpleLineSymbol()));
});
tb.activate(esri.toolbars.Draw.LINE);
}
function outputDistance(result) {
dojo.byId("distance").innerHTML = dojo.number.format(result.lengths[0]) + " metros or " + dojo.number.format(result.lengths[0] / 1000) + " Kilometros";
}
dojo.addOnLoad(init);
</script>
</head>
<body>
Click and hold down on the map to draw a line that will be added to the map. The application will then use the geometry service to project and compute the length of the line.
<div id="map" class="tundra" style="width:1024px; height:512px; border:1px solid #000;"></div>
Distance: <span id="distance"></span><br />
<input type="button" value="Activar" onclick="" /><br />
<input type="button" value="Desactivar" onclick="toolbar.deactivate();map.showZoomSlider();" /><br />
<button dojoType="dijit.form.Button" onClick="tb.activate(esri.toolbars.Draw.LINE);map.hideZoomSlider();">Line</button>
<button dojoType="dijit.form.Button" onClick="tb.deactivate();map.showZoomSlider();">Deactivate</button>
</body>
</html>
It's like tb its not a global variable I don't know It seems to me that but my experience with JavaScript its very little thanks for taking the time to read this
... View more
08-31-2010
02:04 PM
|
0
|
0
|
486
|
POST
|
Hi, It worked what you told me, Just I want to know If you can help me with this, in the same code I want to make 2 buttons (one for activate the toolbar another for deactivate it) so it's that possible? thanks, for your anwser Deactivate your drawing toolbar?
... View more
08-31-2010
12:29 PM
|
0
|
0
|
486
|
POST
|
Hi, Im having this problem... whenever I run this web site I cannot make zoom in or zoom out, or even move the map with the pan control, can anyone tell me why is this ? please I've been working with this sample since I found it and I don't know how to solve this problem ... my code <!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">
<title>Measure Distances</title>
<script src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.0" type="text/javascript"></script>
<script type="text/javascript">
dojo.require("esri.map");
dojo.require("esri.tasks.geometry");
var map, navToolbar;
var geometryService;
function init() {
//esriConfig.defaults.map.sliderLabel = null;
//var startExtent = new esri.geometry.Extent(-80.0571, 41.3697, -74.4321, 44.0822, map.spatialReference); //new esri.SpatialReference({ wkid: 4326 }));
var map = new esri.Map("map"); //, { extent: FullExtent });
dojo.connect(map, "onLoad", initFunctionality);
map.addLayer(new esri.layers.ArcGISDynamicMapServiceLayer("http://servarcgisprd/ArcGIS/rest/services/MapaBase/MapServer"));
geometryService = new esri.tasks.GeometryService("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
dojo.connect(geometryService, "onLengthsComplete", outputDistance);
// navTool = new esri.toolsbars.Navigation(map);
// dojo.connect(navToolbar, "onExtentHistoryChange", extentHistoryChangeHandler);
}
function initFunctionality(map) {
var tb = new esri.toolbars.Draw(map);
var lengthParams = new esri.tasks.LengthsParameters();
//on draw end add graphic, project it, and get new length
dojo.connect(tb, "onDrawEnd", function (geometry) {
map.graphics.clear();
lengthParams.polylines = [geometry];
lengthParams.lengthUnit = esri.tasks.GeometryService.UNIT_METER;
lengthParams.geodesic = false;
//call GeometryService.lengths() with projected geometry
geometryService.lengths(lengthParams);
var graphic = map.graphics.add(new esri.Graphic(geometry, new esri.symbol.SimpleLineSymbol()));
});
tb.activate(esri.toolbars.Draw.LINE);
}
function outputDistance(result) {
dojo.byId("distance").innerHTML = dojo.number.format(result.lengths[0]) + " metros or " + dojo.number.format(result.lengths[0] / 1000) + " Kilometros";
}
// function extentHistoryChangeHandler() {
// dijit.byId("zoomprev").disabled = navToolbar.isFirstExtent();
// dijit.byId("zoomnext").disabled = navToolbar.isLastExtent();
// }
dojo.addOnLoad(init);
</script>
</head>
<body>
Click and hold down on the map to draw a line that will be added to the map. The application will then use the geometry service to project and compute the length of the line.
<div id="map" ></div>
Distance: <span id="distance"></span>
</body>
</html>
... View more
08-31-2010
09:07 AM
|
0
|
8
|
1370
|
POST
|
Hi, well I've been searching for answers... but I cannot find something that helps me, my problem is: I have to show a map with a custom extent and a different spatial reference, whenever I try to set this two, my map doesn't show ... here is my code... (it's from a sample I found I just add my map service)
....
var initialExtent = new esri.geometry.Extent({
"xmin": 650.24376718739,
"ymin": 1515.85251773739,
"xmax": 807.862232212611,
"ymax": 1673.47098276261,
"spatialReference": {
PROJCS["WGS_1984_UTM_Zone_15N",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-93.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Kilometer",1000.0]]
}
});
map = new esri.Map("map", {
extent: initialExtent,
slider: false
});
dojo.connect(dijit.byId('map') , 'resize', function () {
//resize the map when browser size changes
resizeMap();
// });
dojo.connect(map, "onClick", mapClickHandler);
var topoMap = new esri.layers.ArcGISDynamicMapServiceLayer("http://servarcgisprd/ArcGIS/rest/services/MapaBase/MapServer", {
id: "topo",
visible: true
});
baseLayers.push(topoMap);
map.addLayers(baseLayers);
.....
As you can see my spatial reference it's very different from anything else, so It's ok I wrote it like that? Help !! Thanks, Alex
... View more
08-31-2010
07:24 AM
|
0
|
1
|
528
|
POST
|
Steve, thanks for your help, Would you have it in javascript code?
... View more
08-30-2010
01:55 PM
|
0
|
0
|
163
|
POST
|
Hi guys, I was wondering if someone knows how to zoom in to a specific object. p.e. If I have a car layer with 10 cars in it, every car has its own ID (from 1 to 10), what I want it's to zoom it to a specific car ID, let's say 7 so I want the map makes zoom to the car with the ID = 7. It's that possible? If it is, how can I do it? Thanks Alex,
... View more
08-30-2010
11:52 AM
|
0
|
2
|
554
|
POST
|
Hi, so this code was working for me like 2 weeks ago but... the map has change and then it doesn't work anymore, can you help me ? please
<!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>Query State Info without Map</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" language="Javascript">
dojo.require("esri.tasks.query");
var queryTask, query;
function init() {
//build query
queryTask = new esri.tasks.QueryTask("http://servarcgisprd/ArcGIS/rest/services/MapaBase/MapServer/4");
//build query filter
query = new esri.tasks.Query();
query.returnGeometry = false;
query.outFields = ["POSTE", "COORDENADA_X", "COORDENADA_Y"]
}
function execute(stateName) {
query.text = stateName;
//execute query
queryTask.execute(query, showResults);
}
function showResults(results) {
var s = "";
for (var i = 0, il = results.features.length; i < il; i++) {
var featureAttributes = results.features.attributes;
for (att in featureAttributes) {
s = s + "<b>" + att + ":</b> " + featureAttributes[att] + "<br />";
}
}
dojo.byId("info").innerHTML = s;
}
dojo.addOnLoad(init);
</script>
</head>
<body>
US state name : <input type="text" id="stateName" value="" />
<input type="button" value="Get Details" onclick="execute(dojo.byId('stateName').value);" />
<br />
<br />
<div id="info" style="padding:5px; margin:5px; background-color:#eee;">
</div>
</body>
</html> I think is the 'MapaBase' service the one who is making the mistake but... I don't know anymore I'll appreciate if anyone can help me... 🙂
... View more
08-27-2010
01:41 PM
|
0
|
2
|
689
|
POST
|
I know why it doesn't display the map! It was because : // var startExtent = new esri.geometry.Extent(-80.0571, 41.3697, -74.4321, 44.0822, new esri.SpatialReference({ wkid: 4326 })); var map = new esri.Map("map"); //, { extent: startExtent }); this lines had the extent parameter on it, so I just commented and It work, but I have another problem now :S please help me If you know how My map doesnt Zoom in or out it just stay I want to get closer please if you know help me
... View more
08-26-2010
12:55 PM
|
0
|
0
|
127
|
POST
|
Hi, I wonder If anyone could help me, I got this code: <!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"> <title>Measure Distances</title> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.0/js/dojo/dijit/themes/tundra/tundra.css"> <script src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.0" type="text/javascript"></script> <script type="text/javascript"> dojo.require("esri.map"); dojo.require("esri.tasks.geometry"); dojo.require("esri.toolbars.draw"); dojo.require("dojo.number"); var geometryService; function init() { //identify proxy page to use if the toJson payload to the geometry service is greater than 2000 characters. //If this null or not available the project and lengths operation will not work. Otherwise it will do a http post to the proxy. esriConfig.defaults.io.proxyUrl = "/arcgisserver/apis/javascript/proxy/proxy.ashx"; esriConfig.defaults.io.alwaysUseProxy = false; var startExtent = new esri.geometry.Extent(-80.0571, 41.3697, -74.4321, 44.0822, new esri.SpatialReference({ wkid: 4326 })); var map = new esri.Map("map", { extent: startExtent }); dojo.connect(map, "onLoad", initFunctionality); //map.addLayer(new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer")); map.addLayer(new esri.layers.ArcGISDynamicMapServiceLayer("http://servarcgisprd/ArcGIS/rest/services/MapaBase/MapServer")); geometryService = new esri.tasks.GeometryService("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"); dojo.connect(geometryService, "onLengthsComplete", outputDistance); } function initFunctionality(map) { var tb = new esri.toolbars.Draw(map); var lengthParams = new esri.tasks.LengthsParameters(); //on draw end add graphic, project it, and get new length dojo.connect(tb, "onDrawEnd", function (geometry) { map.graphics.clear(); lengthParams.polylines = [geometry]; lengthParams.lengthUnit = esri.tasks.GeometryService.UNIT_METER; lengthParams.geodesic = true; //call GeometryService.lengths() with projected geometry geometryService.lengths(lengthParams); var graphic = map.graphics.add(new esri.Graphic(geometry, new esri.symbol.SimpleLineSymbol())); }); tb.activate(esri.toolbars.Draw.FREEHAND_POLYLINE); } function outputDistance(result) { dojo.byId("distance").innerHTML = dojo.number.format(result.lengths[0] ) + " meters"; } dojo.addOnLoad(init); </script> </head> <body> Click and hold down on the map to draw a line that will be added to the map. The application will then use the geometry service to project and compute the length of the line. <div id="map" class="tundra" style="width:1024px; height:512px; border:1px solid #000;"></div> Distance: <span id="distance"></span> </body> </html> Well the problem is that I press F5 to run it, and it does, but the map doesn't display ... I don't know why ... I thought it was the spatial reference but... I'm not sure the spatial reference is: Spatial Reference: PROJCS["WGS_1984_UTM_Zone_15N",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-93.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Kilometer",1000.0]] Anyone knows ?
... View more
08-26-2010
12:02 PM
|
0
|
1
|
475
|
POST
|
Tim, thank you so much!, I'm trying it right now I just have one question, when I create the points I use this lines (just to try) : p1 = new esri.geometry.Geometry.Point(767045.94,1620609.96,??); p2 = new esri.geometry.Geometry.Point(768450.94,7621609.90,??); I don't know what to put in the spatial reference parameter because my map has this as a spatial reference: PROJCS["WGS_1984_UTM_Zone_15N",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-93.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Kilometer",1000.0]] It's a lot and I don't think i have to put all that into a parameter right? Please can You tell me, what should I do? Thanks Alex, Alex, I think if you take a close look at the first page swingley pointed out (http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/util_distance.html), you'll see some code that shows how to set up the parameters for a call to the GeometryService's distance task. It shows how to add geometries from an array. In your case, you'd add your two known points:
var distParams = new esri.tasks.DistanceParameters();
distParams.distanceUnit = esri.tasks.GeometryService.UNIT_STATUTE_MILE;
distParams.geometry1 = pointA; //<--- your Point A geometry
distParams.geometry2 = pointB; //<--- your Point B geometry
distParams.geodesic = true;
The sample code on the page shows how to call GeometryService.distance and work with its results. The section where it says function(distance){..}) catches the data returned by GeometryService.distance in the parameter distance.
geometryService.distance(distParams, function(distance) {
// Do what you want with the result.
});
});
Hope that helps, Tim
... View more
08-26-2010
09:55 AM
|
0
|
0
|
432
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|