|
POST
|
There's a sample in the help that shows how to associate info windows with graphics that might help: http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/map_topo_graphics.html Do you see any errors in the debug console (Firebug or Chrome Developer Tools) when you run your application and click the graphic to display the info window? I have created a simple Dynamic map layer and adding custom graphics by looping through Jason with custom infotemplate. I want to show popup or infowindow with custom info when user clicks on a custom graphics. How to achieve this, I have tried several ways but not able to make it work. My latest code looks like this and it doesn't work. I can see all my custom graphics but nothing is happening when I click on a graphics. <script type="text/javascript"> var djConfig = { parseOnLoad: true }; </script> <script type="text/javascript"> dojo.require("esri.map"); dojo.require("esri.layers.agstiled"); dojo.require("esri.toolbars.draw"); dojo.require("esri.SnappingManager"); dojo.require("esri.toolbars.edit"); dojo.require("dijit.form.Button"); dojo.require("dijit.Menu"); dojo.require("dijit.layout.BorderContainer"); dojo.require("dijit.layout.ContentPane"); dojo.require("esri.dijit.InfoWindowLite"); dojo.addOnLoad(init); var map, tb; function init() { map = new esri.Map("map"); dojo.connect(map, "onLoad", initToolbar); map.infoWindow.resize(200, 75); map.addLayer(new esri.layers.ArcGISDynamicMapServiceLayer("****/ArcGIS/rest/services/Continents/MapServer")); var infoTemplate = new esri.InfoTemplate(); infoTemplate.setTitle("${NAME}"); infoTemplate.setContent("<b>URL Is: </b><a href='https://community.esri.com/test/'>${URL}</a><br/>"); createDynamicGraphicsFromLocation(JasonObj); } function createDynamicGraphicsFromLocation(JasonObj) { var geoValues = JasonObj dojo.forEach(geoValues.split('$'), function (pt, i) { var symbol; var geometryObj; if (pt.split('£')[0] == 'point') { symbol = tb.markerSymbol; geometryObj = new esri.geometry.Point(dojo.fromJson(pt.split('£')[1])); var graphic = new esri.Graphic(geometryObj, symbol); graphic.setAttributes({ "URL": "URLTest" }); graphic.setAttributes({ "Name": "TestName" }); var infoTemplate = new esri.InfoTemplate(); infoTemplate.setTitle("${NAME}"); infoTemplate.setContent("<b>URL Is: </b><a href='https://community.esri.com/test/'>${URL}</a><br/>"); graphic.setInfoTemplate(infoTemplate); map.graphics.add(graphic); } }); }
... View more
01-12-2012
07:58 AM
|
0
|
0
|
649
|
|
POST
|
Chris, In your second example you are trying to add a layer from a feature service without specify the index of the layer to display. Here's an example that shows how to add a feature service layer:
"operationalLayers": [{
"url": "http://sampleserver3.arcgisonline.com/arcgis/rest/services/HomelandSecurity/operations/FeatureServer/2",
"id": "operations_9184",
"visibility": true,
"opacity": 1,
"mode": 1,
"title": "operations - Incident Areas",
"popupInfo": {
"title": "Incident Areas: {ftype}",
"fieldInfos": [{
"fieldName": "objectid",
"label": "Object ID",
"isEditable": false,
"tooltip": "",
"visible": false,
"stringFieldOption": "textbox"
}, {
... View more
01-12-2012
07:48 AM
|
0
|
0
|
2541
|
|
POST
|
You need to wait until the layer is loaded. If this is the basemap you are adding you can listen for the map's onLoad event and check the tileInfo then. Here's a snippet that shows how this works: basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"); dojo.connect(map,'onLoad',function(){ console.log(basemap.tileInfo.lods.length); }) map.addLayer(basemap);
... View more
01-10-2012
07:04 AM
|
0
|
0
|
1060
|
|
POST
|
I haven't tested this but it looks like the following sample from ArcScripts may do what you need: http://arcscripts.esri.com/details.asp?dbid=16528
... View more
01-09-2012
07:06 AM
|
0
|
0
|
2664
|
|
POST
|
Mark Perhaps I don't quite understand what you are trying to do but it sounds like you want to have an item in the basemap gallery that when selected will draw one of the arcgis.com basemaps along with the labels. If so you can modify your code below to define two basemap layers one for the World Terrain basemap and one for the labels. Then you'll create the Basemap and provide both new basemap layers as an array to the layers option: //create Terrain Basemap for Gallery var terrainLayer = new esri.dijit.BasemapLayer({ url: "http://services.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer" }); var labelsLayer = new esri.dijit.BasemapLayer({ url: 'url to labels service', isReference:true }); var terrainBasemap = new esri.dijit.Basemap({ layers: [terrainLayer,labelsLayer], title: 'Terrain with Labels', thumbnailUrl: 'http://www.arcgis.com/sharing/content/items/11742666e55b45b8a508751532d0c1ea/info/thumbnail/Terrain_ne_usa.png' }); basemapGallery.add(terrainBasemap);
... View more
01-06-2012
09:25 AM
|
1
|
0
|
2427
|
|
POST
|
Mark, Another option might be to create a group in ArcGIS.com that contains the basemaps you want to display in the gallery. You can then specify a basemap group (added at 2.6) when creating the basemap gallery.
var basemapGallery = new esri.dijit.BasemapGallery({
showArcGISBasemaps: false,
basemapsGroup:{owner:"esri",title:"Community Basemaps"},
map: map
}, dojo.create('div'));
... View more
01-06-2012
07:56 AM
|
0
|
0
|
2427
|
|
POST
|
The issue described below is a known issue at version 2.6 and should be fixed in the next release (2.7). You can workaround this issue at 2.6 by setting the map's navigation mode to classic:
map = new esri.Map("map",{
extent:initExtent,
navigationMode:'classic'
});
Hi there, this issue is happening in my app as well. I'm using v2.6 and toggling dynamic layers using hide() and show() methods. Steps I'm taking to test: Toggle layer on Wait for layer to display Click to pan on the map or click zoom slider to zoom in or out Layer shifts Pan/zoom ends and the layer returns to correct location. If I use v2.5 I don't get this issue.
... View more
01-05-2012
08:00 AM
|
0
|
0
|
1191
|
|
POST
|
Ben, The upgrade may be as simple as changing the script tags to point to the latest version (2.6) but you may run into some issues. It might be worth leaving a comment on the ArcGIS.com item to ask if the template author has tried to upgrade. http://arcgis.com/home/item.html?id=14290c7441b34ea984ad9310f4cf6435
... View more
01-04-2012
12:54 PM
|
0
|
0
|
1903
|
|
POST
|
Ben, I ran a quick test using the legend dijit along with using esri.request to get the token and the secure service displayed correctly in the legend:
<!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>Accessing secure ArcGIS Server services</title>
<link rel="stylesheet" type="text/css" href="https://serverapi.arcgisonline.com/jsapi/arcgis/2.6/js/dojo/dijit/themes/claro/claro.css">
<link rel="stylesheet" type="text/css" href="security.css">
<style type="text/css">
html, body {
height: 98%; width: 99%;
margin:0;
padding-top:4px;
padding-left:4px;
}
#rightPanel{
width:140px;
border:2px solid #617798;
-webkit-border-top-right-radius: 4px;
-webkit-border-bottom-right-radius: 4px;
-moz-border-radius-topright: 4px;
-moz-border-radius-bottomright: 4px;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
#status {
font-size: 14px;
font-weight:bold;
}
#mapCanvas{
border-top:2px solid #617798;
border-bottom:2px solid #617798;
border-left:2px solid #617798;
-webkit-border-top-left-radius: 4px;
-webkit-border-bottom-left-radius: 4px;
-moz-border-radius-topleft: 4px;
-moz-border-radius-bottomleft: 4px;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
padding:0px;
}
.submit input{
width:auto;
padding: 9px 15px;
background: #617798;
border:0;
font-size:14px;
color:#FFF;
cursor:pointer;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
input{
padding:5px;
border: solid 1px #E5E5E5;
outline:0;
font:normal 13px;
width:120px;
background: #FFFFFF url('bg_form.png') left top repeat-x;
background: -webkit-gradient(linear, left top, left 25, from(#FFFFFF), color-stop(4%, #EEEEEE), to(#FFFFFF));
background: -moz-linear-gradient(top, #FFFFFF, #EEEEEE 1px, #FFFFFF 25px);
box-shadow: rgba(0,0,0, 0.1) 0px 0px 8px;
-moz-box-shadow: rgba(0,0,0, 0.1) 0px 0px 8px;
-webkit-box-shadow: rgba(0,0,0, 0.1) 0px 0px 8px;
}
label{
margin-right:10px;
color:#999;
}
input:hover, textarea:hover,
input:focus, textarea:focus {
border-color: #C9C9C9;
-webkit-box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 8px;
}
</style>
<script type="text/javascript">
var dojoConfig = { parseOnLoad: true };
</script>
<script type="text/javascript" src="https://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.4"></script>
<script type="text/javascript">
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("esri.map");
dojo.require("esri.layers.FeatureLayer");
dojo.require("esri.dijit.Legend");
dojo.addOnLoad(initialize);
// Global variables
var map,resizeTimer;
function initialize() {
//check to see if browser supports placeholder text - if not enable labels for username and
//password form.
if(!supportsPlaceholder()){
esri.show(dojo.byId('passwordLabel'));
esri.show(dojo.byId('nameLabel'));
}
esri.config.defaults.io.proxyUrl = "proxy/proxy.php";
// Create map
map = new esri.Map("mapCanvas",{
extent: new esri.geometry.Extent({"xmin":-12080521,"ymin":4472736,"xmax":-11829657,"ymax":4563023,"spatialReference":{"wkid":3857}}),
slider: false
});
dojo.connect(map, "onLoad", mapLoaded);
// Add a cached map service
var basemap = new esri.layers.ArcGISTiledMapServiceLayer("https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer");
map.addLayer(basemap);
//add the map service to the map - this layer doesn't require a token
var trailsService = new esri.layers.ArcGISDynamicMapServiceLayer("https://servicesbeta.esri.com/ArcGIS/rest/services/SanJuan/Trails/MapServer");
map.addLayer(trailsService);
}
function mapLoaded() {
esri.hide(dojo.byId("status"));
dojo.connect(dojo.byId("username"), "onkeypress", keyPressed);
dojo.connect(dojo.byId("password"), "onkeypress", keyPressed);
dojo.connect(dijit.byId('mapCanvas'), 'resize', function() {
resizeMap();
});
}
function signIn() {
// Check if the user has entered username and password
var usr = dojo.byId("username").value, pwd = dojo.byId("password").value;
if (!usr || !pwd) {
return;
}
dojo.byId("signInStatus").innerHTML = "Creating token...";
// Get token from the ArcGIS Server Token Service.
//
esri.request({
url: "https://servicesbeta.esri.com/ArcGIS/tokens",
content: {
request: "getToken",
username: usr,
password: pwd
},
handleAs: "text",
load: tokenObtained,
error: tokenRequestFailed
});
}
function tokenObtained(response) {
dojo.byId("signInStatus").innerHTML = "Token created. Accessing the service...";
// Add the secure feature service to the map
// Note that the token is appended to the URL
// when constructing the layer.
var featureLayerURL = "https://servicesbeta.esri.com/ArcGIS/rest/services/SanJuan/TrailConditions/MapServer/0?token=" + response;
var infoTemplate = new esri.InfoTemplate("Current Conditions", "${Condition} incident updated on ${UpdateDate:DateFormat(selector: 'date', fullYear: true)}. ${Description}");
var conditions = new esri.layers.FeatureLayer(featureLayerURL,{
infoTemplate:infoTemplate,
outFields:["*"]
});
conditions.setDefinitionExpression("Description != ''");
dojo.connect(conditions, "onLoad", function() {
setTimeout(function() {
// closeSignInForm();
dojo.byId("signInStatus").innerHTML = "";
}, 1500);
});
dojo.connect(conditions, "onError", function(error) {
dojo.byId("signInStatus").innerHTML = "Error: " + error.message;
});
dojo.connect(map,'onLayerAddResult',function(results){
console.log('added');
//add legend
var legendDijit = new esri.dijit.Legend({
map:map
},"legendDiv");
legendDijit.startup();
});
map.addLayers([conditions]);
map.infoWindow.resize(200,120);
}
function tokenRequestFailed(error) {
dojo.byId("signInStatus").innerHTML = "Unable to create token. Please check your username/password";
}
function keyPressed(e) {
if (e.charOrCode === dojo.keys.ENTER) {
signIn();
}
}
//Handle resize of browser
function resizeMap(){
clearTimeout(resizeTimer);
resizeTimer = setTimeout(function(){
map.resize();
map.reposition();
}, 500);
}
function supportsPlaceholder() {
// An alternative to this test would be to use a javascript library like
//Modernizr that detects support for HTML5 and CSS3 functionality.
var i = document.createElement('input');
return 'placeholder' in i;
}
function disableSignInForm() {
dojo.byId("username").value = "";
dojo.byId("password").value = "";
var node = dojo.byId("content"), box = dojo.contentBox(node);
dojo.style(node, { top: 0, opacity: 1 });
var hideAnimation = dojo.animateProperty({
node: node,
duration: 500,
properties: { top: -1 * box.h, opacity: 0 }
});
hideAnimation.play();
}
</script>
</head>
<body class="claro">
<div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="design:'headline',gutters:false" style="position:relative;width:100%;height:100%;">
<div id="mapCanvas" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'center'" >
<span id="status" style="position: absolute; z-index: 99; right: 5px; top: 5px;">
Loading...
</span>
</div>
<div id='centerPanel' data-dojo-type='dijit.layout.ContentPane' data-dojo-props="region:'left'" style='width:200px;'>
<div>
<h3>Legend</h3>
<div id='legendDiv'></div>
</div>
</div>
<!--right content panel-->
<div id="rightPanel" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'right'">
<p>This sample shows how to view a secure map service using token-based authentication.</p>
<div id="content" >
<p>To view current trail conditions sign in with user name: <b>rick</b> and password:<b>rick@esri</b></p>
<p class="username">
<label style="display:none;" for="username" id="nameLabel">Name</label>
<input placeholder="Username" type="text" name="username" id="username" />
</p>
<p class="password">
<label style="display:none;" id="passwordLabel" for="password">Password</label>
<input placeholder="Password" type="password" name="password" id="password" />
</p>
<p class="submit">
<input type="submit" id="signIn" onclick="signIn();" value="Sign In" autofocus/>
</p>
</div>
<span id="signInStatus"></span>
</div>
</div>
</body>
</html>
Can you provide more details about your scenario?
... View more
01-04-2012
09:02 AM
|
0
|
0
|
1271
|
|
POST
|
Feature layers in selection mode only display the currently selected features. Its a great option to use if you want to select features using the selectFeatures method. To display features without a selection use either the Snapshot or OnDemand modes. The FeatureLayer API doc has details on each of the modes. http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/featurelayer.htm
... View more
01-04-2012
08:21 AM
|
0
|
0
|
537
|
|
POST
|
Ben It looks like that template is using Version 2.2 of the ArcGIS API for JavaScript. IE9 support started at version 2.3 so you can run the application in compatability mode like you are now or upgrade the app to version 2.3. Blog post regarding IE9 support at version 2.3. http://blogs.esri.com/Dev/blogs/arcgisserver/archive/2011/04/04/test.aspx
... View more
01-03-2012
01:34 PM
|
0
|
0
|
1903
|
|
POST
|
Which template and which version of Internet Explorer?
... View more
01-03-2012
09:40 AM
|
0
|
0
|
1903
|
|
POST
|
Looks like there was a logic error in the application. I fixed it in the attached version. Note: This version still uses the alpha version of jQueryMobile. I'll update to the latest version after the holiday break.
... View more
12-22-2011
02:39 PM
|
0
|
0
|
1323
|
|
POST
|
We recently updated that sample to use the latest version of jQueryMobile and it looks like that broke some of the functionality. We'll look at the sample and resolve any issues as soon as possible. In the meantime I've attached a working version that uses an alpha version of jQueryMobile:
... View more
12-22-2011
12:15 PM
|
0
|
0
|
1323
|
|
POST
|
Jason, Here's a link to a sample that shows how to add and remove features from the current selection. In this example click on the map to select features then shift-click to remove features from the selection. http://jsfiddle.net/J4sfK/
dojo.connect(neighborhoods,'onClick',function(e){
var query = new esri.tasks.Query();
query.objectIds = [e.graphic.attributes.FID];
//if shift key is pressed subtract from selection - otherwise add
if(e.shiftKey){
neighborhoods.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_SUBTRACT);
}else{
neighborhoods.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_ADD);
}
});
... View more
12-22-2011
06:42 AM
|
0
|
0
|
1116
|
| 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 |
Tuesday
|