POST
|
We are experiencing an issue with Chrome v29+ and version 2.8 of ArcGIS JSAPI The solutions I've seen online seem to reference the query.js file whereas the JSAPI doesn't load that file but I see a similar pattern in init.js (but since it is minified I'm not sure where the actual problem code is). Would appreciate any fixes from ESRI. We plan to upgrade the JSAPI at some point but a temporary fix would be a lifesaver. UPDATE: The fix that svignara posted above allows the map to load, but calling getChildren() on our BorderContainer only returns 1 child element when there should be two, so it is still broken
... View more
08-29-2013
06:50 AM
|
0
|
0
|
516
|
POST
|
I was able to solve the cursor offset issue by using map.reposition() after any change in my page layout that affected the map div. Hey I'm afraid not. I still see a cursor offest from time to time in my apps. More often in Chrome than other browsers. Did you find a fix?
... View more
01-15-2013
08:59 AM
|
0
|
0
|
433
|
POST
|
It seems like this should be fairly straight forward but I haven't found a great solution yet. I would like to show my users a message, and possibly alter the way our interface looks, if and when there is a problem with one of our map services. In my application I have a basemap (ArcGISTiledMapServiceLayer), a dynamic layer (ArcGISDynamicMapServiceLayer) and a couple feature layers (FeatureLayer). For the basemap and dynamic layer, I am just doing a straightforward constructor and then map.addLayer to add them to the map. For the feature layers, I am doing a constructor, applying a setDefinitionExpression and then using map.addLayer to add to the map. If any of the services are down I want to be able to tell the user, at minimum with an alert or message. I thought I could use onLayerAddResult(layer, error) but it doesn't seem to be getting called if the layer based on a stopped/bad service is added to the map. I see similar examples using esri.request but it doesn't seem like I should have to do an extra call to the service since in the console I see these types of calls to each service: http: //myserver/ArcGIS/rest/services/Streets/Mask/MapServer?f=json&dpi=96&transparent=true&format=png8&layers=show%3A-1&callback=dojo.io.script.jsonp_dojoIoScript2._jsonpCallback With a response of either: dojo.io.script.jsonp_dojoIoScript2._jsonpCallback({"serviceDescription" : null,"mapName":"Layers","description":"","copyrightText":"","layers":[{"id":0,"name":"LMBCO_Mask","parentLayerId":-1,"defaultVisibility":true,"subLayerIds":null}],"tables":[],"spatialReference":{"wkid":2263},"singleFusedMapCache":false,"initialExtent":{"xmin":806353.163236593,"ymin":139639.306949227,"xmax":1165380.94101437,"ymax":327833.751393672,"spatialReference":{"wkid":2263}},"fullExtent":{"xmin":824755.941014371,"ymin":38597.6402825604,"xmax":1146978.16323659,"ymax":323319.862504783,"spatialReference":{"wkid":2263}},"units":"esriFeet","supportedImageFormatTypes":"PNG32,PNG24,PNG,JPG,DIB,TIFF,EMF,PS,PDF,GIF,SVG,SVGZ,BMP","documentInfo":{"Title":"","Author":"","Comments":"","Subject":"","Category":"","Keywords":"","AntialiasingMode":"Normal","TextAntialiasingMode":"Force"},"capabilities":"Map,Query,Data"}); if the service is up and running, or: dojo.io.script.jsonp_dojoIoScript2._jsonpCallback({"error":{"code":400,"message":"Unable to complete operation.","details":["Service 'NYCStreets/LMBCO_Mask' of type 'MapServer' does not exist or is inaccessible."]}}); if the service is not available. Is there a way to handle this reponse that comes back? Thanks for your help! Chad Wilcomb
... View more
05-08-2012
12:26 PM
|
0
|
1
|
700
|
POST
|
Not sure what specifically is different, but here is the way I am doing something similar in case it might help... Creating the empty Popup for the map.
var popup = new esri.dijit.Popup(null, dojo.create("div"));
map = new esri.Map("map", {
extent: extent,
width: mapWidth,
infoWindow: popup, //Define popup for map infowindow
showInfoWindowOnClick: false
}); Define the InfoTemplate on the FeatureLayer
var template = new esri.InfoTemplate();
template.setContent(getTextContent);
var featureLayer = new esri.layers.FeatureLayer("http://yourserver/ArcGIS/rest/services/yourmapservice/MapServer/0", {
mode: esri.layers.FeatureLayer.MODE_SNAPSHOT,
outFields: ["Name","rep_no","ADDR1"],
infoTemplate: template //Define the template for the FeatureLayer
});
function getTextContent(graphic) {
var name= graphic.attributes.Name;
var rep_no= graphic.attributes.rep_no;
var address= graphic.attributes.ADDR1;
var content = "<b>Name : </b>" + name + "<br><b>Rep # : </b>" + rep_no + "<br><b>Address : </b>" + address;
return content;
} Then I do this after I use selectFeatures on my FeatureLayer to show popup and center the map on the selected feature...
map.infoWindow.hide();
map.infoWindow.clearFeatures();
map.infoWindow.setFeatures(selectedRepGraphic); //I use setFeatures to set the Map InfoWindow/Popup to the selected feature/graphic
map.infoWindow.show(selectedRepGraphic.geometry);
map.centerAndZoom(selectedRepGraphic.geometry, 7); Good luck!
... View more
04-10-2012
10:43 AM
|
0
|
0
|
589
|
POST
|
I haven't tested this or anything, but what happens if you try using a single function like this one, adapted from the sample to match up with your code:
function doRepManager(fset) {
map.graphics.clear(); //not sure if you want to clear the graphics or not, but just in case
var symbol = new esri.symbol.SimpleMarkerSymbol();
symbol.style = esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE;
symbol.setSize(6);
symbol.setColor(new dojo.Color([219, 112, 147, 1]));
//create array of attributes
var items = dojo.map(fset,function(result){
var graphic = result.feature;
graphic.setSymbol(symbol);
map.graphics.add(graphic);
return result.feature.attributes;
});
//Create data object to be used in store
var data = {
identifier: "rep_no", //This field needs to have unique values
label: "rep_no", //Name field for display. Not pertinent to a grid but may be used elsewhere.
items: items
};
//Create data store and bind to grid.
store = new dojo.data.ItemFileReadStore({ data:data });
var grid = dijit.byId('grid');
grid.setStore(store);
}
... View more
04-03-2012
06:32 AM
|
0
|
0
|
400
|
POST
|
Looks like the services for at least the earthquakes are down: http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/EarthquakesFromLastSevenDays/MapServer Shows a does not exist or is invalid. They may be doing maintenance or something got borked. I can't imagine the overhead keeping up with all of the services that they have to be publishing 🙂 They must be back up because all these links work for me!
... View more
04-02-2012
08:45 AM
|
0
|
0
|
215
|
POST
|
What's the reasoning behind not wanting to add an object id field client side? Derek, do you have any samples on how to do this?
... View more
04-02-2012
07:30 AM
|
0
|
0
|
1182
|
POST
|
Cwclimb, I tested the following code, the result is that when the layer has been readded (with the definitionExpression set) are shown all the feature of the layer...In your application is it working correctly?(the definition expression is honored) map.removeLayer(featureLayer);
featureLayer.setDefinitionExpression(qstring);
map.addLayer(featureLayer); Yes, this is working as expected in my applications, where qstring represents a valid WHERE statement, like "FIELD_NAME='Value'".
... View more
04-02-2012
07:27 AM
|
0
|
0
|
403
|
POST
|
Try using a Query Layer to load the data into your MXD. Go to File -> Add Data -> Add Query Layer, connect to your database and write a query (or double-click on a table to Select *). Click "Show Advanced Options", then select one or more fields to create a unique identifier.
... View more
04-02-2012
05:42 AM
|
0
|
0
|
1182
|
POST
|
Evans, I think I got this working how you want it. The FeatureSet result from the queryTask is successfully being passed to the doBufferFunc function now. A couple things- 1) I moved the queryTask out of init() and into your queryZip() function. It was out of scope to the queryZip() function previously. I used a sample ESRI map service and added some outFields to the query to test it. 2) I got rid of the features[] thing you were doing. Since you only wanted the first candidate with score > 80, I just passed the candidate.location (geom) into the queryZip function. Here's just the JS code with comments included... <script type="text/javascript"> dojo.require("esri.map"); dojo.require("esri.tasks.locator"); dojo.require("dojo.number"); dojo.require("dijit.form.Button"); dojo.require("dijit.form.Textarea"); dojo.require("dijit.layout.BorderContainer"); dojo.require("dijit.layout.ContentPane"); dojo.require("esri.tasks.query"); dojo.require("esri.tasks.geometry"); var map, locator; var geom, featgeom; function init() { var initExtent = new esri.geometry.Extent({"xmin":-17497000,"ymin":2165000,"xmax":-4132000,"ymax":6969000,"spatialReference":{"wkid":102100}}); map = new esri.Map("map", { extent: initExtent}); var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"); map.addLayer(basemap); // var queryTask --> I moved this out of init() and into the query function dojo.connect(map, 'onLoad', function(map) { //resize the map when the browser resizes dojo.connect(dijit.byId('map'), 'resize', map,map.resize); }); locator = new esri.tasks.Locator("http://tasks.arcgis.com/ArcGIS/rest/services/WorldLocator/GeocodeServer"); dojo.connect(locator, "onAddressToLocationsComplete", showResults); map.infoWindow.resize(200,125); }; //End of Init function locate() { map.graphics.clear(); var address = {"SingleLine":dojo.byId("address").value}; locator.outSpatialReference= map.spatialReference; var options = { address:address, outFields:["Loc_name"] }; locator.addressToLocations(options); }; function showResults(candidates) { console.log("showResults"); console.log(candidates); var candidate; var symbol = new esri.symbol.SimpleMarkerSymbol(); var infoTemplate = new esri.InfoTemplate("Location", "Address: ${address}<br />Score: ${score}<br />Source locator: ${locatorName}"); symbol.setStyle(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE); symbol.setColor(new dojo.Color([153,0,51,0.75])); dojo.every(candidates,function(candidate){ console.log(candidate.score); if (candidate.score > 80) { console.log(candidate.location); var attributes = { address: candidate.address, score:candidate.score, locatorName:candidate.attributes.Loc_name }; geom = candidate.location; var graphic = new esri.Graphic(geom, symbol, attributes, infoTemplate); //add a graphic to the map at the geocoded location map.graphics.add(graphic); map.graphics.add(new esri.Graphic(geom)); //You don't need to do all this features business, just pass the geom variable to queryZip() //var features= []; //features.push(graphic); //var featureSet = new esri.tasks.FeatureSet(); //featureSet.features = features; //I THINK IM STUCK HERE?! //featgeom = features.geometry; return false; //break out of loop after one candidate with score greater than 80 is found. } }); if(geom !== undefined){ map.centerAndZoom(geom,12); queryZip(geom); } else alert("No address found."); }; function queryZip(geom){ //I grabbed a random ESRI map service for the QueryTask var queryTask = new esri.tasks.QueryTask("http://server.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Tapestry/MapServer/2"); // Query var query = new esri.tasks.Query(); query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_INTERSECTS; query.outSpatialReference = {"wkid":102100}; query.returnGeometry = true; query.geometry = geom; queryTask.execute(query, doBufferFunc); console.log(query); //dojo.connect(queryTask, "onComplete", doBufferFunc()); }; function doBufferFunc(featureSet){ console.log(featureSet); }; dojo.addOnLoad(init); </script>
... View more
03-30-2012
02:46 PM
|
0
|
0
|
240
|
POST
|
cwilcomb, I tested your solution but it doesn't work. However the first solution you suggested should work, but not, and the behavior of the application it's very strange...I think about two chances: -I'm doing something wrong in the way I use the DefinitionExpression, -It is a bug in the javascript API. So, please, someone of the ESRI Support Provide me Help!I'll be glad to you! And a special thanks to cwilcomb xD I have all of the code that I posted working in my application so it's not a bug in the API. You should probably post a reproduce-able code sample to get more/better responses. I just jumped in because I was working on something very similar this week. You'll get it worked out eventually!
... View more
03-29-2012
12:13 PM
|
0
|
0
|
403
|
POST
|
If there are certain attributes that can be very long, you could do something like this...
var template = new esri.InfoTemplate();
template.setContent(getTextContent);
function getTextContent(graphic) {
var attribute1 = graphic.attributes.Attribute1;
var attribute2 = graphic.attributes.Attribute2;
if (attribute1.length > 20 || attribute2.length > 20) {
map.infoWindow.resize(x,y); //Resize the infoWindow
}
var content = "<b>Attribute 1</b>: " + attribute1 + "<br>";
content += "<b>Attribute 2</b>: " + attribute2;
return content;
}
... View more
03-29-2012
09:52 AM
|
0
|
0
|
190
|
POST
|
Hard to tell why that would be happening, but maybe you just need to do something like this when setting your definition expression?
map.removeLayer(featureLayer);
featureLayer.setDefinitionExpression(qstring);
map.addLayer(featureLayer);
I've figured out what the problem is! when I change the definition expression in my feature layer, the old features remain on the layer for a while (until I click on another "new" feature), so if I've got overlappend features and I click on a "new" one the function find two feature at the same point (the old one and the new). I don't get this behavior if I first click on a "new" not-overlapped feature and then I click on the "new overlapped" feature. I hope I was clear. What do you think about? Thank you very much.
... View more
03-29-2012
05:59 AM
|
0
|
0
|
403
|
POST
|
Thanks David & stevel, why didn't I think of using CSS? Incidentally, I used the same technique to knock out the maximize button on the popup as well...
.esriPopup .actionsPane .zoomTo {
display: none;
}
.esriPopup .titleButton.maximize {
display: none;
}
... View more
03-29-2012
05:17 AM
|
2
|
0
|
500
|
POST
|
The default behavior only returns the graphic "on top" I believe. Try something like this:
dojo.connect(map, "onClick", function (evt) {
var query = new esri.tasks.Query();
query.geometry = pointToExtent(map, evt.mapPoint, 10); //buffers click point by number of pixels(10)
var select = featureLayer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW);
select.then(function(features) {
console.log("select features result: ", features);
map.infoWindow.setFeatures(features);
map.infoWindow.show(e.mapPoint);
}, function(err) {
console.log("select features error: ", err);
});
});
//this is just a function that buffers the click point by number of pixels and returns an Extent.
function pointToExtent(map, point, toleranceInPixel) {
var pixelWidth = map.extent.getWidth() / map.width;
var toleraceInMapCoords = toleranceInPixel * pixelWidth;
return new esri.geometry.Extent(point.x - toleraceInMapCoords,
point.y - toleraceInMapCoords,
point.x + toleraceInMapCoords,
point.y + toleraceInMapCoords,
map.spatialReference);
}
Hat tip to Derek Swingley and his help here (http://gis.stackexchange.com/q/22025/5282)
... View more
03-28-2012
01:44 PM
|
0
|
0
|
403
|
Title | Kudos | Posted |
---|---|---|
2 | 03-29-2012 05:17 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|