|
POST
|
I wish I could find the thread I read not too long ago that discussed this. As I remember, the short answer is "You can't control it". I agree that it is almost always WAY too close and often overlaps the feature it's labeling.
... View more
05-31-2013
12:44 PM
|
0
|
0
|
1166
|
|
POST
|
I have decided that I don't like the new measurement widget, so I'm going back to basics. I have a floating pane containing two buttons and a display field. One button for measuring area and the other for measuring length. I think I have the geometry service calls sorted out, but when I close my floating pane, which should also deactivate the toolbar I created, I continue to have the tooltips for 'Click to start drawing'. The lines for 'measureActive = true' are used to keep the identify I have defined elsewhere from firing on my click event until I close the measure pane. Here are the relevant functions: //functions for measurement function closeMeasure () { console.log ("closeMeasure"); measureActive = false; dojo.disconnect(measureHandler); dojo.disconnect(measureAreaHandler); dojo.disconnect(measureLengthHandler); measureTb.deactivate(); map.graphics.clear(); identifyHandler = dojo.connect(map, 'onClick' , doIdentify); } function openGeomMeasure () { measureActive = true; map.graphics.clear(); measureAreaHandler = dojo.connect(geomService, "onAreasAndLengthsComplete", outputAreaAndLength); measureLengthHandler =dojo.connect(geomService, "onLengthsComplete", outputLength); var measureError = dojo.connect(geomService, "onError" , measureErrHandler); var fp = dijit.byId('floater_GeomMeasure'); if ((fp.style =="visibility: hidden;") || (fp.style="VISIBILITY:hidden;")) { fp.style.visibility="visible"; fp.show(); } measureHandler = dojo.connect(measureTb, "onDrawEnd", getAreaAndLength); } function getAreaAndLength(geometry) { map.graphics.clear(); var graphic = map.graphics.add(new esri.Graphic(geometry, highlightFillSymbol)); var geoType = geometry.type; if (geoType == 'polygon') { //setup the parameters for the areas and lengths operation var areasAndLengthParams = new esri.tasks.AreasAndLengthsParameters(); areasAndLengthParams.areaUnit = esri.tasks.GeometryService.UNIT_ACRES; geomService.simplify([geometry], function(simplifiedGeometries) { areasAndLengthParams.polygons = simplifiedGeometries; geomService.areasAndLengths(areasAndLengthParams); }); }else { var lengthParams = new esri.tasks.LengthsParameters(); lengthParams.lengthUnit = esri.tasks.GeometryService.UNIT_FOOT; lengthParams.geodesic = true; geomService.simplify([geometry], function(simplifiedGeometries) { lengthParams.polylines = simplifiedGeometries; geomService.lengths(lengthParams); }); } } function measureErrHandler (error) { console.log ("MeasureErrHandler = " + error); } function outputAreaAndLength(result) { console.log(dojo.toJson(result)); dojo.byId("measureText").innerHTML = "<b>Area: </b> " + result.areas[0].toFixed(2) + " Acres"; // dojo.byId('distanceDetails').innerHTML = distance; } function outputLength (result) { console.log(dojo.toJson(result)); dojo.byId("measureText").innerHTML = "<b>Length: </b> :" + result.lengths[0].toFixed(2) + " Feet"; } function startAreaMeasure () { measureActive = true; measureTb.deactivate(); measureTb.activate(esri.toolbars.Draw.POLYGON); dojo.byId("measureText").innerHTML = ""; } function startDistanceMeasure () { measureActive = true; measureTb.deactivate(); measureTb.activate(esri.toolbars.Draw.POLYLINE); dojo.byId("measureText").innerHTML = ""; }
... View more
05-31-2013
12:31 PM
|
0
|
6
|
1998
|
|
POST
|
I'm not familiar with the modal popup window you're describing. If you are calling your map to appear in some sort of popup window, wouldn't it's dimensions determine the size of the map and not the map div or the map? Then you would want both the map div and the map to have a style of height and width of 100%? It seems like if you specify dimension in more than one place, you're creating more potential conflict instead of trying to force the map into place.
... View more
05-30-2013
06:37 AM
|
0
|
0
|
716
|
|
POST
|
I'm not sure about the nested deferred, but as far as your infoTemplate content, I've been using a function on it, rather than just defining it like you have. It gave me a lot finer control of it's behavior as opposed to hard coding it and it doesn't try to format the information until the feature was returned from the identify. I wanted the contents displayed as a table. I have a lot of messy attribution, so there are lots of checks in my code to make sure there are values before I add it as a record in the table.
parcelInfoTemplate = new esri.InfoTemplate();
parcelInfoTemplate.setTitle("Parcel Information");
parcelInfoTemplate.setContent(parcelSetWindowContent);
Here's my identify function that I have set to my map 'onClick'
function doIdentify(event){
map.infoWindow.hide();
map.graphics.clear();
labelPt = event.mapPoint;
parcelIdentifyParams.geometry = event.mapPoint;
parcelIdentifyParams.mapExtent = map.extent;
var deferred = parcelIdentifyTask.execute(parcelIdentifyParams);
deferred.addCallback(function(response){
var feature = response[0].feature;
showInfoWindow(feature,labelPt);
});
}
}
function showInfoWindow (feature, labelPt) {
feature.setInfoTemplate(parcelInfoTemplate);
map.infoWindow.setTitle("Parcel Information");
map.infoWindow.setContent(feature.getContent());
map.infoWindow.show(labelPt);
}
function parcelSetWindowContent(graphic) {
var nameTest1 = graphic.attributes.NAME1;
var addressTest = graphic.attributes.SITEADDRES;
var addressTest2 = graphic.attributes.SITEADDRESS;//very freaky that some seem to have one 's' and other two
var legalTest1 = graphic.attributes.LEGAL1;
var legalTest2 = graphic.attributes.LEGAL2;
var legalTest3 = graphic.attributes.LEGAL3;
var legalTest4 = graphic.attributes.LEGAL4;
var fullLegalString;
var twpRangeSecString;
var twpTest = graphic.attributes.TOWNSHIP;
var rngTest = graphic.attributes.RANGE;
var secTest = graphic.attributes.SECTION;
if (twpTest != 'undefined' && twpTest != 'Null') {
twpRangeSecString = "TWP:" + graphic.attributes.TOWNSHIP;
}
if (rngTest != 'undefined' && rngTest != 'Null') {
twpRangeSecString = twpRangeSecString + " RNG:" + graphic.attributes.RANGE;
}
if (secTest != 'undefined' && secTest != 'Null') {
twpRangeSecString = twpRangeSecString + " SEC: " + graphic.attributes.SECTION;
}
var acreageTest = graphic.attributes.ACRES;
var buildingNameTest = graphic.attributes.BUILDING_NAME;
var bookTest = graphic.attributes.BOOK1;
var pageTest = graphic.attributes.PAGE1;
var initString = "";//used to see if there is really any content in the attribute values
//There is problem with Null being detected as a 4 character length string instead of just nothing
//checking to see if the value is longer than 4 characters because of this
initTable = "<table id='infoWindowTable' data-dojo-type='dojox.grid.DataGrid' class='infoTable' ><tr><th></th><th></th></tr>";
if (nameTest1.length > 1) {
initTable = initTable + "<tr><td><b>Owner:</b></td><td>" + nameTest1+ "</td></tr>";
initString = nameTest1;
}
if (buildingNameTest) {
if (buildingNameTest.length > 4) {
initTable = initTable + "<tr><td><b>Building:</b></td><td>" + buildingNameTest+ "</td></tr>";
initString = initString + buildingNameTest;
}
}
if (addressTest) {
if (addressTest.length > 4) {
initTable = initTable + "<tr><td><b>Site Address:</b></td><td>" + addressTest + "</td></tr>";
initString = initString + addressTest;
}
}
if (addressTest2) {
if (addressTest2.length > 4) {
initTable = initTable + "<tr><td><b>Site Address:</b></td><td>" + addressTest2 + "</td></tr>";
initString = initString + addressTest2;
}
}
initTable = initTable + "</table><br><a id='btnZoom' onClick='zoomTo();'>Zoom To</a>";
//some counties provided so little information in a field that there wasn't enough information to put
//in an infoWindow
if (initString.length < 3) {
initTable = "Limited data provided, see side panel.";
}
return initTable;
}
Maybe it will at least give you some ideas of another way to approach your problem.
... View more
05-29-2013
01:40 PM
|
0
|
0
|
1529
|
|
POST
|
You are using parameters in your map constructor that are not valid. If you look at the API reference, neither height or width are an option. Have you tried it without these in your map definition?
... View more
05-29-2013
01:18 PM
|
0
|
0
|
716
|
|
POST
|
I have the measurement dijit activated in a floating pane, which opens with a button. I have the common issue of needing to both measure and identify and keep track of each. In general, this is working for me, until I noticed that the polygon I was drawing for measuring the area was only showing me one segment at a time, not the whole polygon! I'm declaring the measurement dijit in the init function as
measurement = new esri.dijit.Measurement({
map: map,
defaultAreaUnit: esri.Units.ACRES,
defaultLengthUnit: esri.Units.FEET
}, dojo.byId('measureDiv2'));
measurement.startup();
The function for opening the floating pane also sets the variable I'm using in the identify function for whether or not the measure tool is currently active
function openMeasure () {
measureActive = true;
var fp = dijit.byId('floater_measure');
if ((fp.style =="visibility: hidden;") || (fp.style="VISIBILITY:hidden;")) {
fp.style.visibility="visible";
fp.show();
}
var snapManager = map.enableSnapping({snapKey:dojo.keys.copyKey});
dojo.connect(measurement.length, "onClick", function(){
measureActive = true;
console.log("Distance Tool activated");
});
dojo.connect(measurement.area, "onClick", function(){
measureActive = true;
console.log("Area Tool activated");
});
dojo.connect(measurement, "onMeasureEnd", function(activeTool, geometry){
this.setTool(activeTool, false);
measureActive = false;
setTimeout(function(){
measurement.clearResult();
}, 5000);
map.graphics.enableMouseEvents();
identifyHandler = dojo.connect(map, 'onClick' , doIdentify);
// console.log("Measurement done");
});
}
I've tried this in Firefox and IE and I get the same results. I'm still using the 3.2 version of the API library. I got an error in measurement.js when I tried version 3.3 and it didn't do anything different trying 3.4.
... View more
05-29-2013
11:35 AM
|
0
|
2
|
985
|
|
POST
|
Thanks for the extra pair of eyes! There are so many little things that aren't supported in IE 8 that I assumed I wasn't going to be able to use this as a print option. I didn't notice the missing 'var' when I switch from a webmap to a basic locally hosted map and set of services.
... View more
05-22-2013
01:07 PM
|
0
|
0
|
1312
|
|
POST
|
No, that didn't make any difference. I have to have a printing solution that works in IE. It is the state standard and users are rarely allowed to download and install any other browsers. I have other browsers for myself, but I'm in IT. I have to code to the lowest level of browser, which I think is still IE 7.
... View more
05-21-2013
07:40 AM
|
0
|
0
|
1312
|
|
POST
|
I have a basic print example based on http://help.arcgis.com/en/webapi/javascript/arcgis/jssamples/widget_print_esri_request.html, but I have changed out the webmap for a standard JS map with arcdynamicservicelayers etc. This works just fine in Firefox. When I try the sample code in IE 8, it doesn't look to load the esri.dijit.Print I created. Instead, looking at the IE Developers Tools, I'm getting errors for 'Object doesn't support this property or method' . The Print button I expect to see never loads and neither does my map. I've played with a couple of different version of the API, but that doesn't seem to help. This must work in IE. Maybe it's something small I just haven't spotted yet? <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9"> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"> <title>Print Digit Sample</title> <link type="text/css" rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.2/js/dojo/dijit/themes/claro/claro.css"> <link type="text/css" rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.2/js/esri/css/esri.css"> <style> html, body { height: 100%; width: 100%; margin: 0; padding: 0; } h3 { margin: 0 0 5px 0; border-bottom: 1px solid #444; padding: 0 0 5px 0; text-align: center; } #map{ margin: 0; padding: 0; } #printDiag { background: #fff; border: solid; border-width: 1px; color: #000; font-family: arial; height: auto; right: 30px; top: 30px; margin: 5px; padding: 10px; position: absolute; width: 300px; z-index: 40; #note { font-size: 80%; font-weight: 700; padding: 0 0 10px 0; } #info { padding: 10px 0 0 0; } </style> <script type="text/javascript"> var dojoConfig = { parseOnLoad: true }; </script> <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.2"> </script> <script> dojo.require("dijit.layout.BorderContainer"); dojo.require("dijit.layout.ContentPane"); dojo.require("esri.arcgis.utils"); dojo.require("esri.dijit.Print"); var pathName = "https://myserver.gov"; var printUrl; printUrl = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task"; function init(){ esri.config.defaults.io.proxyUrl = "proxy/proxy.ashx"; spatialReference = new esri.SpatialReference({ wkid: 102100 }); startExtent = new esri.geometry.Extent(-10723197, 4186914, -9829190, 4992866, spatialReference); map = new esri.Map("map", { extent: startExtent }); countyLayer = new esri.layers.ArcGISDynamicMapServiceLayer(pathName + "/ArcGIS/rest/services/BaseMap/county_simple/MapServer", { id: "countyLayer" }); map.addLayer(countyLayer); createPrintDijit("This is my Title"); } function createPrintDijit(printTitle) { var layoutTemplate, templateNames, mapOnlyIndex, templates; // create an array of objects that will be used to create print templates var layouts = [ { "name": "Letter ANSI A Landscape", "label": "Landscape - PDF", "format": "pdf", "options": { "legendLayers": [], // empty array means no legend "scalebarUnit": "Miles", "titleText": printTitle , "copyrightText": "Missouri Office of Geospatial Information" } }, { "name": "Letter ANSI A Portrait", "label": "Portrait - PDF", "format": "pdf", "options": { "legendLayers": [], "scaleBarUnit": "Miles", "titleText": printTitle , "copyrightText": "Missouri Office of Geospatial Information" } } ]; // create the print templates, could also use dojo.map templates = []; dojo.forEach(layouts, function(lo) { var t = new esri.tasks.PrintTemplate(); t.layout = lo.name; t.label = lo.label; t.format = lo.format; t.layoutOptions = lo.options; templates.push(t); }); var printer = new esri.dijit.Print({ "map": map, "templates": templates, url: printUrl }, dojo.byId("print_button")); printer.startup(); } dojo.ready(init); </script> </head> <body class="claro"> <div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="design:'headline',gutters:false" style="width: 100%; height: 100%; margin: 0;"> <div id="map" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'center'"> <div id="printDiag" > <h3> Creating Map Output </h3> <div id="info"> <div id="note"> To Use: Click the print button to choose either Landscape or Portrait format. <br><br>Once your PDF is generated, the print button will change link that says Printout. Click it to view your PDF. </div> <!-- that will be used for the print dijit --> <div id="print_button" ></div> </div> </div> </div> </div> </body> </html>
... View more
05-20-2013
01:31 PM
|
0
|
8
|
2086
|