POST
|
Ok so I've added the ID and now nothing loads. Also it seems that merely hiding the layer is not removing it from the printTask's list of stuff to print, only removing it has removed it from the print output. Is it possible to reorder the layers using map.on? If so I could just leave everything as is and add an if, else to swap their display order and achieve the desired printing...theoretically. Also, if it helps the general structure is this:
function init() {
var initialExtent =...
var lods = ...
tiledBasemap = ...
dynamicBasemap = ...
map.addLayers ...
}
function swapBasemap(...){}
function resizeTheMap(map) {...}
function printMap(...){
printTask.execute}
... View more
06-06-2014
11:24 AM
|
0
|
0
|
160
|
POST
|
So I'm not sure what you mean by give the layer an ID to fetch by but I tried passing just the variable name with: map.on('extent-change', function(delta, extent, levelChange, lods){
if(levelChange){
if(lods.level>17) {
map.getLayer("hcBasemapDynamic").show();
map.getLayer("tiledMapServiceLayer").hide();
} else {
map.getLayer("tiledMapServiceLayer").show();
map.getLayer("hcBasemapDynamic").hide();
}
}
}); This actually hid both layers (which I assume has to do with the ID thing) but more troubling is when trying the printing function, it still printed as before! (Screenshot attached- Left is the gis app, Right is the print pdf) Another question about this- I currently have this bit inside my map init function. In its own function it had 0 impact so I assume this is the correct location?
... View more
06-06-2014
10:57 AM
|
0
|
0
|
800
|
POST
|
I've got this: map.on('extent-change', function(delta, extent, levelChange, lods){
if(levelChange){
if(lods.level>17) {
hcBasemapDynamic visibile: true,
tiledMapServiceLayer visible : false
} else {
hcBasemapDynamic visible : false,
tiledMapServiceLayer visible : true
}
}
}); I'm struggling with how to write the set visible/not portion.
... View more
06-06-2014
08:27 AM
|
0
|
0
|
800
|
POST
|
Streets are never technically turned off, rather stacked on top of and the minScale of imagery is handled.
... View more
06-05-2014
11:53 AM
|
0
|
0
|
800
|
POST
|
Also, if i set the visibility to false on the imagery layer, it behaves as expected and does not appear on the printTask. However, this of course also causes it to not display on the map. Is there a better way to toggle which basemap is being displayed to the user that also allows setting visibility so that the printTask executes properly? Maybe something to the effect of: if (scale => 564) { visibility : false } else { visibility : true };?
... View more
06-05-2014
11:46 AM
|
0
|
0
|
800
|
POST
|
You're correct- I am using LODs to control the visibility of the imagery. Here's the snippet:
var lods = [{
"level" : 0,
"resolution" : 156543.033928,
"scale" : 591657527.591555
}, {
"level" : 1,
"resolution" : 78271.5169639999,
"scale" : 295828763.795777
}, {
etc etc
}, {
"level" : 19,
"resolution" : 0.298582141647617,
"scale" : 1128.497176
}, {
"level" : 20,
"resolution" : 0.1492910708237085,
"scale" : 564.248588125
}];
tiledMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/Worl d_Street_Map/MapServer");
hcBasemap = new esri.layers.ArcGISTiledMapServiceLayer("http://www.blahblahblah.org/ArcGIS10/rest/services/Cache/Cache Aerials2010/MapServer", {
visible : false
});
hcBasemapDynamic = new esri.layers.ArcGISDynamicMapServiceLayer("http://www.blahblahblah.org/ArcGIS10/rest/services/Ca che/CacheAerials2010/MapServer", {
id : "Imagery_Dynamic",
minScale : 564.248588125
});
and the printMap function for good measure: function printMap(label, author, copyright, format, layout, scaleunit) {
var layersToPrint = esri.tasks.LegendLayer();
layersToPrint.layerId = "BlahBlahBlah";
layersToPrint.subLayerIds = [14, 15, 16, 17, 18, 19, 21, 24, 27, 28, 29, 30];
params = new esri.tasks.PrintParameters();
var template = new esri.tasks.PrintTemplate();
template.exportOptions = {
width : 750,
height : 1000,
dpi : 96
};
template.layoutOptions = {
copyrightText : copyright,
scalebarUnit : scaleunit,
titleText : label,
authorText : author,
legendLayers : [layersToPrint]
};
template.format = format;
template.layout = layout;
template.preserveScale = true;
params.template = template;
params.map = map;
showLoader();
printTask.execute(params, function(result) {
hideLoader();
window.open(result.url, '_blank');
window.focus();
});
}
... View more
06-05-2014
11:34 AM
|
0
|
0
|
800
|
POST
|
Hi there, I have a printTask that works wonderfully except for one unfortunate bit that I cannot seem to figure out or find any resources on. I have two ArcGISTiledMapServiceLayers that function as basemaps; one of which is imagery on our arcgisonline server, the other is ESRIs world Street Map. The world street map displays until the user is zoomed in beyond a certain extent, then the imagery displays beyond that. However, when executing printTask, the imagery always appears on top of the world street map, regardless of what is currently being displayed. Basically, I just want the printTask to print whatever basemap is currently displaying. Any suggestions/thoughts/ideas would be most helpful. I've attached a screenshot of what's being output. Thanks!
... View more
06-05-2014
10:39 AM
|
0
|
11
|
1357
|
POST
|
That was it. My connection just needed to be changed to default to the user. Unfortunately the path still has to be hard-coded but that's still not a difficult setup process. Thank you tons for your help! Mega thumbs up!
... View more
04-21-2014
10:13 AM
|
0
|
0
|
539
|
POST
|
Looking in the folder at: C:\Users\mosleya\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog I see a Connection to gisprod.sde file. This is the same file for every user with a version, meaning its owner is administrator. So hard-cording: workspace = (r"C:\Users\mosleya\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog\Connection to gisprod.sde") produces the same error: RuntimeError: Operation only allowed by the owner of the version [sde.DEFAULT] My end game here is to start an edit session on a specific version under the DEFAULT.sde Something like: workspace = (r"C:\Users\mosleya\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog\Connection to gisprod\VersionMOSLEYA.sde") ...if such a file path existed of course.
... View more
04-21-2014
07:57 AM
|
0
|
0
|
539
|
POST
|
So I tried hardcoding the path name like so: workspace = "C:\Users\mosleya\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog\Connection to gisprod.sde" edit = arcpy.da.Editor(workspace) From this I get an error that says edits to this may only be made by the owner of the Default.sde DB (admin). So I passed: arcpy.da.ListVersions("C:\Users\mosleya\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog\Connection to gisprod.sde") and come up with a list of 20 expected version objects, [0] being default (I have to assume). So I tried this for [0]-[19] in hopes of finding the direct workspace of my user name (which I have editing rights to): version = arcpy.da.ListVersions("C:\Users\mosleya\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog\Connection to gisprod.sde")[0] workspace = (version) edit = arcpy.da.Editor(workspace) I get a "cannot open workspace" error for every single one. I know one of these must be my own version so I'm not sure if I have missed some crucial arcpy.da.Editor line or what. The only thought I have is that perhaps my version has a lock on it by default that must be unlocked to enable to editor and then relocked after the edit is done?
... View more
04-21-2014
05:34 AM
|
0
|
0
|
539
|
POST
|
I haven't been able to find any information on pointing the workspace at a particular version of sde data unfortunately. I did try simply hard coding the path of the sde and it threw an editing permission restricted error. Now that my brain has had a minute to sit still, that's quite a duh kind of error. I'll see if the filepath is different for the actual layer when I get back into work and give that a go. Which help article were you pulling from? I seemed to have missed it in my hours of pouring through esri resources.
... View more
04-17-2014
02:03 PM
|
0
|
0
|
539
|
POST
|
So using that code I run into 2 errors: The first error is due to unexpected indentations between the edit.start and edit.stop commands. Upon some inspection of the arcpy.editor class help doc, it seems you have the option of either not indenting these or passing the editor using with: with arcpy.da.Editor(workspace) as edit: and there is then no need for the start and stop commands as this is automatically handled. So I removed the indentation and ran into my second error: Line 29: edit = arcpy.da.Editor(workspace) RuntimeError: cannot open workspace So I passed a few of the beginning lines to pursue what I thought might be the suspicious bit of code: import arcpy
import os
addressPoints = "Address Points"
mxd = arcpy.mapping.MapDocument('current')
df = arcpy.mapping.ListDataFrames(mxd)[0]
lyr = arcpy.mapping.ListLayers(mxd, addressPoints, df)[0]
print lyr
print lyr.workspacePath print lyr returns Address Points as expected. print lyr.workspacePath returns nothing. We are then feeding the next line: edit = arcpy.da.Editor(workspace) an empty argument. Meaning that the "Address Points" layer SEEMS to have an attribute named workspacePath but it is blank...unless I'm misinterpreting this? Any thoughts?
... View more
04-17-2014
12:38 PM
|
0
|
0
|
539
|
POST
|
Well it looks like I spoke too soon. I had been testing on a backup database. When tried out on the live DB it throws this error: Line 53 ExecuteError: ERROR 999999: Error executing function. The requested operation is invalid on a closed state [gisdev.GISDBA.AddressPoints][STATE_ID = 3149277] Failed to execute (SelectLayerByLocation). We are working on versions of a DB.sde, however as nothing in the code is a literal path I did not expect that to have much of an impact. Any thoughts?
... View more
04-16-2014
12:06 PM
|
0
|
0
|
519
|
POST
|
So based on your logic here's what I came up with: import arcpy
import pythonaddins
class BlueBird(object):
"""Implementation for BlueBird.button (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
#Get the current map document and the first data frame.
mxd = arcpy.mapping.MapDocument('current')
df = arcpy.mapping.ListDataFrames(mxd)[0]
#Check to make sure user had at least one parcel selected.
parcelsCount = int(arcpy.GetCount_management("Parcels").getOutput(0))
if 0 < parcelsCount < 2:
#Select Address Points within selected parcel
arcpy.SelectLayerByLocation_management("Address Points", "HAVE_THEIR_CENTER_IN", "Parcels")
with arcpy.da.SearchCursor("Parcels", ['PIN','TMS']) as singleCursor:
for singleRow in singleCursor:
PIN = singleRow[0]
TMS = singleRow[1]
with arcpy.da.UpdateCursor("Address Points", ['PIN', 'TMS']) as singleCursor:
for singleRow in singleCursor:
singleRow[0] = PIN
singleRow[1] = TMS
singleCursor.updateRow(singleRow)
elif 1 < parcelsCount < 1000:
#Create in memory parcel layer
selectedParcels = arcpy.MakeFeatureLayer_management("Parcels", "selectedParcels")
for lyr in arcpy.mapping.ListLayers(mxd, "", df):
if lyr.name == "Address Points":
addressLayer = lyr
if lyr.name == "Parcels":
parcelsLayer = lyr
with arcpy.da.SearchCursor("Parcels", ['PIN', 'TMS', 'OBJECTID']) as parcelCursor:
for parcelRow in parcelCursor:
PIN = parcelRow[0]
TMS = parcelRow[1]
OID = parcelRow[2]
OID = str(OID)
arcpy.SelectLayerByAttribute_management("selectedParcels", "NEW_SELECTION", "OBJECTID= "+OID)
#Select Address Points by location, within selected Parcels.
arcpy.SelectLayerByLocation_management("Address Points","HAVE_THEIR_CENTER_IN","selectedParcels")
with arcpy.da.UpdateCursor("Address Points", ['PIN', 'TMS']) as addressCursor:
for addressRow in addressCursor:
addressRow[0] = PIN
addressRow[1] = TMS
addressCursor.updateRow(addressRow)
del PIN, TMS
arcpy.Delete_management("selectedParcels")
else:
print('Please select a valid number of parcels.') I decided to make an elif statement for when only a single parcel is selected to save time and RAM from the in memory layer. ~3 seconds to run for 1 parcel ~20 seconds to run 2+ It's working quite well now, though I'm sure there's a better way to do the where clause in SelectLayerByAttribute. Thanks again!
... View more
04-16-2014
11:28 AM
|
0
|
0
|
519
|
POST
|
Unfortunately joins are out due to permissions we have set on the respective layers, or you're right- I would have simply run that tool. Trying to make an inefficient situation and little less so. My knowledge is lacking in terms of what arcpy modules are available, so I thank you for your patience. I do understand what made the last iteration of code work, as I can see your last suggestion should as well, given the GetCount command. You said that the SelectByLocation must be included within the loop- I assume this statement (along with lack of search results) means there is no arcpy command to remove the previously iterated through row from selection? P.S. I checked out the up voting thread. Thanks again!
... View more
04-15-2014
02:57 PM
|
0
|
1
|
519
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|