Please, I need help with this problem.I have a layer with 5 lines as roads, and all of they with a geocode.Also, i have a mxd as a map service in a ArcGis Server 9.3.I need to put the map of the service in a webpage across Esri Javascript, but filtering the roads across a GET or POST variable and highlight this road.Please....help me !! and sorry for my english.Christian
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>test</title> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.1/js/dojo/dijit/themes/tundra/tundra.css"> <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.1"></script> <script type="text/javascript"> dojo.require("esri.map"); dojo.require("esri.tasks.query"); dojo.require("esri.symbol"); dojo.require("esri.layers.agstiled"); dojo.require("esri.toolbars.draw"); var map; var myQueryTask, myQuery; var infoTemplate; var symbol; function init() { //create map and add layer map = new esri.Map("mapDiv"); var layer = new esri.layers.ArcGISDynamicMapServiceLayer("http://gis/ArcGIS/rest/services/MOP/MapServer"); map.addLayer(layer); //build query myQueryTask = new esri.tasks.QueryTask("http://gis/ArcGIS/rest/services/MOP/MapServer/10"); //build query filter myQuery = new esri.tasks.Query(); myQuery.returnGeometry = true; myQuery.outFields = ["CodUnico","Nombre","Dire"]; //initialize InfoTemplate infoTemplate = new esri.InfoTemplate("${CodUnico}", "Nombre : ${Nombre}<br/> Dire : ${Dire}"); //create symbol for selected features symbol = new esri.symbol.SimpleMarkerSymbol(); symbol.setStyle(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE); symbol.setSize(10); symbol.setColor(new dojo.Color([255,0,0,0.5])); } function execute(CodUnico) { myQuery.where = "CodUnico like '%" + CodUnico + "%'"; //execute query myQueryTask.execute(myQuery,showResults); } function showResults(myFeatureSet) { var s = ""; for (var i=0, il=myFeatureSet.features.length; i<il; i++) { var featureAttributes = myFeatureSet.features.attributes; for (att in featureAttributes) { s = s + "<strong>" + att + ": </strong>" + featureAttributes[att] + "<br />"; } } dojo.byId("info").innerHTML = s; //remove all graphics on the maps graphics layer map.graphics.clear(); //Performance enhancer - assign featureSet array to a single variable. var resultFeatures = myFeatureSet.features; //Loop through each feature returned for (var i=0, il=resultFeatures.length; i<il; i++) { //Get the current feature from the featureSet. //Feature is a graphic var graphic = resultFeatures; graphic.setSymbol(symbol); //Set the infoTemplate. graphic.setInfoTemplate(infoTemplate); //Add graphic to the map graphics layer. map.graphics.add(graphic); } } dojo.addOnLoad(init); </script> </head> <body> <form action=""> Geocodigo DAP : <input type="text" id="CodUnico" value="DAP101012" /> <input type="button" value="Get Details" onclick="execute(dojo.byId('CodUnico').value);" /> </form> <br /> <br /><div id="mapDiv" style="margin:auto;width:97%;border:1px solid #000;"></div> <div id="info" class="tundra" style="padding:5px; margin:5px; background-color:#eee;"></div> </body> </html>
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.