|
POST
|
Randy, Thanks, these did work but they replaced everything in the text box with "Print date: 11/28/2018". newdate = "Print date: <dyn type=\"date\" format=\"\"/>" if " DATE" in elm.text.upper():
elm.text = newdate if "PRINT DATE" in elm.text.upper():
elm.text = newdate
... View more
11-28-2018
11:28 AM
|
0
|
13
|
1772
|
|
POST
|
Randy, Thanks for that. I tried your script verbatim (besides the path variable) and for some reason it won't save (nothing's open, tried saveACopy('test'), unindented, quit python, restarted, etc...). But, as far as the printout goes, it doesn't look like it changed the date because it's showing the same old date. Using yours and Dan's help from before, I put together this script: import arcpy, os
from arcpy import env
arcpy.env.workspace = ws = r"\\gisfile\GISmaps\AtlasMaps\ATLAS_MAPS_18\Test Folder"
oldText = "Print Date:9.23.2016"
newdate = "Print date: <dyn type=\"date\" format=\"\"/>" #i want the date text dynamic
# list the mxds of the workspace folder
for mxdname in arcpy.ListFiles("*.mxd"):
print "checking document: {}".format(mxdname)
mxd = arcpy.mapping.MapDocument(ws + "\\" + mxdname)
for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
if "Print Date" in oldText.upper():
new_fixed = "{}: {}".format(oldText.split(":")[0], newdate)
print "+++date changed+++"
mxd.save()
del mxd
However, it doesn't print the second statement or change the text in the MXD. I'm guessing it might have to do with the contents of the text box? This is the actual text box I've been testing on with all it's contents as it is in the MXD. As I said before this "Print Date..." line will have different content in different MXDs; where I'm eventually headed. Also, I've never named any elements in any of the maps. So, I don't see how I'd use this to access the text.
... View more
11-28-2018
08:43 AM
|
0
|
16
|
3157
|
|
POST
|
Dan, I like that approach. The thing is, "oldText" could be "Print Date:", "Plot Date:", "Plot date", etc... I wasn't the originator of the maps. I've only been updating them. So, with that, could I create a list with all these possibilities? I'm basically wondering how to formulate that.
... View more
11-27-2018
07:37 AM
|
0
|
1
|
3157
|
|
POST
|
Randy, Are you aware of a way to name the text boxes with Arcpy? That's a good idea. Sad thing is I'd have to retroactively do that at this point.
... View more
11-27-2018
06:41 AM
|
0
|
19
|
3157
|
|
POST
|
I'm in 4.9. How can I get the popup to display the title of each field using a Webmap? Right now, when you click the feature in the app the title displays as "Sheet1". The feature layer in the Webmap is actually "Warming Center". In the JS (below) I have the Title set up to display the "FACILITY_NAME" field. But, that's not happening. If I use the Map class instead of a Webmap the title displays in the popup just fine. But, in this case I'd rather user a Webmap. var webmap = new WebMap({
portalItem: {
id: "93b7e42b2ca64790aa2315da5eceaff9"
}
});
/************************************************************
* Set the WebMap instance to the map property in a MapView.
************************************************************/
var view = new MapView({
map: webmap,
container: "viewDiv",
popup: {
dockEnabled: true,
dockOptions: {
// Disables the dock button from the popup
buttonEnabled: false,
// Ignore the default sizes that trigger responsive docking
breakpoint: false,
}
}
});
//Popup template
var template = { // autocasts as new PopupTemplate()
title: "{FACILITY_NAME}",
content: [{
type: "fields",
fieldInfos: [{
fieldName: "FACILITY_TYPE",
label: "Facility Type",
visible: true,
}, {
fieldName: "ADDRESS",
label: "Address",
visible: true,
}, {
fieldName: "WEBSITE",
label: "Website",
visible: true,
}, {
fieldName: "PHONE_NUMBER",
label: "Phone",
visible: true,
}, {
fieldName: "HOURS",
label: "Hours",
visible: true,
}]
}]
};
//Reference the popupTemplate instance in the popupTemplate property of FeatureLayer
var featureLayer = new FeatureLayer({
url: "https://services.arcgis.com/fGsbyIOAuxHnF97m/arcgis/rest/services/Warming_Centers_in_and_around_Will_County_IL/FeatureServer/0?token=TBoytrSjk658s73RVxEixBfWiPa_GI5EYBjyRTwYygOilY6kmMaDiHJla-n8ZvLylgt755Owpi4Pvqxk8hzaAM3vfBBx2ueCuCWfenNdfKFxnSEoTfLCTB4kcJqBR1KHJAje4C9tHfcYHJnH1ciTvKBy38vzit7TGUFfVUkQEgXlmhoN4iut9RMll6meOOaUFSa0yPENiXUOxWClJcXzPSe81jiObK3Ecjv4YirstB6GLYanFZ56cEnR66HRwbmB",
outFields: ["*"],
popupTemplate: template
}); I haven't found any reference or help explaining this. WebMap | API Reference | ArcGIS API for JavaScript 4.9 This sample uses a webmap, but I don't see where they set the Title parameter. ArcGIS API for JavaScript Sandbox
... View more
11-19-2018
09:43 AM
|
0
|
1
|
1825
|
|
POST
|
Robert, Thanks for directing me away from the CSS. Whereas before I created a Map instance, I now created a WebMap. And this seems to have answered my question. /************************************************************
* Creates a new WebMap instance. A WebMap must reference
* a PortalItem ID that represents a WebMap saved to
* arcgis.com or an on-premise portal.
*
* To load a WebMap from an on-premise portal, set the portal
* url with esriConfig.portalUrl.
************************************************************/
var webmap = new WebMap({
portalItem: {
id: "93b7e42b2ca64790aa2315da5eceaff9"
}
});
/************************************************************
* Set the WebMap instance to the map property in a MapView.
************************************************************/
var view = new MapView({
map: webmap,
container: "viewDiv", I had a lot of help from these two examples: Load a basic WebMap | ArcGIS API for JavaScript 4.9 Swap web maps in the same view | ArcGIS API for JavaScript 4.9
... View more
11-16-2018
02:16 PM
|
0
|
0
|
1448
|
|
POST
|
I guess what I was asking was whether it's possible to have two different scales, one for the PC and one for the phone.
... View more
11-14-2018
06:35 AM
|
0
|
2
|
1448
|
|
POST
|
I can't seem to find the element to change the scale. Can it be done in the CSS? I've tried this: @media (max-width: 480px) {
view MapView {
scale: 1300000,
}
... View more
11-13-2018
02:33 PM
|
0
|
4
|
1569
|
|
POST
|
I have a working script that searches for a text element in an MXD and replaces it with new text. I'm using it to update the "print date: mo./day/year". But, this method is sort of limited in that it only finds that exact string. In my map document folder, the dates of these maps differ from each other. So, how can I make the script replace an open-ended string? I've tried: oldText = "Print Date: " and oldText = "Print Date: *" As the script is here, "oldText = Print Date: 9.6.2016" will be replaced with "newText = Print Date: 11/13/2018". But, dates on other maps could be anything. If I could replace the old with dynamic text date that would be even better. arcpy.env.workspace = Workspace = r"path\to\TestFolder"
Output = r"path\to\TestFolder2"
oldText = "Print Date: 9.6.2016"
oldList = oldText.split(', ')
newText = "Print Date: 11/13/2018"
newList = newText.split(', ')
# list the mxds of the workspace folder
for mxdname in arcpy.ListFiles("*.mxd"):
print "checking document: {}".format(mxdname)
# set the variable
mxd = arcpy.mapping.MapDocument(Workspace + "\\" + mxdname)
# replace elements that occur in the map document
for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
counter = 0
for text in oldList:
if text in elm.text:
elm.text = elm.text.replace(text, newList[counter])
print '{} changed'.format(elm.text)
counter = counter + 1
else:
counter = counter + 1
for elm in arcpy.mapping.ListLayoutElements(mxd, ""):
counter = 0
for text in oldList:
if text in mxd.title:
mxd.title = elm.text.replace(text, newList[counter])
counter = counter + 1
else:
counter = counter + 1
# move the mxd.saveACopy outside of the if loop so a copy is saved even it does not meet the condition of the if loops
mxd.save() #(os.path.join(Output + "\\" + mxdname))
# do not include this delete statement inside the above loop or it will delete the mxd object inside the loop. Make sure to dedent.
del mxd
... View more
11-13-2018
02:16 PM
|
0
|
28
|
6713
|
|
POST
|
For curiosity's sake, here's that unorthodox script. It's a workaround if you don't have many options as to where your data is stored. This script will: Remove broken layer (has to be specified by exact map layer name)--> Adds a new layer--> Updates that layer's symbology by importing a .lyr file that's saved with the symbology settings you want--> Moves this layer above another layer (puts it where you want it in the TOC) import arcpy
#variables
mxd = arcpy.mapping.MapDocument(r'path\to\.mxd')
df = arcpy.mapping.ListDataFrames(mxd, "name of dataframe")[0]
feature = arcpy.mapping.Layer(r"path\to\feature you want on map")
for lyr in arcpy.mapping.ListLayers(mxd, "featureclass", df): #the layer you're replacing
arcpy.mapping.RemoveLayer(df, lyr) #because this layer is broke, it will be removed
arcpy.mapping.AddLayer(df, feature, "AUTO_ARRANGE") #then 'feature' has to be re-added, but will be the wrong color
#the 'feature' will be updated by the .lyr file you created
updateLayer = arcpy.mapping.ListLayers(mxd, "name of feature", df)[0]
print("MXD: {} updated").format(mxd)#print statement to make sure it's working sofar
sourceLayer = arcpy.mapping.Layer(r"path\to\your\.lyr")
#update layer using the .lyr file's symbology
arcpy.mapping.UpdateLayer(df, updateLayer, sourceLayer, True)
#move layer to where you want in the TOC
for lyr2 in arcpy.mapping.ListLayers(mxd, "", df):
if lyr2.name == "feature name":
moveLayer = lyr2
if lyr2.name == "some other feature in the TOC":
refLayer = lyr2
arcpy.mapping.MoveLayer(df, refLayer, moveLayer, "BEFORE")
mxd.save()
del mxd
... View more
11-09-2018
01:17 PM
|
1
|
0
|
1818
|
|
POST
|
After creating an alternative script that unorthodoxically replaces the broken layer, I was able to find the problem in my original stand-alone script. It seems something is corrupt in the path to, or the FGDB itself. So, I replaced the parameters in the replaceDataSource() function to call a feature class in our SDE instead. And it worked. lyr.replaceDataSource("Database Connections\example.sde", "SDE_WORKSPACE", "featureclass_example")
... View more
11-09-2018
01:00 PM
|
1
|
1
|
1818
|
|
POST
|
Michael, I used saveACopy. Same as before, the script runs with no error and the print statements print. There were no changes in the *new map. mxd.saveACopy('Beecher_Unit_200U_B_copy.mxd')
EDIT: I ran the script in both IDLE and PyScripter.
... View more
11-06-2018
10:46 AM
|
0
|
0
|
1818
|
|
POST
|
I have a very simple script meant to fix broken map layers by replacing the data source. After talking to an ESRI tech he was saying it could be a problem with the IDE I'm using, or something possibly with the version of Python. I'm using PyScripter which is pointing to Python 2.7.13. 1.) The source \\gisfile\GISmaps\GISstaff\Jared\Hydro.gdb, as seen in the screenshot, is what I want to replace. As a stand-alone script, this does not change anything in the Map. However, it runs with no errors and both print statements print what they're supposed to. for lyr in arcpy.mapping.ListLayers(mxd):
if str(lyr.name) == "Test":
lyr.replaceDataSource(r"\\gisfile\GISstaff\Jared\Hydro.gdb", "FILEGDB_WORKSPACE", "Hydro_WillCounty_Waterways")
print lyr.dataSource
mxd.save()
del mxd
print "+++ Gut +++" \\gisfile\GISstaff\Jared\Hydro.gdb\Hydro_WillCounty_Waterways
+++ Gut +++ 2.) Same thing in IDLE Python 2.7.13. It runs with no errors and both print statements print. But, nothing happens in the map. 3.) If I run the same script in the ArcMap Python pane it will work. import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
for lyr in arcpy.mapping.ListLayers(mxd):
if str(lyr.name) == "Test":
lyr.replaceDataSource(r"\\gisfile\GISstaff\Jared\Hydro.gdb", "FILEGDB_WORKSPACE", "Hydro_WillCounty_Waterways")
print lyr.dataSource
mxd.save()
del mxd
print "+++ Gut +++" I'm going to try and have PyScripter point to Python 3.x. I wanted to check here to see if anyone has seen this before.
... View more
11-06-2018
09:39 AM
|
0
|
5
|
2028
|
|
POST
|
I'm only beginning to understand this. If I create a web app through the developer version of WebApp Builder and download it I can get it to display through my internal server set up through IIS Manager. If I deploy the same app on our production server for our website it will not load. The little I know is that it might be because our server does not have a certificate for https. We're using http.
... View more
10-31-2018
02:14 PM
|
0
|
2
|
938
|
|
POST
|
Irtiza, If you're using ArcGIS API for Javascript 4.9 have a look at this sample code. Multiple popup elements | ArcGIS API for JavaScript 4.9
... View more
10-31-2018
12:40 PM
|
0
|
0
|
1227
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 11-13-2025 08:22 AM | |
| 1 | 11-12-2025 08:37 AM | |
| 1 | 10-22-2025 02:14 PM | |
| 1 | 01-17-2019 08:21 AM | |
| 1 | 07-06-2023 07:08 AM |
| Online Status |
Offline
|
| Date Last Visited |
Friday
|