|
POST
|
Version 2.6 of the ArcGIS API for JavaScript released today. View the blog post for details: http://esriurl.com/3428 For those who need the local download it will be available in a few days. I'll post back on this thread once it is ready.
... View more
12-14-2011
07:30 AM
|
0
|
6
|
1890
|
|
POST
|
One way to accomplish this would be to use the Navigation toolbar. Here's a link to a sample: http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/toolbar_navigation.html
... View more
12-13-2011
01:42 PM
|
0
|
0
|
1214
|
|
POST
|
Keith, In my testing it looks like some locators return an error. For example if I test with the locator you are using: http://tasks.arcgisonline.com/ArcGIS/rest/services/Locators/TA_Address_NA_10/GeocodeServer Then an error is thrown when no addresses are matched. You can catch this using the following code:
dojo.connect(map, "onClick", function(evt) {
map.graphics.clear();
var def = locator.locationToAddress(esri.geometry.webMercatorToGeographic(evt.mapPoint), 100);
def.then(function(candidate){
if (candidate.address) {
//this service returns geocoding results in geographic - convert to web mercator to display on map
var location = esri.geometry.geographicToWebMercator(candidate.location);
var graphic = new esri.Graphic(location, symbol, candidate.address, infoTemplate);
map.graphics.add(graphic);
map.infoWindow.setTitle(graphic.getTitle());
map.infoWindow.setContent(graphic.getContent());
//display the info window with the address information
var screenPnt = map.toScreen(location);
map.infoWindow.resize(200,100);
map.infoWindow.show(screenPnt,map.getInfoWindowAnchor(screenPnt));
}
else{
//no address found
console.log("No address found for this location");
}
}, function(error){
console.log("error: " + error.message);
});
});
However if you use this locator: http://tasks.arcgis.com/ArcGIS/rest/services/WorldLocator/GeocodeServer" Then the code I posted earlier should work. Let me know if this is not the case in your testing .
... View more
12-09-2011
08:51 AM
|
0
|
0
|
3072
|
|
POST
|
Sorry about the geocode/reversegeocode confusion. Here's a snippet that shows how to determine if no address is found when performing a reverse geocode:
dojo.connect(map, "onClick", function(evt) {
map.graphics.clear();
var def = locator.locationToAddress(esri.geometry.webMercatorToGeographic(evt.mapPoint), 100);
def.then(function(candidate){
if (candidate.address) {
//this service returns geocoding results in geographic - convert to web mercator to display on map
var location = esri.geometry.geographicToWebMercator(candidate.location);
var graphic = new esri.Graphic(location, symbol, candidate.address, infoTemplate);
map.graphics.add(graphic);
map.infoWindow.setTitle(graphic.getTitle());
map.infoWindow.setContent(graphic.getContent());
//display the info window with the address information
var screenPnt = map.toScreen(location);
map.infoWindow.resize(200,100);
map.infoWindow.show(screenPnt,map.getInfoWindowAnchor(screenPnt));
}
else{
//no address found
console.log("No address found for this location");
}
});
});
... View more
12-09-2011
07:19 AM
|
0
|
0
|
3072
|
|
POST
|
Try defining your popup template like this:
var popupTemplate = new esri.dijit.PopupTemplate({
title: "{address}",
fieldInfos: [
{fieldName: "req_type", label:'Request Type', visible:true},
{fieldName: "req_date", label:'Request Date',visible:true,format:{dateFormat:'shortDateShortTime'}}
],
showAttachments:true
});
... View more
12-08-2011
12:39 PM
|
0
|
0
|
758
|
|
POST
|
Keith, The callback (onAddressToLocationsComplete) does fire when there aren't any candidates. Here's a snippet that shows one way to check for no results:
function locate() {
map.graphics.clear();
var address = {"SingleLine":dojo.byId("address").value};
locator.outSpatialReference= map.spatialReference;
locator.addressToLocations(address,["Loc_name"]);
}
function showResults(candidates) {
if(candidates.length === 0){
alert('no candidates');
}
}
... View more
12-08-2011
12:37 PM
|
0
|
0
|
3072
|
|
POST
|
You can define the content for the info window or popup by providing a function that can calculate the value. The 'Format info window content' help topic has details on the various options. http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp/intro_formatinfowindow.htm Here's an example of how you can use a custom formatting function to determine if a field is null. If its not null you can display a value and if null you can display different text. This code snippet defines an info template with a custom formatting function called calculateDeaths that determines if the Num_Deaths field has a value.
var infoTemplate = new esri.InfoTemplate("${Name}");
infoTemplate.setTitle("${Name}");
infoTemplate.setContent("Magnitude ${Magnitude:NumberFormat(round:2)} earthquake occurred on ${Date_:DateFormat(datePattern:'MMMM d, yyyy.', selector:'date')}<br/>Deaths: ${Num_Deaths:calculateDeaths}" );
Here's what the function looks like:
function calculateDeaths(value,key,data){
return data.Num_Deaths !== null ? data.Num_Deaths : 'No Deaths';
}
Alternatively you can use a function to define the entire window's content so if you like you can not display null values. Here's a code snippet showing how you can define an info template that uses a function to display content: var infoTemplate = new esri.InfoTemplate();
infoTemplate.setTitle("${Name}");
infoTemplate.setContent(getContent); And here's the function that defines the content:
function getContent(graphic){
var numInjured = graphic.attributes.Num_Injured;
var numDeaths = graphic.attributes.Num_Deaths !== null ? graphic.attributes.Num_Deaths : 'No Deaths';
var content = "<b>Magnitude: </b>" + graphic.attributes.Magnitude + "<br/><b>Deaths: </b> " + numDeaths ;
if(numInjured !== null){
content += "<br/><b>Injured: </b>" + numInjured;
}
return content;
}
... View more
12-05-2011
06:19 AM
|
0
|
0
|
728
|
|
POST
|
Steve, Sorry for the delay in responding - somehow I missed the responses to this thread. Will this approach work for you? <head>
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.4">
</script>
<link href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.4/js/dojo/dijit/themes/claro/claro.css"
rel="stylesheet" type="text/css">
<link rel="stylesheet" type='text/css' href='http://serverapi.arcgisonline.com/jsapi/arcgis/2.4/js/esri/dijit/css/Popup.css'
/>
<title>
popup test
</title>
<script type="text/javascript">
dojo.require("esri.map");
dojo.require("esri.layers.FeatureLayer");
function init() {
var spatialRef = new esri.SpatialReference({
wkid: 102113
});
var startExtent = new esri.geometry.Extent();
startExtent.xmin = -3474427;
startExtent.ymin = 3213361;
startExtent.xmax = 3409296;
startExtent.ymax = 11057509;
startExtent.SpatialReference = spatialRef;
var map = new esri.Map("mapDiv", {
extent: startExtent
});
map.setExtent(startExtent);
var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer");
map.addLayer(basemap);
var biotemplate = new esri.InfoTemplate();
biotemplate.setTitle("<b>HTML Popup Test</b>");
/*biotemplate.setContent("<iframe src='http://discomap.eea.europa.eu/ArcGIS/rest/services/Bio/LifeProjects_Dyna_WGS84/MapServer/0/${OBJECTID}/htmlPopup?f=html' frameborder='0' width='100%' height='100%' style='width: 100%; height: 100%; display: block; padding: 0px; margin: 0px;'></iframe>");*/
biotemplate.setContent(updatePopup);
var bioLayer = new esri.layers.FeatureLayer("http://discomap.eea.europa.eu/ArcGIS/rest/services/Bio/LifeProjects_Dyna_LAEA/MapServer/0", {
infoTemplate: biotemplate
});
map.addLayer(bioLayer);
var oiltemplate = new esri.InfoTemplate();
oiltemplate.setTitle("<b>HTML Popup Test</b>");
oiltemplate.setContent("<iframe src='http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/StantonCountyKSLeases/MapServer/0/${OBJECTID}/htmlPopup?f=html' frameborder='0' width='100%' height='100%' style='width: 100%; height: 100%; display: block; padding: 0px; margin: 0px;'></iframe>");
var oilLayer = new esri.layers.FeatureLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/StantonCountyKSLeases/MapServer/0", {
infoTemplate: oiltemplate
});
map.addLayer(oilLayer);
map.infoWindow.resize(600, 300);
}
function updatePopup(graphic){
var deferred = new dojo.Deferred();
var url = graphic.getLayer().url + "/" + graphic.attributes.OBJECTID + "/htmlPopup?f=json";
esri.request({
url: url,
content:url.query,
callbackParamName: "callback",
load: function(response) {
//esriServerHTMLPopupTypeAsURL
deferred.callback( "<iframe src='" + response.content +"' frameborder='0' width='100%' height='100%' style='width: 100%; height: 100%; display: block; padding: 0px; margin: 0px;'></iframe>");
},
error: function(error) {
deferred.errback("Error occurred while generating profile");
}
});
return deferred;
return requestHandle;
}
dojo.addOnLoad(init);
</script>
</head>
<body class="claro">
<div id="head">
</div>
<div id="mapDiv" style="width:100%; height:90%; border:1px solid #000;">
</div>
</body>
... View more
12-02-2011
08:42 AM
|
0
|
0
|
2023
|
|
POST
|
Matt, Here's a revised version of the code. The bike routes were added to the map as a DynamicMapServiceLayer. I also modified the extent so that the map opened zoomed into San Antonio. Since the basemap (World_Topo) is in Web Mercator (102100) I specified the San Antonio extent using coordinates that are valid for Web Mercator.
<!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,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>
</title>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.5/js/dojo/dijit/themes/claro/claro.css">
<style type="text/css">
html, body { height: 100%; width: 100%; margin: 0; padding: 0; }
#map{
padding:0;
}
</style>
<script type="text/javascript">
var djConfig = {
parseOnLoad: true
};
</script>
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.5"></script>
<script type="text/javascript">
dojo.require("dijit.dijit"); // optimize: load dijit layer
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("esri.map");
dojo.require("esri.virtualearth.VETiledLayer");
dojo.require("dijit.TitlePane");
dojo.require("esri.dijit.BasemapGallery");
dojo.require("esri.arcgis.utils");
var map = null;
function init() {
var initExtent = new esri.geometry.Extent({"xmin":-11123269.230112463,"ymin":3379128.146430188,"xmax":-10804373.948106863,"ymax":3478190.535087729,"spatialReference":{"wkid":102100}});
map = new esri.Map("map",{extent:initExtent});
var initBasemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer");
map.addLayer(initBasemap);
var bikeRoutes = new esri.layers.ArcGISDynamicMapServiceLayer("https://gis.sanantonio.gov/ArcGIS/rest/services/BikeFacilities/MapServer");
map.addLayer(bikeRoutes);
createBasemapGallery();
//resize the map when the browser resizes
dojo.connect(dijit.byId('map'), 'resize', map,map.resize);
}
function createBasemapGallery() {
//add the basemap gallery, in this case we'll display maps from ArcGIS.com including bing maps
var basemapGallery = new esri.dijit.BasemapGallery({
showArcGISBasemaps: true,
bingMapsKey: 'Enter your Bing Maps Key',
map: map
}, "basemapGallery");
basemapGallery.startup();
dojo.connect(basemapGallery, "onError", function(msg) {console.log(msg)});
}
//show map on load
dojo.addOnLoad(init);
</script>
</head>
<body class="claro">
<div dojotype="dijit.layout.BorderContainer" design="headline" gutters="false" style="width:100%;height:100%;margin:0;">
<div id="map" dojotype="dijit.layout.ContentPane" region="center" style="border:1px solid #000;padding:0;">
<div style="position:absolute; right:20px; top:10px; z-Index:999;">
<div dojoType="dijit.TitlePane" title="Switch Basemap" closable="false" open="false">
<div dojoType="dijit.layout.ContentPane" style="width:380px; height:280px; overflow:auto;">
<div id="basemapGallery" ></div></div>
</div>
</div>
</div>
</div>
</body>
</html>
... View more
12-01-2011
07:30 AM
|
0
|
0
|
495
|
|
POST
|
Don, The code works for me (both the buffer and the query. Have you tried adding breakpoints to your code to see if the buffer is successful. You can also view the requests in the net tab to see if the buffer and query were successful.
... View more
12-01-2011
07:22 AM
|
0
|
0
|
1417
|
|
POST
|
This is a bug at 2.5, you should be able to workaround this issue like this:
esri.hide(measurement[�??location�?�].domNode).
... View more
12-01-2011
07:13 AM
|
0
|
0
|
488
|
|
POST
|
In my testing it works fine with both in IE. I do not get cross domain errors. Here's a running test case: http://jsfiddle.net/4gLJR/
... View more
12-01-2011
07:11 AM
|
0
|
0
|
752
|
|
POST
|
You need to create the djConfig object before including the dojo core (comes with ArcGIS API for JavaScript). Here's a modified version of your code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html dir="ltr">
<head>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.5/js/dojo/dijit/themes/claro/claro.css"
/>
<style type="text/css">
body, html { font-family:helvetica,arial,sans-serif; font-size:90%; }
</style>
<script type="text/javascript">var djConfig = {parseOnLoad: true};</script>
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.5"></script>
<script type="text/javascript">
dojo.require("dijit.TitlePane");
</script>
</head>
<body class=" claro ">
<div id="tp2" dojoType="dijit.TitlePane" title="I'm a TitlePane Too">
Click arrow to close me.
</div>
</body>
</html>
... View more
11-30-2011
01:10 PM
|
0
|
0
|
752
|
|
POST
|
Is the url to your service public? If so can you share?
... View more
11-30-2011
06:31 AM
|
0
|
0
|
987
|
|
POST
|
Have you tried using the featureLayer.getSelectedFeatures method? This method returns an array of graphics for all the selected features in the feature layer.
... View more
11-30-2011
06:30 AM
|
0
|
0
|
1100
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 03-31-2026 08:27 AM | |
| 1 | 03-26-2026 09:07 AM | |
| 1 | 03-26-2026 10:11 AM | |
| 1 | 03-24-2026 02:23 PM | |
| 1 | 03-17-2026 02:50 PM |
| Online Status |
Offline
|
| Date Last Visited |
yesterday
|