GIS Life Blog - Page 8

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Latest Activity

(463 Posts)
ThomasColson
MVP Alum

In order to support a very large number of map consumers, that don't ever edit anything or create data, I rely on AGOL to host Map (Hosted Feature Services), hook those back to Portal as "Items", and keep my ArcGIS Server Farm service instances low, only spawning what is needed to support editors. Through security controls, the map service that automatically comes with a feature services is un-discoverable. I don't want people hitting the map services and spawning more service instances. This is in effect a "Collaboration"for people that can't enable Collaboration on their Portal. 

https://www.esri.com/arcgis-blog/products/api-python/analytics/updating-your-hosted-feature-services... has been pretty handy for the past few years, via a scheduled task, it updates (nightly) several hundred feature services by pulling data from SDE into a Pro Project and overwriting what's on AGOL. Unfortunately, it doesn't allow you to preserve "Allow Export to other formats" setting on AGOL. 

Enter https://pro.arcgis.com/en/pro-app/arcpy/sharing/introduction-to-arcpy-sharing.htm, which I've finally rolled my sleeves up on and have converted all my python doo-hickeys to use https://pro.arcgis.com/en/pro-app/arcpy/sharing/featuresharingdraft-class.htmhttps://pro.arcgis.com/en/pro-app/tool-reference/server/stage-service.htm, and https://pro.arcgis.com/en/pro-app/tool-reference/server/upload-service-definition.htm. Coincidentally there's a lot more options to control service parameters. 

Disclaimer: I know nothing about python, so I'm sure there's all sorts of inefficiencies in here, but it works. 

import arcpy
import sys, string, os, calendar, datetime, traceback,smtplib
from arcpy import env
from subprocess import call

# Mail Server Settings
service = "GRSM_SASQUATCH"
sd_filename = service + ".sd"
try:
    d = datetime.datetime.now()
    log = open("C:\\PYTHON_LOGS\LOG."+service+".txt","a")
    log.write("----------------------------" + "\n")
    log.write("----------------------------" + "\n")
    log.write("Log: " + str(d) + "\n")
    log.write("\n")
