Getting Started with the Arcgis Web Apis Ben Ramseth, Lloyd Heberlie, Andy Gup What We Want to Cover
Getting Started with the ArcGIS Web APIs Ben Ramseth, Lloyd Heberlie, Andy Gup What we want to cover
• What is Web GIS • Integration with ArcGIS Server • Look at our three Web APIs • Samples • Tips and Tricks Your Presenters for Today
• Ben Ramseth, Instructor Technical Lead, CTT+
• Lloyd Heberlie, Product Engineer, Flex API @lheberlie
• Andy Gup, Technical Lead - Web APIs, Esri Developer Network @agup Who are you?
*Image from Microsoft Clip Art What is Web GIS?
Andy Gup ArcGIS Server – Works with many different clients
ArcGIS .Net Java Explorer iPhone
Open Street Map ArcGIS Desktop SAP Flex/Flash Android
Google Earth Microsoft Silverlight
Bing Maps ArcMap
PHP Ruby JavaScript Python ArcGIS Mobile OpenLayers http://www.esri.com/services/disaster-response/floods/latest-news-map.html http://edn1.esri.com/antarctica http://gis.greeleygov.com/origin/propinfo.html http://maps.bouldercounty.org/boco/emapping/ resources.arcgis.com ArcGIS Server - Architecture
Client Web GIS Data APIs Services Services
Mobile
Javascript Map Services REST File Filesystems JSON Geoprocessing Services IO Flex XML SOAP AMF SQL KML Geocoding Services OGC Silverlight Geodatabases What is a GIS Service?
ArcGIS Server Map Service Edit
Map Service Use Endpoint
Display ArcGIS Server – GIS Services
Mapping Geometry
Search Feature Image
Geocode Geodata ArcGIS Server Globe OGC
Geoprocessing KML Network Analysis
http://esriurl.com/arcgisservices How do I get my data into an app? Web Services!
REST
SOAP
OGC
*Image from Microsoft Clip Art Example ArcGIS REST API Architecture
REST
JSON, XML etc Web Server
lyr, msd, mxd, etc. ArcGIS Client API ArcGIS Desktop
ArcGIS Server
Geodatabase Example REST API usage
URL-based requests (GET or POST)
Format works with all client-side application languages
http://sampleserver1.arcgisonline.com/ArcGIS/rest/servi ces/Specialty/ESRI_StateCityHighway_USA/MapServer/expor t?bbox=-127.8,15.4,-63.5,60.5&f=pjson
ArcGIS Services Directory In the browser: ArcGIS Web APIs
JavaScript
JavaScript Compact Build (Mobile)
Adobe Flex
Microsoft Silverlight
http://esriurl.com/webapis
*Image from Microsoft Clip Art ArcGIS Web API capabilities include……
Map Graphics Query Symbols Editing
Geoprocessing GraphicsLayer Geometries
FeatureLayers Time-awareness
Extents Routing Why use the Web APIs?
Let’s you focus on rapid application development!
map.addLayer(basemap)
vs. http://sampleserver1.arcgisonline.com/ArcGIS/rest/servic es/Specialty/ESRI_StateCityHighway_USA/MapServer/export? bbox=-127.8,15.4,-63.5,60.5&f=pjson Why use the Web APIs?
vs.
dojo.io.script.jsonp_dojoIoScript2._jsonpCallback({"serviceDescription":"","mapName":"Layers","descript ion":"","copyrightText":"","layers":[{"id":0,"name":"arcgis2.DBO.custinfo","parentLayerId":- 1,"defaultVisibility":true,"subLayerIds":null},{"id":1,"name":"arcgis2.DBO.DenverCO_CensusTracts","pare ntLayerId":- 1,"defaultVisibility":true,"subLayerIds":null}],"tables":[],"spatialReference":{"wkid":4326},"singleFus edMapCache":false,"initialExtent":{"xmin":-105.170917848995,"ymin":39.5124265894988,"xmax":- 104.556422044239,"ymax":40.0144928617289,"spatialReference":{"wkid":4326}},"fullExtent":{"xmin":- 105.13659819355,"ymin":39.55113300385,"xmax":- 104.57486577945,"ymax":39.9313831191501,"spatialReference":{"wkid":4326}},"units":"esriDecimalDegrees", "supportedImageFormatTypes":"PNG24,PNG,JPG,DIB,TIFF,EMF,PS,PDF,GIF,SVG,SVGZ,AI,BMP","documentInfo":{"Ti tle":"","Author":"","Comments":"","Subject":"","Category":"","Keywords":"","Credits":""},"capabilities" :"Map,Query,Data"}); Framework for Integrating Multiple services
ArcGIS Server
ArcGIS Online ArcGIS API for JavaScript
Andy Gup Agenda
• What is the ArcGIS API for JavaScript? • ArcGIS.com configurable templates • Inside the API • HTML5 and ArcGIS • Tips and tricks
Why JavaScript?
• Runs natively in all web browsers – no need for a plug-in. • Great starting place for beginners • Many different frameworks available. - EXTJS, Dojo, jQuery, etc. • Many development environment choices - Notepad, Notepad++, Aptana, Visual Studio, etc.
Dojo and the ArcGIS API for JavaScript
• Robust JavaScript Toolkit • Active Community • Dojo Digits - Strong widget system - Grids, charts, toolbars, trees and more • Powerful eventing model • Rich client side graphics dojo example…
dojo.require("esri.map"); function showResults(featureSet) {
//QueryTask returns a featureSet. Loop through features dojo.forEach(featureSet.features,function(feature){ var graphic = feature; graphic.setSymbol(symbol);
//Set the infoTemplate. graphic.setInfoTemplate(infoTemplate);
//Add graphic to the map graphics layer. map.graphics.add(graphic); }); dojotoolkit.org Other JavaScript Libraries
ArcGIS API for JavaScript works with other JavaScript libraries! Configurable Templates
• ArcGIS.com Configurable Templates • Create maps using online tools • Download template to your web server • Config files • Modify code directly ArcGIS.com Inside the ArcGIS API for JavaScript
• Look at key pieces of functionality • Talk about syntax and coding patterns • http://links.esri.com/javascript
*Image from Microsoft Clip Art Adding Map Layers
map = new esri.Map("map");
//Add the topographic layer to the map. var basemap = new esri.layers.ArcGISTiledMapServiceLayer(“http://...”); map.addLayer(basemap);
var featureLayer = new esri.layers.FeatureLayer("http://.../FeatureServer/1", {mode: esri.layers.FeatureLayer.SNAPSHOT, outFields: ["NAME","POP2000","POP2007","POP00_SQMI","POP07_SQMI"] } ); featureLayer.setDefinitionExpression("STATE_NAME = 'South Carolina'"); map.addLayer(featureLayer);
Demo – Feature Layers Geoprocessing
var gp = new esri.tasks.Geoprocessor(“http://server1.../”); var features= []; features.push(graphic); var featureSet = new esri.tasks.FeatureSet(); featureSet.features = features; var params = { "Input_Location":featureSet, "Drive_Times":driveTimes }; gp.execute(params, getDriveTimePolys);
Demo – Geoprocessing HTML5 and ArcGIS
• You can use it today with our JavaScript API • HTML5 samples available in Resource Center
HTML5 Logo by W3C What is HTML5?
HTML + CSS3 + JavaScript
HTML5 Logo by W3C HTML5
• Next standard for HTML • “HTML5” used liberally across the web • Key elements - New semantic tags (e.g.
ArcGIS API for
HTML5 Logo by W3C caniuse Demo HTML5 Geolocation API
navigator.geolocation.getCurrentPosition( zoomToLocation, locationError ); watchId = navigator.geolocation.watchPosition( updateLocation, locationError );
HTML5 Geolocation Demo Cross-browser support
• What do your end-users use? • Laptop vs. Mobile • IE < 9 little to no support for HTML5 • Chrome Frame • Test early – test often!
*Image from Microsoft Clip Art Feature Detection
• Detect if user’s browser supports specific HTML5 feature
var useLocalStorage = supports_local_storage(); var canvasSupport = supports_canvas();
// Source for supports_local_storage function: // http://diveintohtml5.org/detect.html function supports_local_storage() { try { return 'localStorage' in window && window['localStorage'] !== null; } catch( e ){ return false; } } // Does the browser support canvas? function supports_canvas() { return !!document.createElement('canvas').getContext; }
Feature Detection Demo A word about browsers
• JavaScript Engines – major performance enhancements • Native graphics engine improvements • Many updates per year • HTML5, CSS3 support
Browser Performance Demo
http://ie.microsoft.com/testdrive/Default.html
Web Browsers on esri.com
100% Other 90% Safari 80%
70% Firefox
60% Chrome 50% IE6 40%
30% IE7
20% IE8 10% IE9 0% Q1 Q2 Q3 Q4 2011
Source: www.esri.com/visitorstatistics IDE Recommendations
Aptana/Aptana Plugin (v2) Notepad++ Textpad Visual Studio Dreamweaver Eclipse
Getting Started Resources
• Just learning… - http://www.w3schools.com/ • ArcGIS and HTML 5 Live Training Seminar video - http://esriurl.com/arcgishtml5 • When can I use… - http://caniuse.com/ • CSS-TRICKS - http://css-tricks.com/
• Suggested reading (free!) - Eloquent JavaScript
- Dive into HTML5
- Crockford on JavaScript
Suggested JavaScript Sessions
Advanced Development with the ArcGIS API for JavaScript
- Wed. 10:30am – Pasadena Room. Building Your First JavaScript API App
- Tue. 2:45pm – Demo Theater #2 JavaScript and Feature Layers
- Tue. 4:30pm – Demo Theater #2 Using the ArcGIS for Server REST API - Tue. 4:30pm – Primrose B
ArcGIS API for Flex
Lloyd Heberlie Agenda
• Getting Started and Concepts • Inside the ArcGIS API for Flex • Road Ahead • Productivity • Getting more information Demo Desktop (AIR), Desktop Browser (Flash Player), Mobile (AIR) Sharing code across screens Getting Started and Concepts Adobe Flash Platform
Multiscreen Content and Applications
Design / Develop Framework Flex Creative Suite Clients Flash AIR Flash Player Professional
Flash AMF, XML, JSON, SOAP, RSS, ATOM, etc. Catalyst HTTP/S, Sockets, RTMP, etc.
Servers Flash Flash Flash Data Media Platform Flash and Services Builder Server Services Services http://www.adobe.com/devnet/flashplatform.html
Why Adobe Flex Framework?
• Create applications that are, - Interactive, responsive - Easy to extend - Simple, yet powerful • Consistent across browsers, desktops, devices, and operating systems • Highly productive, open source, IDE support • Rich set of components • Strong developer community - http://www.adobe.com/devnet/flex
Flex development overview
Desktop Devices * Browsers ** and Desktop Apps *
Runtime AIR * Flash Player **
Design Source Code Compiled Code Develop ActionScript / MXML .swf / .air Creative Flash Suite Builder Frameworks and SDKs Flex 3rd Party
AMF, XML, JSON, SOAP, RSS, ATOM, etc. HTTP/S, Sockets, RTMP, etc.
Servers and Services Flex development for desktop browsers
• Flash Player running in desktop browsers • http://www.adobe.com/devnet/flashplayer.html • http://www.adobe.com/support/flashplayer/download s.html - Debugger versions • Reference Documentation - http://help.adobe.com/en_US/FlashPlatform/reference/ac tionscript/3/index.html
Flex development for Mobile and Desktop
• AIR for Desktop and Mobile • http://www.adobe.com/devnet/air.html • Build your first mobile Flex application - http://www.adobe.com/devnet/flex/articles/twitter- trends.html • Flex/AIR for iOS - http://www.adobe.com/devnet/air/air_for_ios.html - http://devgirl.org/2011/06/20/flexair-for-ios-development- process-explained/ • Flex/AIR for Android - http://www.adobe.com/devnet/air/air_for_android.html
What do I need to get started?
• Requirements for ArcGIS API 3.x for Flex - Access to ArcGIS Server services * - Adobe Flex 4.5 SDK or higher - Adobe Flash Player 10.2 or higher - Debugger version for developers • Recommendations - Adobe Flash Builder 4.6 (IDE) • Optional - Adobe Creative Suite Release notes | Flex SDK versions
• Flex 4.5.1 or above for Mobile development - Use 4.6 for best mobile coverage • Flex 4.5 SDK build is 4.5.0.20967 and contains: - AIR SDK 2.6.0.19120 - Flash Player 10.2.153.1 • Flex 4.5.1 SDK build is 4.5.1.21328 and contains: - AIR SDK 2.6.0.19120 - Flash Player 10.2.159.1 • Flex 4.6 SDK build is 4.6.0.23201 and contains: - AIR SDK 3.1.0.4880 - Flash Player 11.1.102.55 Flash Builder Welcome Demo Setting up your development environment Code generation / code assist What will I need to know / learn?
• MXML - Declarative XML that gets converted to ActionScript - UIComponent, Skinning and Layout • ActionScript - Based on ECMAScript specification - Programming language for Flash Player and Flex SDK • CSS - Styling UIComponents and Skins • Tip: read the Flex SDK source code!
ActionScript 3 (AS3) fundamentals
• Syntax - http://www.adobe.com/devnet/actionscript/learning/as3- fundamentals/syntax.html • Variables - http://www.adobe.com/devnet/actionscript/learning/as3- fundamentals/variables.html • Conditionals - http://www.adobe.com/devnet/actionscript/learning/as3- fundamentals/conditionals.html • www.actionscriptcheatsheet.com
ActionScript 3 Data Types and Metadata Tags
• uint, int, Number • String, Boolean, Object, Date • Array, ArrayList, ArrayCollection • Dictionary • XML • [Bindable], [Event] • http://www.adobe.com/devnet/actionscript/learning/a s3-fundamentals/data-types.html • http://help.adobe.com/en_US/flex/using/WS2db45492 0e96a9e51e63e3d11c0bf680e1-7ffe.html
Tour de Flex Suggested reading Development web server
• Configure your favorite server-side environment - Apache + Tomcat - IIS + ASP.NET - Configure a Proxy page • Installing a self-signed certificate - http + ssl = https - Helpful for testing resources over https - IdentityManager (secure ArcGIS services)
Thinking about deployment
• Minimum Flash Player installation (10.2) - Wrapper streamlines process • Uncheck enable integration with browser navigation • Use Runtime Shared Library (RSL) • Export “Release build” • Flash Player cross-domain issues - http://www.adobe.com/devnet/flashplayer.html - http://www.adobe.com/devnet/flashplayer/articles/cross_ domain_policy.html - proxy page (for security) Placement of the crossdomain file
Web Server with ArcGIS Server Web Server with application with application and ArcGIS Server crossdomain.xml
Map Map requests requests SWF SWF and and responses responses Inside the ArcGIS API for Flex ArcGIS for Flex history
• Well Adopted • Very active forum • Community code gallery • Release schedule
Flex API Flex Viewer 2012 3.0 3.0 2011 2.3, 2.3.1, 2.4, 2.5 2.3, 2.3.1, 2.4, 2.5 2010 2.0, 2.1, 2.2 2.0 beta, 2.1, 2.2 2008 - 2009 1.0, 1.1, 1.2 and 1.3 ArcGIS for Flex What is your relationship?
• ArcGIS API for Flex - Custom task focused applications - Roll your own: business logic leverage the API - http://links.esri.com/flex • ArcGIS Viewer for Flex - http://links.esri.com/flexviewer - Extends the API - Application Builder - Viewer source code available on Github - https://github.com/ArcGIS/ArcGISViewerForFlex
Demo ArcGIS Viewer for Flex Application Builder: custom widgets Adobe Flash Platform and ArcGIS
Multiscreen Content and Applications
Design / Develop Framework ArcGIS API Flex for Flex Creative Suite Clients Flash AIR Flash Player Professional
Flash AMF, XML, JSON, SOAP, RSS, ATOM, etc. Catalyst HTTP/S, Sockets, RTMP, etc. Servers Flash and ArcGIS Server Builder Services
http://www.adobe.com/devnet/flashplatform.html ArcGIS for Flex development overview
Desktop Devices * Browsers ** and Desktop Apps *
Runtime AIR * Flash Player **
Design Source Code Compiled Code Develop ActionScript / MXML .swf / .air Creative Flash Suite Builder Frameworks Flex ArcGIS API and SDKs for Flex
AMF, XML, JSON, SOAP, RSS, ATOM, etc. HTTP/S, Sockets, RTMP, etc.
Servers Esri services and ArcGIS Server Services How do I get the API?
• Resource center - http://links.esri.com/flex-api/latest-download • Contents - Readme, API library, samples, skins
• API Library: collection of classes and assets (“the swc”)
• Samples: same as the resource center
• Skins: look and feel of a UI component
http://resourcesbeta.arcgis.com/en/communities/flex-api/ ArcGIS API for Flex Resource Center
http://resourcesbeta.arcgis.com/en/communities/flex-api/ ArcGIS API for Flex download What’s in that download? How do I run the samples locally?
Optional: set the output folder url in Flex Build Path settings Demo Resource Center and Samples Binding
• [Bindable] • private myVar:String;
•
http://proceedings.esri.com/library/userconf/devsummit11/tech.html Road Ahead Road ahead
• ArcGIS API 3.x for Flex - Full ArcGIS 10.1 functionality - Support for ArcGIS Online API • ArcGIS Viewer 3.x for Flex - Custom widgets in Application Builder - Hosted applications on ArcGIS.com - Auto upgrade existing application - Thematic / Dynamic layers Widget - Integrating user contributions using Github
What’s next for Adobe and Apache Flex
• Adobe Products and Runtimes - FlashBuilder - Flash Platform Runtimes (AIR, Flash Player) - Desktops (AIR, Flash Player) and Mobile (AIR) - Adobe’s Flex Roadmap - http://www.adobe.com/devnet/flex/whitepapers/roadmap.html - Adobe’s Flash Roadmap - http://www.adobe.com/devnet/flashplatform/whitepapers/roadm ap.html • Apache Flex - http://incubator.apache.org/flex/
Productivity Flash Builder
• Flash Builder Tips and Tricks - Show line numbers - Key Bindings: Cmd(Ctrl) + Shift + L - Organize Imports: Shift + Cmd(Ctrl) + O - Fix Indentation: Cmd(Ctrl) + I - http://www.adobe.com/devnet/flash-builder/articles/tips- tricks.html • Code Templates • File Templates • FlexFormatter Flex Library Projects
Troubleshooting development issues
• Flash Builder debugging - http://www.adobe.com/devnet/flex/articles/flashbuilder_s hortcuts_tips.html • Network Monitors - Fb Network tab, Charles Debugging Proxy, Wireshark, Fiddler • Web Browser Developer Tools - Chrome Developer Tools - Safari Web Inspector - Firefox (Firebug, Httpfox)
Getting More Information Esri Training for Developers http://www.esri.com/training
• Instructor-Led Courses - Building Web Applications Using the ArcGIS API for Flex - Introduction to ArcGIS Server - Creating Effective Web Applications Using ArcGIS Server
• Online Training Seminars - Free, one-hour presentation and demos by Esri technical experts - Live seminar broadcast on a new topic every month
Flex SDK resources
• Adobe Flex Developer Center - http://www.adobe.com/devnet/flex.html • Adobe TV - http://tv.adobe.com/search/?q=Flex • Flex in a week - http://tv.adobe.com/show/flex-in-a-week • Tour de Flex - http://www.adobe.com/devnet/flex/tourdeflex.html • Conferences - Adobe MAX - 360 Flex
Additional resources
• Kuler - http://kuler.adobe.com • Smashing Magazine - http://www.smashingmagazine.com/ • ColorPicker - Hex Color Picker (Mac) - ColorCop (Windows) • ScreenRuler - PixelWindow
2012 Developer Summit: Other sessions
• Advanced Development with ArcGIS API for Flex - Wed 2:45 – 4:00 PM Primrose A (PSCC) • What’s New in ArcGIS API for Flex - Wed 1:00 – 2:15 PM Pasadena/Ventura/Sierra (RH) • Configuring and Customizing ArcGIS Viewer for Flex - Thurs 10:15 – 11:30 AM Catalina/Madera (RH) • Killer Apps: HTML5 and Flex - Wed 4:30 – 5:45 PM Catalina/Madera (RH) • Flex the World - Wed 10:30 – 11:00 AM Demo Theater 2 – Oasis (PSCC) PSCC (Palm Springs Convention Center) and RH (Renaissance Hotel) Summary
• Getting Started and Concepts • Inside the ArcGIS API for Flex • Road Ahead • Productivity • Getting more information ArcGIS API for Silverlight
Ben Ramseth ArcGIS API for Silverlight Outline
• Getting Starting with Silverlight • Inside the ArcGIS API for Silverlight • Creating a Simple Application • Adding Toolkit Controls • Integrating Silverlight Control Events • Actions and Behaviors • Performing a Query Task
ArcGIS API for Silverlight starting points
Resource Center
Start from scratch Templates Viewer Setting up the Silverlight Environment
Tools IDE Runtime
ArcGIS API for Silverlight Downloading the ArcGIS API for Silverlight Demo Assemblies Namespaces
Client assembly
Geometry namespace
Geometry classes Classes
Map class
Map class’s properties
Scale property Class Diagrams Application road map ArcGIS Online Map Services
HTML JS XAP Files
REST REST Image files Features as JSON
IIS
Visual Studio Silverlight Tools 5 Web Browser Web page html file Silverlight Runtime 5 Silverlight plug-in Silverlight.js file ArcGIS API for Silverlight 3.0 Silverlight control’s xap file Creating a Silverlight Web Mapping Application Demo ArcGIS Toolkit Controls
http://esrisilverlight.codeplex.com/ Binding controls to a map Adding Toolkit Controls Demo Programming events with code behind
Button’s Click event Name of a C# function in the code behind Events have code behind
ArcGIS controls have event
Integrating Silverlight controls
Rectangle StackPanel RadioButtons Integrating Silverlight Control Events Demo ArcGIS controls have behaviors and actions
Adding a Behavior Demo Query task workflow
What state do you want to see? FeatureSet
Feature Attributes
Create Send Execute Receive query query to task FeatureSet Collect server to Return and user execute results display Inputs to client results Geometry Performing a Query Demo Getting Started Resources
• Silverlight… - http://silverlight.net - http://www.microsoft.com/silverlight - http://expression.microsoft.com • ArcGIS API for Silverlight … - http://help.arcgis.com/en/webapi/silverlight/3.0/index.html
• ArcGIS Blog… - http://blogs.esri.com/esri/arcgis/category/developer/ Suggested Silverlight Sessions
What's New in ArcGIS API for Microsoft Silverlight Tue 2:45pm Primrose C/D (Palm Springs Convention Center) Configuring and Customizing ArcGIS Viewer for Silverlight Wed 1:00pm Primrose B (Palm Springs Convention Center) Advanced Development with ArcGIS API for Microsoft Silverlight Thu 8:30am Catalina/Madera (Renaissance Hotel) Programming Image Services Using ArcGIS API for Microsoft Silverlight Wed 4:30pm Smoketree A - E (Palm Springs Convention Center)
Wrap Up Key points to remember
• Three web APIs to choose from • JavaScript is native • Silverlight and Flex are plug-in based • Viewers and Application Builders • Consume resources from ArcGIS.com • http://resources.arcgis.com • Forums, Code Samples