|
POST
|
I'm a little late on this one but I was curious so I gave this a shot. Try this: <!DOCTYPE html>
<html>
<head>
<title>...</title>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.1/js/dojo/dijit/themes/claro/claro.css">
<style>
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.1"></script>
<script type="text/javascript">
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("esri.map");
var map;
var drag = {};
function init() {
var initExtent = new esri.geometry.Extent({"xmin":-13632648,"ymin":4542594,"xmax":-13621699,"ymax":4546875,"spatialReference":{"wkid":102100}});
map = new esri.Map("map",{extent:initExtent});
var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer");
map.addLayer(basemap);
var resizeTimer;
dojo.connect(map, 'onLoad', function(theMap) {
map.addLayer(new esri.layers.GraphicsLayer({ id: 'ctrl_drag' }));
dojo.connect(dijit.byId('map'), 'resize', function() {
clearTimeout(resizeTimer);
resizeTimer = setTimeout( function() {
map.resize();
map.reposition();
}, 500);
});
// listen to various events to draw a graphic when the ctrl key is held down
dojo.connect(map, "onMouseDragStart", drag_start);
dojo.connect(map, "onMouseDragEnd", drag_stop);
dojo.connect(map, "onMouseDrag", dragging);
// IE doesn't play nice attaching onkeyup/onkeydown to the window object...
var key_event_handle = dojo.isIE ? dojo.query('body')[0] : window;
dojo.connect(key_event_handle, "onkeydown", function(evt) {
if (evt.ctrlKey || evt.keyCode == 17) {
map.disablePan();
}
});
dojo.connect(key_event_handle, "onkeyup", function(evt) {
if (evt.ctrlKey || evt.keyCode == 17) {
map.enablePan();
}
});
});
}
function drag_start(evt) {
if (evt.ctrlKey) {
map.getLayer('ctrl_drag').clear();
if (check_drag_graphic()) {
delete drag.drag_graphic;
}
drag.start = evt.mapPoint;
}
}
function drag_stop(evt) {
if (evt.ctrlKey) {
drag.stop = evt.mapPoint;
build_rect();
}
}
function dragging(evt) {
if (evt.ctrlKey || evt.keyCode == 17) {
drag.stop = evt.mapPoint;
build_rect();
}
}
function build_rect() {
var xmin = drag.start.x < drag.stop.x ? drag.start.x : drag.stop.x;
var ymin = drag.start.y < drag.stop.y ? drag.start.y : drag.stop.y;
var xmax = drag.start.x > drag.stop.x ? drag.start.x : drag.stop.x;
var ymax = drag.start.y > drag.stop.y ? drag.start.y : drag.stop.y;
var box = new esri.geometry.Extent({
'xmin': xmin, 'ymin': ymin, 'xmax': xmax, 'ymax': ymax, 'spatialReference': map.spatialReference
});
if (check_drag_graphic()) {
map.getLayer('ctrl_drag').graphics[0].setGeometry(box);
} else {
drag.drag_graphic = new esri.Graphic(box, new esri.symbol.SimpleFillSymbol());
map.getLayer('ctrl_drag').add(drag.drag_graphic);
}
}
function check_drag_graphic() {
if (drag.hasOwnProperty('drag_graphic')) {
return true;
} else {
return false;
}
}
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="overflow:hidden;">
</div>
</div>
</body>
</html>
... View more
12-16-2010
04:18 PM
|
0
|
0
|
807
|
|
POST
|
I think you're confusing the REST API with the JavaScript API. If you're using JS, use executeForIds().
... View more
12-09-2010
11:46 AM
|
0
|
0
|
1368
|
|
POST
|
Try using featureSet.geometryType in your switch statement.
... View more
12-09-2010
11:36 AM
|
0
|
0
|
2695
|
|
POST
|
Perhaps I'm missing something, but you're talking about putting an image on a web page, correct? Just put an img tag in a div and you're good to go.
... View more
12-08-2010
05:55 AM
|
0
|
0
|
624
|
|
POST
|
I'm not able to get to your map service but you're right about overwriting your info on each iteration of your loop. Do something like this: function addToMap(idResults, evt){
var chart_html = [];
for (var i = 0, il = idResults.length; i < il; i++) {
var idResult = idResults;
if (idResult.layerId === 0) {
var feature, attributes, NO3NO2, SAMPLEDATE, graphics;
feature = idResult.feature;
attributes = feature.attributes;
NO3NO2 = parseFloat(attributes.NO3NO2);
var params = dojo.mixin({
chf: "a,s,000000CD",
chbh:"a,4,2",
chds:"0,20",
chxr:"0,0,20",
cht: "bvg",
chs:"275x110",
chxt: +SAMPLEDATE +"," +NO3NO2,
chxl:"0:|2004|2005|2006|2007|2008|2009",
chd:"t1:" +NO3NO2,
chco:"A2C180,3D7930",
chtt:"Water+Quality+Data",
});
//create symbol for selected features on the map
var mySymbol = new esri.symbol.SimpleMarkerSymbol();
mySymbol.setStyle(esri.symbol.SimpleMarkerSymbol.S TYLE_SQUARE);
mySymbol.setSize(10);
mySymbol.setColor(new dojo.Color([255,255,0,0.5]));
feature.setSymbol(mySymbol);
map.graphics.add(feature);
map.infoWindow.setTitle("NO3NO2")
console.log(NO3NO2);
chart_html.push("<img src='" + "http://chart.apis.google.com/chart?" +
decodeURIComponent(dojo.objectToQuery(params)) +
' />"
);
}
map.infoWindow.setContent(chart_html.join('<hr />'))
map.infoWindow.show(map.toScreen(identifyParams.geometry) , map.getInfoWindowAnchor(map.toScreen(identifyParams.geometry)));
}
}
... View more
12-01-2010
01:47 PM
|
0
|
0
|
1414
|
|
POST
|
Yes. Use an identify task and specify the geometry from your user defined polygon as the geometry property on your identify parameters.
... View more
11-29-2010
09:25 AM
|
0
|
0
|
518
|
|
POST
|
dojo.connect returns a handle that you can use to disconnect the event listener. Use something like this in your code: var map_click_handle = dojo.connect(map, 'onClick' some_function);
dojo.disconnect(map_click_handle); Of course that's a simplified example... Check out the docs for dojo.connect and dojo.disconnect.
... View more
11-09-2010
08:51 AM
|
2
|
0
|
1171
|
|
POST
|
Are you using a feature service? Can you elaborate on what happens when your users "interrupt each other"?
... View more
11-05-2010
11:01 AM
|
0
|
0
|
384
|
|
POST
|
In the getXML() function in the code I posted, change the 'url' property from 'points.xml' to the url to your php page.
... View more
11-04-2010
12:25 PM
|
0
|
0
|
1885
|
|
POST
|
Glad to demonstrate it's a piece of cake in JS as well :).
... View more
10-29-2010
12:30 PM
|
0
|
0
|
1885
|
|
POST
|
There's a sample that shows how to get (cross-domain) xml data via a proxy page: Access xml data. But I guess that's probably not what you want...try this: <!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title> points from json^H^H^H^H xml! </title>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.1/js/dojo/dijit/themes/claro/claro.css">
<style>
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.1"></script>
<script type="text/javascript">
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("esri.map");
var map;
function init() {
var initExtent = new esri.geometry.Extent({"xmin":-13632648,"ymin":4542594,"xmax":-13621699,"ymax":4546875,"spatialReference":{"wkid":102100}});
map = new esri.Map("map",{extent:initExtent});
var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer");
map.addLayer(basemap);
var resizeTimer;
dojo.connect(map, 'onLoad', function(theMap) {
dojo.connect(dijit.byId('map'), 'resize', function() {
clearTimeout(resizeTimer);
resizeTimer = setTimeout( function() {
map.resize();
map.reposition();
}, 500);
});
getXML();
});
}
function getXML() {
dojo.xhrGet({
'url': 'points.xml',
'content': {},
'handleAs': 'xml',
'load': displayPoints,
'error': error
});
}
function displayPoints(pts) {
console.log('success: ', pts);
xmlpts = pts;
var sym = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE, 20, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0,0,0]), 1), new dojo.Color([255,0,0,0.5]));
dojo.forEach(dojo.query('point', pts), function(pt) {
// might be a cleaner way to do this with dojox.xml.parser but this works so...
var lat = parseFloat(dojo.query('lat', pt)[0].childNodes[0].data);
var lng = parseFloat(dojo.query('long', pt)[0].childNodes[0].data);
var geom = esri.geometry.geographicToWebMercator(new esri.geometry.Point(lng, lat, new esri.SpatialReference({wkid: 4326})));
var graphic = new esri.Graphic(geom, sym);
map.graphics.add(graphic);
});
// zoom to our newly added graphics
map.setExtent(esri.graphicsExtent(map.graphics.graphics), true);
}
function error(error) {
console.log('failed: ', error);
}
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="overflow:hidden;">
</div>
</div>
</body>
</html>
... View more
10-29-2010
11:26 AM
|
0
|
0
|
1885
|
|
POST
|
Since your query gets tacked on to the URL, and browsers impose a limit on the size of URLs for security purposes, you'll need to configure a proxy page to get this to run successfully. More info here: Using the proxy page. The first bullet point on that page addresses your issue.
... View more
10-27-2010
10:47 AM
|
0
|
0
|
1055
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 01-23-2012 07:54 AM | |
| 1 | 05-28-2010 08:31 AM | |
| 1 | 11-12-2012 08:12 AM | |
| 3 | 02-23-2012 10:57 AM | |
| 1 | 06-27-2011 08:51 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:23 AM
|