# Start process...
    starttime = datetime.datetime.now()
    log.write("Begin process:\n")
    log.write("     Process started at " + str(starttime) + "\n")
    log.write("\n")
    
    # Mail Server Settings
    SERVER = "1.2.34"
    PORT = "25"
    FROM = "sasquatch@big.foot.com"
    MAILDOMAIN = '@big.foot.com'
    # Data Steward getting the email. Needs to be their email address...without @big.foot.comat the end
    userList=["yeti"]
    # get a list of usernames from the list of named tuples returned from ListUsers
    userNames = [u for u in userList]
    # take the userNames list and make email addresses by appending the appropriate suffix.
    emailList = [name +  MAILDOMAIN for name in userNames]
    TO = emailList
    # Grab date for the email
    DATE = d

    # Sign in to portal
    arcpy.SignInToPortal('https://www.arcgis.com', 'userid', 'password')

    # Set output file names
    outdir = r"C:\PRODUCTION\GRSM_SASQUATCH"
    sddraft_filename = service + ".sddraft"
    sddraft_output_filename = os.path.join(outdir, sddraft_filename)
    #Delete any left over SD files from failed previous run
    try:
        os.remove(sd_filename)
        print("Successfully deleted ", sd_filename)
    except:
        print("Error while deleting file ", sd_filename, ", perhaps it doesn't exist")
    try:
        os.remove(sddraft_output_filename)
        print("Successfully deleted ", sddraft_output_filename)
    except:
        print("Error while deleting file ", sddraft_output_filename, ", perhaps it doesn't exist")        

    # Reference map to publish
    aprx = arcpy.mp.ArcGISProject(r"C:\PRODUCTION\GRSM_SASQUATCH\GRSM_SASQUATCH.aprx")
    m = aprx.listMaps("GRSM_SASQUATCH_LOCATIONS")[0]

    # Create FeatureSharingDraft and set service properties
    # https://pro.arcgis.com/en/pro-app/arcpy/sharing/featuresharingdraft-class.htm
    sharing_draft = m.getWebLayerSharingDraft("HOSTING_SERVER", "FEATURE", service)
    sharing_draft.summary = "Sasquatch Locations"
    sharing_draft.tags = "Sasquatch, Fur, Hairy, Big Foot"
    sharing_draft.description = "Hide and Seek Champion"
    sharing_draft.credits = "Yeti"
    sharing_draft.useLimitations = "This is not real"
    #sharing_draft.portalFolder = "Front Country"
    sharing_draft.overwriteExistingService = "true"
    sharing_draft.allowExporting = "true"

    # Create Service Definition Draft file
    sharing_draft.exportToSDDraft(sddraft_output_filename)

    # Stage Service
    # https://pro.arcgis.com/en/pro-app/tool-reference/server/stage-service.htm
    sd_output_filename = os.path.join(outdir, sd_filename)
    arcpy.StageService_server(sddraft_output_filename, sd_output_filename)

    # Share to portal
    # https://pro.arcgis.com/en/pro-app/tool-reference/server/upload-service-definition.htm
    print("Uploading Service Definition...")
    arcpy.UploadServiceDefinition_server(sd_output_filename,
                                         "My Hosted Services",
                                         "",
                                         "",
                                         "EXISTING",
                                         "existingFolder",
                                         "",
                                         "OVERRIDE_DEFINITION",
                                         "SHARE_ONLINE",
                                         "PUBLIC",
                                         "SHARE_ORGANIZATION",
                                         ["GRSM","Great Smoky Mountains National Park Open Data"] )

    # Clean up SD files
    try:
        os.remove(sd_filename)
        print("Successfully deleted ", sd_filename)
    except:
        print("Error while deleting file ", sd_filename, ", perhaps it doesn't exist")
    try:
        os.remove(sddraft_output_filename)
        print("Successfully deleted ", sddraft_output_filename)
    except:
        print("Error while deleting file ", sddraft_output_filename, ", perhaps it doesn't exist")        

    # Write nothing to log if success.
    endtime = datetime.datetime.now()
    log.write("     Completed successfully in " 
           + str(endtime - starttime) + "\n")
    log.write("\n")
    log.close()
    print('done')

except:
    
 # Get the traceback object
    tb = sys.exc_info()[2]
    tbinfo = traceback.format_tb(tb)[0]
 # Concatenate information together concerning 
 # the error into a message string
    pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
    msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
# Return python error messages for use in 
# script tool or Python Window
    arcpy.AddError(pymsg)
    arcpy.AddError(msgs)
# Print Python error messages for use in 
# Python / Python Window
    log.write("" + pymsg + "\n")
    log.write("" + msgs + "")
    log.close()
    # Define email message if something went wrong
    SUBJECT = "Notification of Un-Successful AGOL Update of "+service 
    MSG = "Did Not Update: {} - ID: {} at "+ str(DATE)+ "; " +pymsg + "; " + msgs
    print (MSG)
    print (emailList)
 
    # Send an email notifying steward of successful archive
    #MESSAGE = "\ From: %s To: %s Subject: %s %s" % (FROM, ", ".join(TO), SUBJECT, MSG)
    MESSAGE = "Subject: %s\n\n%s" % (SUBJECT, MSG)
    try:
            try:
                print("Connecting to Server...")
                server = smtplib.SMTP(SERVER,PORT)
                try:
                    print("Login...")
                    try:
                        print("Sending mail...")
                        server.sendmail(FROM, TO, MESSAGE)
                    except Exception as e:
                        print("Send Error Mail\n" + e.message)
                except Exception as e:
                    print("Error Authentication Server: check the credentials \n" + e.message)
            except Exception as e:
                print("Error Connecting to Server : check the URL of the server and communications port ( 25 and ' the default ) \n" + e.message)
     
            print("Quit.")
            server.quit()
     
    except Exception as e:
            print (e.message)    
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

more
4 1 1,040
BernSzukalski
Esri Frequent Contributor

