|
POST
|
Heming, Thank you very much for your help, I appreciate this. I have got the "from" point geocoded now and zoomed to on the map, but it seems that driving directions do not work properly yet. Please see the code page with the address modified in the input text boxes (I have not changed anything apart from the input addresses): <input type="text" id="fromTxf" value="1 Kungsgatan, Stockholm, 11143, Sweden" size="30" />
<input type="text" id="toTxf" value="10 Parkvagen, Gavle, 80267, Sweden" size="30" /> The application treats the input start point to be the end point as well, so I do not get any route calculated, since the start and the end point coincide. I have looked into the syntax and did not find any typo or alike, so my guess is that it has something to do with the syntax. I know that it is very hard to debug the JavaScript code (you get Intellisense in Aptana and that is basically it), but I would be beholden to you if you could take a look at the code when you get a chance. I think there is a bug the ESRI has to look into. It all has something to do with the Json expression of the address object (looked at the this thread: http://forums.arcgis.com/threads/23457-Geocoding-Service-Not-returning-Candidates-to-quot-Application-quot?p=77554#post77554). So i changed the address Json object to Object. For anyone who has struggled with Json expression of the object (subset of javascript object), use javascript object. I have tried, it is more flexible(no order to follow!) and never failed me. Attached is the code.
... View more
05-20-2011
05:14 AM
|
0
|
0
|
1137
|
|
POST
|
tereshenkov;103217 wrote: Heming, That is very nice of you. The code is the exact copy of the sample page one can get from the Resource Center apart from the REST URL for the geocoding and routing services (now European) plus those address variable parameters you have helped me to declare. The address you defined has to match with the locator's Address Fields listed on the locator service directory. I modified several lines in ESRI's driving directions to use the EU locator and Router you mention. Please pay attention to how to define the address object in the code: Code attached
... View more
05-19-2011
11:58 AM
|
0
|
0
|
1137
|
|
POST
|
thanks for your reply. I've attached a screenshot of the issue I have - because I haven't included claro.css in my page (to avoid getting all the unwanted reset styles), the attached image shows what my zoom slider looks like at the moment! Not very attractive! Your reply seemed to indicate the practical option available to me is to refined the classes used to style this slider, but is there any way to find out a complete list? Maybe there is and that's a silly question but I don't know! If I open claro.css, it's a compressed css file, so hard to easily get the info out of there (again, unless I'm missing something!). The same thing happens with my popups, so these would need to be styled too. Thanks. dojo css files are pretty well designed for the most parts. It is recommended that you should include in the page and overwrite those style(s) only if you don't like them. It would be nice for ESRI to have detail doc about those css so we don't spend a lot of time digging out ourself.
... View more
05-19-2011
07:35 AM
|
0
|
0
|
1902
|
|
POST
|
Hi Heming, Thank you. I have tested the input and I have got several results, so it should be no problem in here. Any other suggestions? Then you might have to look into your code (i can take a look if you don't mind posting your code).
... View more
05-19-2011
06:44 AM
|
0
|
0
|
2689
|
|
POST
|
The locator you use has 4 address fields: Address, City, Postcode, County. So your code should look like: var address ={}; address.Address ="123 sesame street"; address.City ="heaven"; address.Postcode="12345"; address.Country = "Sweden"; The more detail you give, the better chance you will get a hit. FYI. ArcGIS 10 allow you to put a single line of text like API stated: var address = {"Single Line Input":"123 sesame street, heaven, 12345, Sweden "}; Test your input on http://tasks.arcgisonline.com/ArcGIS/rest/services/Locators/TA_Address_EU/GeocodeServer/findAddressCandidates to see whether your input is wrong or somewhere else in your code...
... View more
05-19-2011
04:47 AM
|
0
|
0
|
2689
|
|
POST
|
Hi Heming, Thanks for the reply! So, I have to paste this line of code somewhere in the page, right? I have declared the variable address right after the creating an instance of the locator: locator = new esri.tasks.Locator("http://tasks.arcgisonline.com/ArcGIS/rest/services/Locators/TA_Address_EU/GeocodeServer");
dojo.connect(locator, "onError", errorHandler);
var address ={};
address.Country = Sweden; Now I don't get this error that country is required, but there is still no route generated and of course there are no directions shown either. In the textboxes, I am typing a string like: Street HouseNumber City Postcode Country I guess the problem has something to do with the piece of code you gave me, I might have interpreted it incorrectly. Thank you again for the help, Heming. The locator you use has 4 address fields: Address, City, Postcode, County. So your code should look like: var address ={}; address.Address ="123 sesame street"; address.City ="heaven"; address.Postcode="12345"; address.Country = "Sweden"; The more detail you give, the better chance you will get a hit. FYI. ArcGIS 10 allow you to put a single line of text like API stated: var address = {"Single Line Input":"123 sesame street, heaven, 12345, Sweden "};
... View more
05-18-2011
01:22 PM
|
0
|
0
|
2689
|
|
POST
|
Hi all, My aim is to create a web application where a user could click on the map or type in the address end and start points for the routing; the route will be calculated and shown on the map; the directions text will be shown on the html page to the user. This application I need exclusively for testing of the routing capabilities available via the ArcGIS Web API. It seemed that the easiest way would be to customize the sample Get driving directions (http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/arcgis/help/jssamples_start.htm#jssamples/routetask_directions.html) to use European geocoding and routing services. I have exchanged the locator and the routing services strings with the European services: locator = new esri.tasks.Locator("http://tasks.arcgisonline.com/ArcGIS/rest/services/Locators/TA_Address_EU/GeocodeServer"); and routeTask = new esri.tasks.RouteTask("http://tasks.arcgisonline.com/ArcGIS/rest/services/NetworkAnalysis/ESRI_Route_EU/NAServer/Route");
However, when trying to get the directions, I get the error message from the browser: An error occured Unable to complete operation. Required field '<i>Country</i>' must be specified I understand that probably this coming from the code where the parsing of the input geocoding strings happen. I.e. //Parse and geocode "from" address
var fromArr = dojo.byId("fromTxf").value.split(","),
fromAddress = { Address:fromArr[0], City:fromArr[1], State:fromArr[2], Zip:fromArr[3] };
locator.addressToLocations(fromAddress, ["Loc_name"], function(addressCandidates) { configureRoute(addressCandidates, "from"); });
//Parse and geocode "to" address
var toArr = dojo.byId("toTxf").value.split(","),
toAddress = { Address:toArr[0], City:toArr[1], State:toArr[2], Zip:toArr[3] };
locator.addressToLocations(toAddress, ["Loc_name"], function(addressCandidates) { configureRoute(addressCandidates, "to"); });
} However, I am not sure how one is supposed to edit this piece of code (or maybe others, too!) in order to reflect the European geocoding parameters (I've looked a bit at http://tasks.arcgisonline.com/ArcGIS/rest/services/Locators/TA_Address_EU/GeocodeServer). I would appreciate if anyone could give me some tips what shall I look at. Maybe it is easier to customize the Find Route sample (http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/arcgis/help/jssamples_start.htm#jssamples/routetask_find_route.html) by implementing the routing directions there, but I am not that familiar with the JavaScript API. Thank you. If you looked at http://tasks.arcgisonline.com/ArcGIS/rest/services/Locators/TA_Address_EU/GeocodeServer, among the Address Fields, Country is required. So when you defined your address parameter, you have to include country name. Othervise, you will get the error. var address ={}; address.Country =must have a value;
... View more
05-18-2011
07:53 AM
|
0
|
0
|
2689
|
|
POST
|
I justed tested it in IE8 and it loaded data into the grid but it took several seconds. Kelly, Did you test it on JS API 2.3 ? The sample seems work now under JS API 2.3. I did a little test. I copy the sample and changed the version to 2.2. The Data Grid is not loading properly again! It does not matter now since i will use the newer version. Thanks for testing.
... View more
05-18-2011
07:36 AM
|
0
|
0
|
831
|
|
POST
|
Hi Thanks for that. I've been experimenting with putting this into the code, but so far, not got it working. I'm not entirely clear where I need to put it. I'm basically using code very similar to this example here: http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/map_dynamiclayerlist.html How would you suggest it can be incorporated into this example? I've tried putting: dojo.connect(dynamicLayer, "onVisibilityChange",handleVisibilityChange); within the init() function, and I've also tried putting it just before map.addLayer(layer) within the buildLayerList function (swapping the first parameter to just be "layer"). My handleVisibilityChange() function is never called. I could be doing something very wrong here, so advice on how to get this working would be great! Thanks. My mistake! onVisibilityChange fire when the layer's visible property change, not for the visibility of the sublayers. Use layer onUpdateStart and onUpdateEnd to handle your situation. I added some code to the sample you mentioned. Try it to see if it works for you. here is the 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"> <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" /> <!--The viewport meta tag is used to improve the presentation and behavior of the samples on iOS devices--> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/> <title>Dynamically Create Map Service Layer List</title> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.3/js/dojo/dijit/themes/claro/claro.css"> <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.3"></script> <script type="text/javascript"> dojo.require("esri.map"); var layer, map, visible = []; function init() { loading = dojo.byId("loadingImg"); //loading image. id map = new esri.Map("map"); layer = new esri.layers.ArcGISDynamicMapServiceLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer"); if (layer.loaded) { buildLayerList(layer); } else { dojo.connect(layer, "onLoad", buildLayerList); } } function buildLayerList(layer) { var items = dojo.map(layer.layerInfos,function(info,index){ if (info.defaultVisibility) { visible.push(info.id); } return "<input type='checkbox' class='list_item' checked='" + (info.defaultVisibility ? "checked" : "") + "' id='" + info.id + "' onclick='updateLayerVisibility();' /><label for='" + info.id + "'>" + info.name + "</label>"; }); dojo.byId("layer_list").innerHTML = items.join(); layer.setVisibleLayers(visible); map.addLayer(layer); dojo.connect(layer, "onUpdateStart", showLoading); dojo.connect(layer, "onUpdateEnd", hideLoading); } function showLoading() { esri.show(loading); } function hideLoading(error) { esri.hide(loading); } function updateLayerVisibility() { var inputs = dojo.query(".list_item"), input; visible = []; dojo.forEach(inputs,function(input){ if (input.checked) { visible.push(input.id); } }); //if there aren't any layers visible set the array to be -1 if(visible.length === 0){ visible.push(-1); } layer.setVisibleLayers(visible); } dojo.addOnLoad(init); </script> </head> <body> This sample loads an ArcGISDynamicMapServiceLayer.<br /> It determines the layers in the map service and presents them as checkboxes that can be used to toggle their visibility.<br /> <br /> Layer List : <span id="layer_list"></span><br /> <br /> <div id="map" class="claro" style="width:600px; height:400px; border:1px solid #000;"> <img id="loadingImg" src="images/loading.gif" style="position:absolute; right:300px; top:200px; z-index:100;" /> </div> </body> </html>
... View more
05-17-2011
12:39 PM
|
0
|
0
|
963
|
|
POST
|
I think I have misunderstood your original suggestion, but I would be grateful if you could expand further. claro.css contains reset css for default fonts, sizes, margins etc to be used. And then it does contain - like you say - the styling for the zoom slider and popups. But short of redefining everything, I'm not sure I follow your suggestion! If I don't want all the body.claro to be defined, but I do want classes like .dijitSliderButtonInner which are part of the slider. There's a good chance I'm missing something obvious here, but grateful if you could explain further! I don't know exactly which style you want to overwrite. If it is just simple ones like width, height etc., you could use: esri.config.defaults.map.slider={left:"30px",top:"30px",width:null,height:"200px"} or esri.config.defaults.map.sliderLabel ={tick:5,labels:null,style:"width:2em; font-family:Verdana; font-size:75%;"} in your init() to change the default slider look. if you want change specific style like .dijitSliderButtonInner in the claro.css. you could do like this: <style type="text/css"> .dijitSliderButtonInner { visibility: visible; !important } </style> it will overwrite .dijitSliderButtonInner in you claro.css.
... View more
05-17-2011
09:52 AM
|
0
|
0
|
1902
|
|
POST
|
None of the features that I am selecting via the querytask are polygons. They are points and polylines. I think from what I now understand that I need a way of taking these and creating a creating a small buffer around them individually to create polygons, and then using these polygons to create a Multipolygon Ring FeatureSet to pass as the AOI for the ExtractDataTask. Am I correct in thinking this? And if so how can I use the buffer gp task as this too needs a geometry for its input? Many thanks, Ben Yes!!! you are on the right track. Use GeometryService's buffer method to create buffer polygons instead. Here is doc you can look at: http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/geometryservice.htm
... View more
05-17-2011
07:51 AM
|
0
|
0
|
2353
|
|
POST
|
Hi I'm using some code from the ESRI examples for toggling the layer visiblity. It works well. function updateLayerVisibility() { var inputs = dojo.query(".list_item"), input; visible = []; for (var i=0, il=inputs.length; i<il; i++) { if (inputs.checked) { visible.push(inputs.id); } } dynamicLayer.setVisibleLayers(visible); } However, I have some layers which are slow to load - maybe take a couple of seconds. They are slow as they contain a lot of data and we've optimised as much as we can for now. Is there a way to capture when the setVisibleLayers() has completed? It would be nice to know when it's completed so I can have a "loading" message. I've had a look on the ESRI API Reference, but there doesn't seem to be a mention of such functionality. Can anyone help? Look into esri.layers.Layer.onVisibilityChange event. It's on http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/layer.htm#onVisibilityChange
... View more
05-17-2011
05:26 AM
|
0
|
0
|
963
|
|
POST
|
Thanks for the reply. Unfortunately that suggestion you have made is not practical. It's not feasible to redefine everything that claro.css defines, as that will mean a lot of unnecessary time being spent and extra code being generated. I don't really want to use claro.css anyway. I have a customer's template and branding guidelines which do the job - all I want to do is be able to style the zoom slider somehow. But unfortunately the styles seem to be locked away and I need to find a way of accessing them. Can anyone suggest a way to style the zoom slider? I didn't suggest you redefine everything in the claro.css. What i said is only overwrite the style that defined the zoom slider. It is a common practice.
... View more
05-17-2011
04:40 AM
|
0
|
0
|
1902
|
|
POST
|
Can you post a link to the sample that is broken in IE? http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/fl_displayvisible.html
... View more
05-17-2011
04:36 AM
|
0
|
0
|
831
|
|
POST
|
Just run across the "Display Visible Fetures" Sample. It seems not loading features on dojox.grid.DataGrid on IE 7 and 8. It works fine on other major browsers. Does someone have the same issue?
... View more
05-16-2011
12:48 PM
|
0
|
4
|
1218
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 04-11-2011 12:16 PM | |
| 1 | 05-25-2017 08:26 AM | |
| 1 | 06-02-2017 07:37 AM | |
| 1 | 06-28-2011 07:02 AM | |
| 1 | 06-12-2017 10:10 AM |
| Online Status |
Offline
|
| Date Last Visited |
10-01-2024
09:57 PM
|