|
POST
|
You can display the popup without user interaction using map.infoWindow.show. Here's a short snippet that displays address information in a popup.
geom = candidate.location;
map.infoWindow.setTitle("Location");
map.infoWindow.setContent(candidate.address);
map.infoWindow.show(geom);.
... View more
08-10-2011
07:09 AM
|
0
|
0
|
812
|
|
POST
|
Along with the things Derek mentioned,here are a few more things to check. Firefox and Chrome will deal with things like trailing commas and missing semi-colons at the end of lines but IE will not. In your posted code (around line 54) this line is missing a semi-colon at the end:
symbol = new esri.symbol.PictureMarkerSymbol('./images/defectmarker.png', 30,60).setOffset(0,30)
JSLint is a good tool to use to identify potential issues. The tool will point out lots of issues in the code including missing semicolons and trailing commas. http://www.jslint.com/
... View more
08-04-2011
08:05 AM
|
0
|
0
|
1910
|
|
POST
|
Esri uses the Dijit themes to provide style for the widgets. Details on the available dijit themes can be found here: http://dojotoolkit.org/reference-guide/dijit/themes.html
... View more
08-02-2011
12:58 PM
|
0
|
0
|
522
|
|
POST
|
Popup and PopupMobile work with a set of features. Modify your code to listen for the feature layer's on click event and when it fires associate the current features with the popup.
greenLayer = new esri.layers.FeatureLayer(greenURL,{
mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
outFields: ["*"],
infoTemplate:popupTemplate
});
//associate the features with the popup on click
dojo.connect(greenLayer,"onClick",function(evt){
map.infoWindow.setFeatures([evt.graphic]);
});
map.addLayer(greenLayer);
... View more
07-25-2011
12:18 PM
|
0
|
0
|
1454
|
|
POST
|
You may also want to check out the Measurement Widget. This widget was released at version 2.3 of the ArcGIS API for JavaScript and allows you to measure area and lengths. Here's a link to a sample showing how to use the widget: http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/widget_measurement.html
... View more
07-18-2011
12:28 PM
|
0
|
0
|
1350
|
|
POST
|
Try running the local version of your application in either Firefox with Firebug enabled or Chrome with Chrome Developer Tools open. View the NET (firebug) or Network(Chrome Developer Tools) portion and run the application to see if the requests to the geometry service project and lengths operations complete successfully.
... View more
07-18-2011
12:26 PM
|
0
|
0
|
1350
|
|
POST
|
Thanks for pointing out the typo we'll get that fixed asap.
... View more
07-18-2011
09:36 AM
|
0
|
0
|
355
|
|
POST
|
Here's an example that shows using the PopupMobile with the PopupTemplate:
<!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>
Flickr
</title>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.4/js/dojo/dijit/themes/claro/claro.css"/>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.4/js/esri/dijit/css/Popup.css"/>
<link rel="stylesheet" type='text/css' href='http://serverapi.arcgisonline.com/jsapi/arcgis/2.4/js/esri/dijit/css/PopupMobile.css'/>
<style>
html, body { height: 100%; width: 100%; margin: 0; padding: 0; } .esriScalebar{
padding: 20px 20px; } #map{ padding:0;}
</style>
<script type="text/javascript">
var dojoConfig = {
parseOnLoad: true
};
</script>
<script type="text/javascript" src="http://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.Popup");
dojo.require("esri.dijit.PopupMobile");
var map;
var featureLayer;
var resizeTimer;
function init() {
//setup the map's initial extent
var initExtent = new esri.geometry.Extent({"xmin":-16305479,"ymin":-635073,"xmax":5884495,"ymax":8307447,"spatialReference":{"wkid":102100}});
//create a popup to replace the map's info window
var popup = new esri.dijit.PopupMobile(null, dojo.create("div"));
map = new esri.Map("map", {
extent: initExtent,
infoWindow: popup
});
dojo.place(popup.domNode, map.root);
//Add the imagery layer to the map. View the ArcGIS Online site for services http://arcgisonline/home/search.html?t=content&f=typekeywords:service
var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer");
map.addLayer(basemap);
//create a feature collection for the flickr photos
var featureCollection = {
"layerDefinition": null,
"featureSet": {
"features": [],
"geometryType": "esriGeometryPoint"
}
};
featureCollection.layerDefinition = {
"geometryType": "esriGeometryPoint",
"objectIdField": "ObjectID",
"drawingInfo": {
"renderer": {
"type": "simple",
"symbol": {
"type": "esriPMS",
"url": "images/flickr.png",
"contentType": "image/png",
"width": 15,
"height": 15
}
}
},
"fields": [{
"name": "ObjectID",
"alias": "ObjectID",
"type": "esriFieldTypeOID"
},{
"name": "description",
"alias": "Description",
"type": "esriFieldTypeString"
},{
"name": "title",
"alias": "Title",
"type": "esriFieldTypeString"
}]
};
//define a popup template
var popupTemplate = new esri.dijit.PopupTemplate({
title: "{title}",
description:"{description}"
});
//create a feature layer based on the feature collection
featureLayer = new esri.layers.FeatureLayer(featureCollection, {
id: 'flickrLayer',
infoTemplate: popupTemplate
});
//associate the features with the popup on click
dojo.connect(featureLayer,"onClick",function(evt){
map.infoWindow.setFeatures([evt.graphic]);
map.infoWindow.show(evt.mapPoint);
});
dojo.connect(map,"onLayersAddResult",function(results){requestPhotos();});
//add the feature layer that contains the flickr photos to the map
map.addLayers([featureLayer]);
//resize the map when the browser resizes - view the 'Resizing and repositioning the map' section in
//the following help topic for more details http://help.esri.com/EN/webapi/javascript/arcgis/help/jshelp_start.htm#jshelp/inside_guidelines.htm
dojo.connect(map, 'onLoad', function(theMap) {
dojo.connect(dijit.byId('map'), 'resize', function() { //resize the map if the div is resized
clearTimeout(resizeTimer);
resizeTimer = setTimeout(function() {
map.resize();
map.reposition();
}, 500);
});
});
}
function requestPhotos(){
//get geotagged photos from flickr
//tags=flower&tagmode=all
var requestHandle = esri.request({
url: "http://api.flickr.com/services/feeds/geo?&format=json",
callbackParamName: "jsoncallback",
load: requestSucceeded,
error: requestFailed
}, {
useProxy: false
});
}
function requestSucceeded(response, io) {
//loop through the items and add to the feature layer
var features = [];
dojo.forEach(response.items, function(item) {
var attr = {};
attr["description"] = item.description;
attr["title"] = item.title ? item.title : "Flickr Photo";
var geometry = esri.geometry.geographicToWebMercator(new esri.geometry.Point(item.longitude, item.latitude, map.spatialReference));
var graphic = new esri.Graphic(geometry);
graphic.setAttributes(attr);
features.push(graphic);
});
featureLayer.applyEdits(features, null, null);
}
function requestFailed(error) {
console.log('failed');
}
dojo.ready(init);
</script>
</head>
<body class="claro">
<div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="design:'headline'"
style="width: 100%; height: 100%; margin: 0;">
<div id="map" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'center'"
style="border:1px solid #000;padding:0;">
</div>
</div>
</body>
</html>
... View more
07-18-2011
09:36 AM
|
0
|
0
|
1454
|
|
POST
|
The sample you refer to uses a proxy page - you will need to setup one locally then modify the following line in the code to point to your proxy page: esriConfig.defaults.io.proxyUrl = "proxy.ashx"; Instructions for setting up a proxy page can be found here: http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp/ags_proxy.htm
... View more
07-18-2011
09:25 AM
|
0
|
0
|
1350
|
|
POST
|
Version 2.4 of the ArcGIS API for JavaScript released today. Check out the server blog for more details: http://blogs.esri.com/Dev/blogs/arcgisserver/default.aspx
... View more
07-08-2011
11:46 AM
|
0
|
1
|
840
|
|
POST
|
You need to update the map's size and position. Try adding the map.resize and map.reposition to your expand and hide functions:
function expand(){
document.getElementById('expand').style.height='110px';
map.resize();
map.reposition();
}
... View more
07-07-2011
05:17 PM
|
0
|
0
|
668
|
|
POST
|
The map's graphics layer is available after the map loads. So try moving the code that adds the route and sets up snapping into the map's onLoad event.
function init() {
var options = {
extent: new esri.geometry.Extent({
xmin: 1191657,
ymin: 8383658,
xmax: 1196348,
ymax: 8386042,
spatialReference: {
wkid: 102113
}
})
};
var map = new esri.Map("map", options);
dojo.connect(map,"onLoad",addRoute);
//Creates the Virtual Earth layer to add to the map
veTileLayer = new esri.virtualearth.VETiledLayer({
bingMapsKey: 'Av1bH4keF8rXBtxWOegklgWGCYYz8UGYvBhsWKuvc4Z15kT76xVFOERk8jkKEDvT',
mapStyle: esri.virtualearth.VETiledLayer.MAP_STYLE_ROAD
});
map.addLayer(veTileLayer);
}
function addRoute(map){
var route = new esri.geometry.Polyline(new esri.SpatialReference({wkid:102113}));
route.addPath([[1191657,8383658], [1196348,8386042]]);
var routeStyle = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0,0,255]), 3);
var graphic = new esri.Graphic(route, routeStyle);
var routeLayer = new esri.layers.GraphicsLayer({opacity:0.80});
routeLayer.add(graphic);
map.addLayer(routeLayer);
var snappingManager = new esri.SnappingManager({
alwaysSnap: true,
layerInfos: [{layer:routeLayer}],
map: map
});
}
... View more
07-05-2011
07:44 AM
|
0
|
0
|
571
|
|
POST
|
Mark, This sample uses a custom operation: http://help.arcgis.com/en/webapi/javascript/arcgis/demos/graphics/graphics_undoredo.html You can view the custom operation code here: http://help.arcgis.com/en/webapi/javascript/arcgis/demos/graphics/myModules/customOperation.js
... View more
07-03-2011
10:29 PM
|
0
|
0
|
1143
|
|
POST
|
Each basemap that you add to the basemap gallery needs to have the same spatial reference. So if you are using the default basemaps from ArcGIS.com then any additional basemaps that you add need to be in Web Mercator. I have, but it results in some funny behavior, which I'm sure has to do with the spatial reference... I am just unsure how to manipulate the extent from web mercator to UTM. function init() {
/* Set Extent and Create Map Constructor */
var extent = new esri.geometry.Extent({
"xmin": -75.35,
"ymin": 41.6,
"xmax": -74.06,
"ymax": 42.75,
"spatialReference": {
"wkid": 4269
}
});
map = new esri.Map("map", {
extent: esri.geometry.geographicToWebMercator(extent)
});
/* Add Basemap */
var basemapUrl = "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer";
var basemapInitial = new esri.layers.ArcGISTiledMapServiceLayer(basemapUrl);
map.addLayer(basemapInitial);
/* AA - Create Basemap Gallery */
createBasemapGallery();
...
/* AA */
function createBasemapGallery(){
/* ESRI World Street Map */
var layerStreet = new esri.dijit.BasemapLayer({
url:"http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"
});
var basemapStreet = new esri.dijit.Basemap({
layers: [layerStreet],
title: "ESRI Street Map"
});
basemaps.push(basemapStreet);
/* New Basemap */
var newBaselayer = new esri.dijit.BasemapLayer({
url:"http://host/ArcGIS/rest/services/myservice/MapServer",
visibleLayers:[2]
});
var newBasemap = new esri.dijit.Basemap({
layers: [newBaselayer],
title: "Other Basemap"
});
basemaps.push(newBasemap);
/* Create Gallery and Populate Drop Down Menu */
basemapGallery = new esri.dijit.BasemapGallery({
showArcGISBasemaps: false,
basemaps: basemaps,
map: map
});
dojo.forEach(basemapGallery.basemaps, function(basemap){
dijit.byId("basemapMenu").addChild(new dijit.MenuItem({
label: basemap.title,
onClick: dojo.hitch(this, function(){
this.basemapGallery.select(basemap.id);
})
}));
}); So at first things are fine, and then when I switch base maps, the new (which is on a different map service and has a different spatial projection (UTM)) basemap zooms to the full extent, actually somewhat further out than that. If I then switch back to the ESRI world street map, it zooms me to a place in the Mediterranean Sea. Could anyone explain this behavior? Will I need to convert the units everytime my basemap changes? Thanks, DR
... View more
06-28-2011
06:13 AM
|
0
|
0
|
918
|
|
POST
|
One approach to workaround this issue is to add a basemap with more zoom levels before creating the basemap gallery. In this snippet the World Topo Map is added so the map will be initialized with more levels: var initBasemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer");
map.addLayer(initBasemap);
createBasemapGallery();
... View more
06-24-2011
09:42 AM
|
0
|
0
|
880
|
| 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 |
Wednesday
|