The destructive fires in the Amazon are causing global concern, and are in the news...So here's a really quick app leveraging ArcGIS Online and Living Atlas content that provides a closer look. It took about about 5 minutes to come up with this very simple app shown below:

BernSzukalski_0-1605911976949.jpeg

Learn how it was created.

Read more...

more
2 0 1,446
by Anonymous User
Not applicable

Where is the nearest early voting site by my house? Where is the nearest pharmacy to this clinic? Where is the nearest Pho restaurant by my dog's hair stylist? These are all questions that your community needs answered. Luckily in just 45 seconds, you can build an application that empowers the community to find the answer on their own, and looks 100% awesome on mobile. 

Rapidly create an application using pre-configured app templates. Just share the map as an app!

Using ArcGIS Configurable Apps, users can rapidly create applications for both browsers and mobile devices.

This is accomplished with the suite of ready-to-use app templates in ArcGIS Online. Just add points to a web map, save it, then share with an app template! It is really that simple: no development, no design. Just minor configurations that can be done in seconds.

App templates look great on mobile too!

Looks and performs great on mobile devices

In this example, I'm using some Emergency Operations Centers from the Living Atlas; a massive library of geospatial content. However, this could just as easily be your organization's point layer of pharmacies, voting sites, homeless shelters, mobile clinics, drop off sites--anything your community needs to find! 

About In a GIF:

Every Friday, I take a few seconds of my day to demonstrate a cool feature of the ArcGIS platform, and share it with you all! The goal is to show how easy it is to create incredible products using tools available in the Esri environment.

We've all seen "look how easy this tool is to use" demos before, using curated data and copy-pasta code. So, to truly demonstrate going from zero-to-hero, In a GIF follows three simple rules:

 In a GIF Rules:

1) The .gif must be less than 45 seconds.

2) No cutting time from the .gif

3) No pre-prepared code allowed.

more
1 0 1,091
by Anonymous User
Not applicable

Blurry. Fuzzy. Non-clicky. Out of date. These are all of the qualities of the peach that I left in the fridge over the weekend at the Esri DC office. They are also the qualities of that screen-grab of an Excel chart you've just embedded on the front page of your website or StoryMap.

In just 45 seconds (yes, this one went a little longer because I wanted to show the final product), you can create an interactive graph that can be embedded directly into your website. As your data updates, so will the chart! This is accomplished by adding your CSV to ArcGIS Online as a hosted layer. Then, pull the hosted layer into Operations Dashboard via the Serial Chart widget, save it, share it, and embed! 

Operations Dashboard can be used to create an embeddable chart.

Did you know: Operations Dashboard is already included with your ArcGIS Online account. Just click the app launcher in your organization's home page.

Here is a sample of the CSV being pulled into ArcGIS Online. This could just have easily been a feature class!

CaseNumberYear
12014
22014
72015
82015
92015
402016
412016
422016

About In a GIF:

Every Friday, I take a few seconds of my day to demonstrate a cool feature of the ArcGIS platform, and share it with you all! The goal is to show how easy it is to create incredible products using tools available in the Esri environment.

 

We've all seen "look how easy this tool is to use" demos before, using curated data and copy-pasta code. So, to truly demonstrate going from zero-to-hero, In a GIF follows three simple rules:

 

 In a GIF Rules:

1) The .gif must be less than 45 seconds.

2) No cutting time from the .gif

3) No pre-prepared code allowed.

more
2 0 817
by Anonymous User
Not applicable

This week's .gif features LocateXT, a powerful text extraction tool accessible in ArcGIS Pro. This extension can be used to plot coordinates and placenames, extract attributes, and rapidly iterate through massive folders of documents. For more information, visit the product page.

LocateXT extracts the coordinates of every shipwreck in a wikipedia article and plots them on a map.

LocateXT can rapidly discover geodata in unstructured text, then convert it to points on a map.

Shout-out to Maren John for inspiring this application of pulling from a source like Wikipedia!

About In a GIF:

