|
POST
|
I'm making a simple web application using the JavaScript API. In this web app I want to be able to info-click a point layer, navigate in the map, use the zoom slider and measure a distance and the calculate the cost of this distans. I've manage to get all of this tools into my web app but the problem is that the measure "tool" does not deactivate when using the tools in the navigation toolbar. Does any one know how I can connect the measure tool to a button so I can chose when to activate and deactivate it? I enclose my script below: <!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=utf8"/>
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<!--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>Bredband</title>
<style type="text/css">
@import "http://serverapi.arcgisonline.com/jsapi/arcgis/2.1/js/dojo/dijit/themes/claro/claro.css";
.zoominIcon { background-image:url(images/nav_zoomin.png); width:16px; height:16px; }
.zoomoutIcon { background-image:url(images/nav_zoomout.png); width:16px; height:16px; }
.zoomfullextIcon { background-image:url(images/nav_fullextent.png); width:16px; height:16px; }
.panIcon { background-image:url(images/nav_pan.png); width:16px; height:16px; }
</style>
<script type="text/javascript">djConfig = { parseOnLoad:true }</script>
<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.toolbars.navigation");
dojo.require("dijit.form.Button");
dojo.require("dijit.Toolbar");
dojo.require("esri.layers.FeatureLayer");
dojo.require("dijit.Dialog");
dojo.require("esri.tasks.geometry");
dojo.require("esri.toolbars.draw");
dojo.require("dojo.number");
var mapLayers = [];
var map, navToolbar;
var geometryService;
function init() {
var initExtent = new esri.geometry.Extent({
"xmin": 1292063,
"ymin": 6136810,
"xmax": 1424193,
"ymax": 6268575,
"spatialReference": {
"wkid": 2400
}
});
map = new esri.Map("map", {
extent: initExtent
});
dojo.connect(map, "onLoad", initOperationalLayer);
dojo.connect(map, "onLoad", initFunctionality);
var imagery = new esri.layers.ArcGISTiledMapServiceLayer("http://localhost/ArcGIS/rest/services/Bredband/Kommuner/MapServer");
map.addLayer(imagery);
mapLayers.push(imagery);
geometryService = new esri.tasks.GeometryService("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
dojo.connect(geometryService, "onLengthsComplete", outputDistance);
navToolbar = new esri.toolbars.Navigation(map);
}
//function init() {
// esriConfig.defaults.map.sliderLabel = null;
//var startExtent = new esri.geometry.Extent({"xmin":1226897.18243243,"ymin":6130221.75,"xmax":1489358.81756757,"ymax":6275163.25,"spatialReference":{"wkid":2400}});
//map = new esri.Map("map",{extent:startExtent});
//map.addLayer(new esri.layers.ArcGISTiledMapServiceLayer("http://localhost/ArcGIS/rest/services/Bredband/Kommuner/MapServer"));
//navToolbar = new esri.toolbars.Navigation(map);
//}
function initOperationalLayer(map) {
var content = "<b>Kommun</b>: ${KOMMUN}" +
"<br /><b>Hemsida</b>: ${URL}";
var infoTemplate = new esri.InfoTemplate("Kommun_Centrum", content);
var featureLayer = new esri.layers.FeatureLayer("http://localhost/ArcGIS/rest/services/Bredband/KommunCenter/MapServer/0",{
mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
outFields: ["*"],
infoTemplate: infoTemplate
});
map.addLayer(featureLayer);
map.infoWindow.resize(200,105);
mapLayers.push(featureLayer); //this client side map layer is the maps graphics layer
}
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;
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] / 1000 * 4.8) + " kronor";
}
dojo.addOnLoad(init);
</script>
</head>
<body class="claro">
<div id="navToolbar" dojoType="dijit.Toolbar">
<div dojoType="dijit.form.Button" id="zoomin" iconClass="zoominIcon" onClick="navToolbar.activate(esri.toolbars.Navigation.ZOOM_IN);">Zooma in</div>
<div dojoType="dijit.form.Button" id="zoomout" iconClass="zoomoutIcon" onClick="navToolbar.activate(esri.toolbars.Navigation.ZOOM_OUT);">Zooma ut</div>
<div dojoType="dijit.form.Button" id="zoomfullext" iconClass="zoomfullextIcon" onClick="navToolbar.zoomToFullExtent();">Full utbredning</div>
<div dojoType="dijit.form.Button" id="pan" iconClass="panIcon" onClick="navToolbar.activate(esri.toolbars.Navigation.PAN);">Panorera</div>
</div>
<div id="map" style="width:1024px; height:512px; border:1px solid #000;"></div>
Kostnad: <span id="distance"></span>
</body>
</html>
add navToolbar.deactivate(); tb.activate(esri.toolbars.Draw.FREEHAND_POLYLINE); to your button's onclick eventhandler. Note: always activate one toolbar (draw or navigation) at a time not both!!
... View more
02-14-2011
04:31 AM
|
0
|
0
|
1444
|
|
POST
|
I have a set of multiple census layers, where the largest scale layer is very detailed over heavily populated areas, and quite coarse over remote areas. I need to display the detailed layer when it makes sense to do so - which is not necessarily at the same scale across the entire map. These screenshots illustrate the problem. At a scale of 1:500k the layer should display in rural areas: But in urban areas, the layer shouldn't display until about 1:100k: Using the JavaScript API and REST layers, is there any way to count the features in the current map extent, and turn the layer off/on accordinly? Eg, if there are fewer than 50 polygons, show the detailed layer, otherwise show the coarse layer. Thanks, Steve Do a spatial query against your polygon layer using the current extent as query.geometry and then query.executeForCount(query, callback?, errback?) to get the count of the polygon.
... View more
02-11-2011
05:24 AM
|
0
|
0
|
580
|
|
POST
|
Hi, I am new in GIS area. We have object coordinates in Gauss�??Krüger Coordinate System (transverse Mercator map projection) that we need to display on a map using JavaScript API. Does the API support this coordinate system? and what is "Spatial Reference"? is it a class to represent different coordinate systems? If so how can I find the mapping of corrdinate system - wkid? Thanks in advance. See reference: http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp/pcs.htm and http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp/gcs.htm
... View more
02-09-2011
08:28 AM
|
0
|
0
|
564
|
|
POST
|
Hi, I am desperately trying to set minimum and maximum scale of a feature layer using WKID 4326 as follows but I fail to do so what am I missing?
var featureLayer = new esri.layers.FeatureLayer("http://myserver/ArcGIS/rest/services/myservice/MapServer/1",{
mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
outFields: ["*"],
});
featureLayer.maxScale=0;
featureLayer.minScale=10000/111195; //Convert to decimal degrees
map.addLayer(featureLayer);
If i interpreted your code in GIS terms, your feature layer will not show when zoomed out beyond 1:(10000/111195), meaning you will have to have your map zoom way beyond 1:1 for your layer to show up!!! Try this: minScale = 10000 (1:10000) or minScale =111195 (1:111195). Not the way you set up. Look at your REST service for reference..
... View more
02-09-2011
08:23 AM
|
0
|
0
|
3107
|
|
POST
|
I have difficulty regarding the toggling between two layers as i have many layers in my application and i want to toggel betweeen basemap and imagery in my project using two radio button.Please as soon as possible And thank You in advance, ESRI has example for this: http://help.arcgis.com/en/webapi/javascript/arcgis/demos/map/map_explicitlayerlist.html Note: This works for dynamic map services or (feature layer) not the tiled map services.
... View more
02-08-2011
04:03 AM
|
0
|
0
|
1435
|
|
POST
|
Hello, Has anybody has integrated bird's eye in JavaScript application (API JavaScript 2.1)? I have the doubt if it is legal to use bird's eye integrated in a application that not use API of Bing Maps, like ArcGIS Server. Thanks Pau Pérez http://cartoweb.cma.gva.es I think you are right. Bing map is integrated into ArcGIS server, not the way around. Have you tried JAPI Extension for Google map. Japi extension for Google map is integrated into Google Map API (extended it). So you could add Google Earth plug in into your appliction. I have done that. It works great!
... View more
02-03-2011
04:40 AM
|
0
|
0
|
1396
|
|
POST
|
Hi there, we set up a map, using a rest service in an ArcGISDynamicMapServiceLayer. By pressing the Ctrl key while dragging the mouse and let go again, the map sticks to the mouse pointer and a continous panning is being performed It's not possible to cancel the panning. The only way to get out is to load the website again. I reproduced this in Esri example maps as well, as: http://help.arcgis.com/en/webapi/javascript/arcgis/demos/toolbar/toolbar_edit.html Any clues how to avoid/cancel this pan? Cheers Marcello add map.disablePan() in you code logic...
... View more
02-02-2011
05:21 AM
|
0
|
0
|
1151
|
|
POST
|
HI, Please help me regarding below code. I want to display Query Info without Map. I copied this code from js sample code and i changed queryTask url and outFields name. But this is not working.. why? Please guide me. Thanks RG <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Query Info without Map</title>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.1/js/dojo/dijit/themes/claro/claro.css">
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.1"></script>
<script type="text/javascript" language="Javascript">
dojo.require("esri.tasks.query");
dojo.require("esri.map");
var queryTask, query;
function init() {
//build query
queryTask = new esri.tasks.QueryTask("http://localhost:8399/arcgis/rest/services/future_india/MapServer/6");
//dojo.connect(queryTask, "onComplete", showResults);
//build query filter
query = new esri.tasks.Query();
query.returnGeometry = false;
query.outFields = ["Lat", "Longs", "LocAddress"];
}
function execute(stateName) {
query.text = stateName;
queryTask.execute(query,showResults);
}
function showResults(results) {
alert("showResults");
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>
name : <input type="text" id="stateName" value="Bhiwandi" />
<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 looked into your code. One line caught my attention: query.text = stateName; text is property shorthanded for a where clause using "like". The field used is the display field defined in the map document. please check your layer in Services Directory to see if your display field is the state field. I recommend you use query.where in stead of query.text (put your state in your outfields) and try again. you alos might put a error function callback in your queryTask.execute for debug purpose.
... View more
02-01-2011
08:30 AM
|
0
|
0
|
509
|
|
POST
|
I believe ArcMap is the only client that supports multilayer caches. Check out this note in the 'Advanced options (cache type)' section of the 'Available map cache properties' Help topic: - ArcMap is the recommended client for working with a multilayer cache. Using a multilayer cache in a Web application provides little or no advantage over using a noncached map service. Thanks for your reply. I know that multi_layered cache works on Web ADF. In my case, I have to show individual contours layer in a map service based on user's choice. And those layers are huge in terms of records so it would be nice to have those individual layer cached. Anyway, thanks for your help on that. I will figure out other ways to do this.
... View more
02-01-2011
08:13 AM
|
0
|
0
|
722
|
|
POST
|
I am trying to set transparencies for different features within a layer. Some polygon features are drawn with a thick border and no fill, therefore they don't need to be transparent. However, some polygon features are solid and need to be transparent to be properly viewed on the map. I'm using ArcGIS 10 and Javascript API v2.1 Here's what I've tried so far, and the results: Set transparencies in the .mxd file => "transparent" polygons completely opaque. .mxd layer transparency does not translate. Set {opacity:0.7} when setting up layer to add to map => makes all layers transparent, washing out polygon borders on some features that need opacity:1.0 to view. Breaking up layers so that some can be set {opacity:0.7} and others {opacity:1.0} => messes up flow of table of contents, and requires major reworking of identify, query, and other tools. So far, I haven't found anything in the API that lets me change individual feature opacity. Any suggestions? Have you considered display the layer as a feature layer and use ClassBreaksRenderer to render those polgons differently?
... View more
01-31-2011
10:49 AM
|
0
|
0
|
1595
|
|
POST
|
I create a multi-layered cached map services. The intention is to be able to toggle the visibilities of the individual layer in the map services. However, unlike the dynamic map serivce, there is no method like setVisibleLayers(visibleLayers) in javascript API for a tiled map service. I am not sure toggle the invidual layer in a tiled map service is even possible. Can someone enlighten me on this?
... View more
01-31-2011
06:05 AM
|
0
|
2
|
1075
|
|
POST
|
Hi, I have a local ArcGIS server using which I published a service. The service works using the "Create a Web Application" Wizard. I downloaded a sample code and it ran smoothly, the difference is the URL is online and not local to my server. I want to run this code using my local ArcGIS server URL and all I see is a blank screen. The map is error free. Can anybody help resolve this? My code <html> <head> <script src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.1" type="text/javascript"></script> <link href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.1/js/dojo/dijit/themes/claro/claro.css" rel="stylesheet" type="text/css" > </head> <script type="text/javascript"> dojo.require("esri.map"); var map;' function init() { map=new esri.Map("mapDiv") var basemapURL = "http://8hXXXX:8399/arcgis/rest/services/Map_City/MapServer"; var basemap = new esri.layers.ArcGISDynamicMapServiceLayer(basemapURL); map.addLayer(basemap); } dojo.addOnLoad(init); </script> <body class="caro"> <div id="mapDiv" style="width:900px;height:600px;border:1px solid #000;"></div> </body> </body> </html> Thanks! PS: URL no is censored for security can you view your service in a browser using http://8hXXXX:8399/arcgis/rest/services/Map_City/MapServer?
... View more
01-28-2011
09:14 AM
|
0
|
0
|
1552
|
|
POST
|
Has anyone developed a measure area tool that displays the area 'so far' as you are drawing the polygon graphic? I have got the measure area tool working fine, so when you double click to complete the polygon the area and perimeter are displayed to the user, but they have asked for the tool to update the area and perimeter dynamically as the shape is being drawn, so they know how big to draw a shape of a certain size. I have seen this functionality on other mapping API web sites. Any help would be great, thank you, Mark. Here is an idea maybe you want to consider: when you activate the draw tool, you also activate a map onclick event. this event handler will collect the point you click on the map dynamically. you can store all the points you click in a point collection so that event handler can convert the point collection into a polygon and do the mearsuring. Let me know if you understand what i am saying or not.
... View more
01-28-2011
06:54 AM
|
0
|
0
|
719
|
|
POST
|
For my web application, I have a FeatureSet that returns the attribute table of a feature layer, and in that table, there is a date field (esriFieldTypeDate) that I must print. However, when I try that, I get an 11- to 12-digit integer instead of the typical MM/DD/YYYY date string. The strange thing is, when I use the Query Related Records tool from the ArcGIS Services page, it actually parses the date field correctly... but the source of that page doesn't give any clues as to how it did. So, for instance, I get the following: 51494400000 instead of 1971/08/20 00:00:00 UTC 50889600000 instead of 1971/08/13 00:00:00 UTC 779328000000 instead of 1994/09/12 00:00:00 UTC Is there a pattern I'm not seeing? Is there a special way to parse these integer dates? Thanks using javascript date object to convert milliseconds to string date format like this var date_string= new Date(milliseconds).toUTCString();
... View more
01-28-2011
06:40 AM
|
0
|
0
|
7578
|
|
POST
|
Hi, I have been trying to make this code work for sometime which should have taken me less time than I have spent on it so far. My code looks up a zip code file, selects a zipcode based on user selection. Once selected, it highlights the selected zipcode (mycode works till this point very well) and runs a query on another file to select all census tracts that intersect with the selected zipcode boundary. My code stops short of selecting tracts based on zipcode selection. Any help to resolve this will be great! Here is my code: function QueryByZip(Zip_ID){ map.graphic.clear(); dijit.byId('progress').show(); queryTask= new esri.tasks.QueryTask("http://128.146.162.230/arcgis/rest/services/KC_zipcodes/MapServer/2"); query = new esri.tasks.Query(); query.where = "ZIP = '" + Zip_ID + "'"; query.returnGeometry = true; query.outFields = ["ZIP"]; queryTask.execute(query); dojo.connect(queryTask, "onComplete", zoomToZip); } function zoomToZip(featureSet){ var features = featureSet.features; var zipGraphic; for (var i=0, il=features.length; i<il; i++) { zipGraphic = new esri.Graphic(features); map.graphics.add(zipGraphic.setSymbol(zipSymbol)); } queryTask2= new esri.tasks.QueryTask("http://128.146.162.230/arcgis/rest/services/KingCountyAllOverlaysForQueryNew/MapServer/0"); query2 = new esri.tasks.Query(); query2.geometry = zipGraphic.geometry; query2.spatialRelationship = esri.tasks.Query.SPATIAL_REL_INTERSECTS; query2.returnGeometry = true; queryTask2.execute(query2); dojo.connect(queryTask2, "onComplete", selectTracts); } function selectTracts(featureSet) { var featureTracts = featureSet.features; var tractGraphic; for (var i=0, il=featureTracts.length; i<il; i++) { tractGraphic = new esri.Graphic(featureTracts); map.graphics.add(tractGraphic.setSymbol(highlightSymbol)); } map.setExtent(tractGraphic.geometry.getExtent()); } change these two lines of code: tractGraphic = new esri.Graphic(featureTracts); ---Wrong here map.graphics.add(tractGraphic.setSymbol(highlightS ymbol)); to: tractGraphic =new esri.Graphic(); map.graphics.add(tractGraphic.setGeometry(featureTracts.geometry).setSymbol(highlightSymbol));
... View more
01-26-2011
08:23 AM
|
0
|
0
|
1219
|
| 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
|