Every Friday, I take a few seconds of my day to demonstrate a cool feature of the ArcGIS platform, and share it with you all! The goal is to show how easy it is to create incredible products using tools available in the Esri environment.

We've all seen "look how easy this tool is to use" demos before, using curated data and copy-pasta code. So, to truly demonstrate going from zero-to-hero, In a GIF follows three simple rules:

 In a GIF Rules:

1) The .gif must be less than 45 seconds.

2) No cutting time from the .gif

3) No pre-prepared code allowed.

more
11 3 2,697
AndresCastillo
MVP Alum

This is the general methodology I used to add custom logic to an application, when there is not much documentation on the app's core codebase:

1
Inspect the desired element on the web browser to determine CSS class responsible for the element.
You can get access to the DOM elements underneath this CSS class using the appropriate JS DOM method, such as document.getElementsByClassName("").

Be aware that an app may use different CSS classes for the UI element for desktop vs mobile deployments.
Once you narrow down the desired DOM node, you can apply a custom JavaScript logic to it to make it do something.

2
Find the source code file responsible for making the html UI element interactive:

If there are many source JavaScript files in the app, try starting with the JavaScript file named as 'common sense' would have it.
For example, since we were trying to modify popup behavior, we start by looking at a file with a similar name, such as popupManager.js.

Add breakpoints to all the methods in this file, to use with the Chrome Dev tools.
This helps understand code.
Observe the app's UI for changes.
Using Chrome's debugger:

Using step over, Identify the specific method responsible for making the html UI element interactive.

Sometimes you might notice that several functions are responsible for making the html UI element interactive.
To narrow down which of the is most relevant to the UI element, see which function is called 100% of the time.
The other functions might not always be called, thus risking skipping the custom code.

Once you identify the appropriate method, step into that function to see what other logic it contains, either from the same js file, or another js file in the app, aside from what is written on-screen in the file.
This will reveal other possible files in the application that have functions that are called for the desired html UI element.

Remove the breakpoints for the functions that didn't do anything pertinent to what we want to do.

3
Determine the best place to insert the custom logic within the JavaScript files identified in step 2.

You must find a way to wire up/connect your custom logic between the application's logic and presentation files (i.e. js and html files, respectively).

 

 

 

 

 


Takeaways:

Chrome Dev tools:
Resume script execution let's you go from breakpoint to breakpoint.
Step over takes you one step at a time through each line of code.
Step into allows you to go inside the function to see what other logic it contains, either from the same js file, or another js file in the app, aside from what is written on-screen in the file.

Note that even if your custom logic works via one way of interacting with the app's UI, you still need to consider other ways the users would access the same UI functionality by interacting with the app a different way.

If that's the case, also insert your custom logic in the appropriate files that affect the UI functionality.

In other words, the app might have different ways of accomplishing the same task for the user.

You need to address all possible ways the user might interact with that task for your custom logic to work flawlessly under many scenarios.


A '.' specifies css class.

 

 


To deploy an app locally for testing:
control panel....
turn windows features on or off
enable IIS.......
enable ftp server
enable ftp extensibility
get admin permission to create files in C:\inetpub\wwwroot
Move desired deploy apps to this folder.
to access url, replace localhost with directory up to the app folder.

 

 

index.html seems to not load because of CORS policy when run app locally:
To handle CORS policy error:

To bypass CORS policy temporarily for development:
from windows+r
chrome.exe --user-data-dir="C:/Chrome dev session" --disable-web-security
only valid for one chrome instance.

or

To bypass cors policy permanently:
google web.config
https://enable-cors.org/server_iis7.html

Developer Communities

Web AppBuilder for ArcGIS

Web AppBuilder Custom Widgets

GP dev group

GIS Developers

Geo Developers

ArcGIS API for JavaScript

Bootstrap

HTML5, CSS, JavaScript, and JavaScript Frameworks

.NET and the Esri JavaScript API

Esri Leaflet

AngularJS

ArcGIS Server with JavaScript API

more
2 0 1,944
AdrianWelsh
MVP Honored Contributor

I thought about doing a play-by-play recap of my experience at the Esri User Conference but then thought that would be pretty boring to other people. So instead, this is my “color commentary” of some of the highlights, lowlights, and medium-lights? Is that a thing? And my general, stray thoughts overall.

 

I wonder how much time the marketing team spends on making these four-word slogans. I like them and think the marketing group does an excellent job. This year it was “See What Others Can’t”, replacing “The Science of Where”.

Early in the plenary, Jack Dangermond guaranteed that there will be no earthquakes during the week of the UC because he can “see what others can’t”! Video link

 

It was cool to watch Jane Goodall chat with Jack and E.O. Wilson. I wonder if it would have been better if it were a little scripted instead of ad-libbed.

The Good highlights:

  • The weather was amazing. It is always amazing in San Diego, but this year was particularly amazing. I know this is not in control of Esri and the conference (or is it?), but still. Along with that, the food in San Diego is also amazing. I love getting the fresh sea food and Mexican food (and combining the two).
  • I saw a few people wearing map shirts and map dresses. This is purely awesome and I kind of wished I had one. I was a little creepy and took some ‘spy’ photos of these people (sorry for invading your privacy but your clothes were too cool to pass up):

    • Ken Field‌ is always sporting awesome stuff
  • Whose license plate is this? It is truly awesome:

  • It is always super cool meeting people that I interact with on GeoNet. For some reason I never found Owen Evans, but I did run into Kory Kramer, Kelly Gerrow, and Melita Kennedy, as well as the GeoNet staff of Christopher Catania, Michelle Mathias, Leslie Fountain, Louise Branscomb, and Pea, I think? I also got to meet up with awesome GeoNet users like Curtis Price, Ken Buja, Andres Castillo, William Craft, Chelsea Rozek, and Ted Cronin (as well as Amy Niessen, Kirsten Pinkston, and John Foster).
  • Giving out reusable aluminum water bottles was a cool idea, especially with different hydration stations around:
  • Before a Survey123 class with James Tedrick, Ismael Chivite, and Elvin Slavik, they made everyone stand up and stretch. I thought that was pretty awesome:
  • My son and I got to meet Jack at Balboa Park:
  • This pint glass I got from the fine folks at GeoNet is terrific:

The Medium-sized highlights:

  • Kory Kramer and others presented on ArcGIS Tips and Tricks and it was awesome. I picked up a cheat sheet that he had made for shortcuts but cannot find that in PDF form anywhere. Where can I find that?
  • noticed that most of the talks are from Esri personnel. I mean, I want to go to the Esri-based talks to get the technical training from the horse’s mouth. There were a few ‘paper sessions’ but I did not want to ‘waste’ one of my time slots when I could have gone to a talk/training on something I work with daily. But what happened to presentations like, “A Spatial Analysis of the NCAA Basketball Tournament” and other fun type of topics?  I guess this is just kind of a random rant/thought but it is something I thought about while at the conference.
  • I thought it was really random that Kevin Eubanks was there to play a song and more so that he allegedly has been to a few conferences. Growing up watching Jay Leno made me appreciate this more. He sure has not aged in 20 years! Video clip.
  • liked seeing the ArcGIS Pro Parcel Fabric introduction that’s new in 2.4.

The Not-so-good highlights/lowlights:

  • There are just too many people. I love seeing how big this conference is and meeting people from all over the world as well as finding the top experts of every field. But it is just packed, packed, packed. During the plenary I saw many sections that were completely filled and a few rows of people who had to stand in the back. I heard rumors of people saying that San Diego is no longer large enough to hold this show and Esri needs to start looking elsewhere. From what I understand, San Diego has the seventh largest convention center in America. All the other places are in cities way less desirable than San Diego. I know Esri has San Diego booked out for a few more years but what will happen?
  • Some vendors seemed like they just did not care. I know this is not really a fair assessment but on more than one occasion, I spoke with a vendor about a product I needed or was interested in and they just did not seem to want to engage and promote/sell their product. I found that a little odd. I will not name names either.
  • know there was some grumbling about extending vendor hall time to 4 pm on Thursday when it used to be noon on Thursday. Many of the vendors did not want to be at the vendor hall that long after two grueling long days before.
  • There were too many talks and too many overlapping talks. I wanted to go to several talks that were in the same time slot. This happened at nearly every time slot. But, again, this is a huge conference with every discipline, so this is likely how it has to be. I know there were some repeat talks but those did not always work out either.
  • Balboa Park. This place is amazing, and I would not want to miss going to the Balboa Park Party. But I am guessing that this had to have been the most attended party, or maybe it was just me. I feel like I have never seen it so crowded. It was on the verge of unpleasant on how busy it was.
  • On top of it being mega-crowded at Balboa, some of the food ran out. I know that it is likely first come first serve but we had to fight through a few crowds just to get the BBQ type food. It was good too, but I wish it was not that stressful!
  • want to know, do people who work for Esri have fun at this conference? I do not know what it is like being on the other side (Esri-personnel side) but it just seems that most Esri employees are working 24/7 at this conference, going non-stop, and working super hard. I have not seen anyone complain or look irritated, but I wonder how I would feel working that hard and possibly not getting to enjoy different talks, different vendors, or San Diego in general.

Overall, the conference is extremely well-run, hardly any technical issues, and just the best place to be for GIS professionals. My wife would ask me, “How come you care so much about these talks to where you’re early and sit in the front row but didn’t care that much in school?!?” I am lucky that I get to go and hope to continue to keep going. I get as much out of it as I possibly can.

 

Thanks for reading!

You can find my Twitter feed during the conference here.

 

more
17 21 5,755
Egge-Jan_Pollé
MVP Alum

https://community.esri.com/people/EPolle_TensingInternational/blog/2019/06/02/aan-de-slag-met-arcgis... 

Ga naar XY met RD-coördinaten

In de oefening van vandaag bouwen we een dialoogvenster (een <form>) waarin gebruikers een X- en een Y-coördinaat op kunnen geven om op basis hiervan op een locatie in te zoomen.

De functie die hiervoor geschreven is (goToRDXY - zie de code hieronder) vangt de invoer van de gebruiker af. Als de invoer correct is, dan wordt een puntobject aangemaakt. Dit puntobject wordt op de kaart geplaatst, en er wordt naartoe gezoomd. Hieronder staan de coördinaten van enkele willekeurige locaties, om de applicatie mee te testen.

LocatieXY
Vrijthof, Maastricht176220317750
Strandpaviljoen de Piraat, Cadzand15940378700
Rode Vuurtoren, Schiermonnikoog205405611450

En weet je wat zo leuk is? Het formulier werkt de hele foutafhandeling af.

De RD-coördinaten moeten immers binnen bepaalde waarden liggen (zie hiervoor de afbeelding in https://community.esri.com/people/EPolle_TensingInternational/blog/2019/05/11/aan-de-slag-met-arcgis... ).

Maar als de gebruiker nog niet de juiste waarden heeft ingevuld, dan doet de knop Ga naar locatie het nog niet. De foutafhandeling verschilt per browser, maar pas als er twee vinkjes staan, kan de gebruiker doorgaan

Bovenaan in de code is wat aanvullende CSS toegevoegd om de look-and-feel van het dialoogvenster en het formulier te beïnvloeden.

Klik hier om het resultaat te zien:

Aan de slag met ArcGIS JavaScript - Ga naar XY (RD-coördinaten) 

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
  <title>Aan de slag met ArcGIS JavaScript - Ga naar XY (RD-coördinaten)</title>
  <style>
    html, body, #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
      font-family: sans-serif;
    }
    .dialogDiv {
      background-color: white;
    }
    .dialogHeader {
      color: white;
      font-weight: bolder;
      width: auto;
      background-color: #3c84a7;
      padding: 5px;
    }
    .coordinatesDiv {
      background-color: white;
      padding: 10px;
    }
    fieldset {
      border: 1px solid grey;
      margin: 10px;
    }
    legend {
      padding: 1em 0.5em;
      font-size:90%;
    }
    input:invalid+span:after {
      content: '✖';
      padding-left: 5px;
    }
    input:valid+span:after {
      content: '✓';
      padding-left: 5px;
    }
  </style>
  <link rel="stylesheet" href="https://js.arcgis.com/4.12/esri/css/main.css">
  <script src="https://js.arcgis.com/4.12/"></script>
  <script>  
      require([
        "esri/Map",
        "esri/geometry/Point",
        "esri/views/MapView",
        "esri/Graphic"
      ], function(Map, Point, MapView, Graphic) {

      var map = new Map({
        basemap: {
          portalItem: {
            id: "7aea6fa913a94176a1074edb40690318" // Topo RD
          }
        }
      });

	  var view = new MapView({
	    spatialReference: 28992, 
	    container: "viewDiv",
	    map: map,
	    center: new Point({x: 155000, y: 463000, spatialReference: 28992}),
	    zoom: 3
	  });

      view.ui.add("rdCoordinatesDiv", "bottom-left");

      var simpleMarkerSymbol = {
        type: "simple-marker",
        style: "triangle",
        angle: 180,
        size: 16,
        yoffset: 8, // De onderste punt van de driehoek wijst naar de locatie met de opgegeven coördinaten
        color: [255, 0, 0],
        outline: {
          color: [255, 255, 255],
          width: 2
        }
      };

      // Maak een Graphic aan zonder geometrie - deze wordt later toegevoegd
      var xyMarkerOnTheMap = new Graphic({
        symbol: simpleMarkerSymbol
      });

      // Voeg de 'onzichtbare' Graphic toe aan de view
      view.graphics.add(xyMarkerOnTheMap);

      // Event Listener
      document.getElementById("rdCoordinatesForm").addEventListener("submit", goToRDXY);
      
      // Functie
      function goToRDXY (event) {
        event.preventDefault() // De preventDefault() method wordt hier gebruikt om te voorkomen dat het formulier gesubmit wordt. Input wordt lokaal - in deze functie - verwerkt.
        xyMarkerOnTheMap.geometry = null;
        let rdX = document.getElementById("rdXCoordinate").value;
        let rdY = document.getElementById("rdYCoordinate").value;
        let target = new Point({x: parseFloat(rdX), y: parseFloat(rdY), spatialReference: 28992});
        xyMarkerOnTheMap.geometry = target;
        console.log(target);
        view.goTo({target: target, zoom: 13});
      }
    });
  </script>
</head>
<body>
  <div id="viewDiv"></div>
  <div class="dialogDiv" id="rdCoordinatesDiv">
    <div class="dialogHeader">
      Ga naar XY
    </div>
  <form id="rdCoordinatesForm">
    <fieldset>
      <legend>RD-coördinaten (EPSG: 28992)</legend>
      <div class="coordinatesDiv">
        <label for="rdXCoordinate">X-coördinaat:</label>
        <input id="rdXCoordinate" type="number" name="rdXCoordinate" step="0.001" min="10000" max="290000" required>
        <span class="validity"></span>
      </div>
      <div class="coordinatesDiv">
        <label for="rdYCoordinate">Y-coördinaat:</label>
        <input id="rdYCoordinate" type="number" name="rdYCoordinate" step="0.001" min="300000" max="620000" required>
        <span class="validity"></span>
      </div>
    </fieldset>
    <div class="coordinatesDiv">
      <input type="submit" value="Ga naar locatie">
    </div>
  </form>
  </div>
</body>
</html>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

more
0 0 261
BernSzukalski
Esri Frequent Contributor

Attachment Viewer is a new (as of the July, 2019, ArcGIS Online release) configurable app. It's intended to provide an easy way to browse feature layer attachments of all types - images, photos, documents, videos, and more. It can be used to view photos captured with Collector for ArcGIS, Survey123, QuickCapture, and other field and desktop apps.

BernSzukalski_0-1605912677886.jpeg

Read more...

more
0 0 614
110 Subscribers