Top Banner
ArcGIS API for JavaScript Building Mobile Web Apps Andy Gup, Esri US
93

ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Jul 10, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

ArcGIS API for JavaScriptBuilding Mobile Web Apps

Andy Gup, Esri US

Page 2: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

AgendaWhat’s mobile?

Bootstrap

Geolocation

Performance

Page 3: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Think Mobile First!

Page 4: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Default Behavior

Page 5: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Default BehaviorDesktop app on Mobile

Page 6: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Default BehaviorDesktop app on Mobile

Page 7: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Default BehaviorDesktop app on Mobile

Page 8: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

SluggishUI JankMissing UI piecesPoor UX

Default BehaviorDesktop app on Mobile

Page 9: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Apps specifically built for mobileField data collectionDeploy to StoreCitizen 411Finder appsGames…Many more!

Page 11: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Mobile devices are different

Device capabilities

Screen size

No mouse!

Page 12: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Mobile devices are different

Page 13: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Bandwidth constrained

Page 14: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Memory constrained

Page 15: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Memory constrainedNexus 6P (top of the line)32 GB phone Snapdragon 810 processor

But only…3 GB RAM!!

Page 16: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

User Experience == very different

TouchOrientationOnscreen keyboardVoice

Page 17: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

User Experience == very different

Page 18: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Design patterns == very different

Smaller screensScreen orientation can rotateMobile popups and overlaysTouch-based navigation

Page 19: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Design patterns == very different

Page 20: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Design patterns == very different

Page 21: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Mobile in 4 Steps

Page 22: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Step #1Organize your data

Page 23: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Get your data in order, first!

Develop a schemaDesign tablesDefine relationshipsClean the dataTest, test, test

Page 24: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

HTTP Request/Response Performance

Test Service response payload sizeSimplify geometries!Remove unneeded attributes

VS.

Page 25: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

HTTP Request/Response Performance

DEMO

Page 26: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

HTTP Request/Response Performance

Enable webserver gzip compressionUse ArcGIS JavaScript OptimizerMinimize, concatenate your .js and .css

Page 27: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

gzip compression

All modern browsers support itAll modern browsers will request itServer needs to be configured

Page 29: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Content-Encoding: gzip

Page 30: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Step #2Sketch, mockup, design

Page 31: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured
Page 32: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Think Mobile First!

Page 33: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Not Desktop First!

Page 34: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Site shouldn’t look the same on all devices

Page 35: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Create at least 3 viewports

min-device-width: 320px

Page 36: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Consider additional viewports

min-device-width: 320px

Page 37: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Consider additional viewports

Depending on your end-usersMany different CSS media query configurations

Page 38: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

CSS Media Queries

Page 39: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Consistent Hierarchy

Map

Widget

Map

Widget

Map

Widget Other content

Other contentOther

content

Page 40: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Step #3Implement UI framework

Page 41: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Many UI frameworks

BootstrapjQueryDojo. . . ?

Page 42: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured
Page 43: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

1. Fluid Grid System2. CSS Media Queries3. HTML5, CSS & JavaScript

Bootstrap Framework

Page 44: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Fluid Grid System

• Layout adapts to different screen sizes

• Based on percentages• 12 column / 960px

Page 46: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Get bootstrap-map-js

github.com/Esri/bootstrap-map-js

Page 47: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Bootstrap Fluid Grid CSS

<div class="col-xs-12 col-sm-8>

Define Column

Device Size

Number of Columns

Page 48: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Hello World

Page 49: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Add package path

Page 50: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Add jQuery & bootstrap.js

Page 51: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Add JS API and BootstrapMap

Page 52: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured
Page 53: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Step #4Display and Rendering Data

Page 54: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Simplify features - Generalize

maxAllowableOffset

ArcGIS Online feature services use it

Page 55: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Simplify features - Generalize

Page 56: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Simplify features - Generalize

Page 57: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Query MODE_ONDEMAND

Zoom-in to reduce number of features

Page 58: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Query MODE_SNAPSHOT

Number of features being returned?Test request/response performanceFeatures have to be renderedBe aware of memory usage

Page 59: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Step #5Build test

Page 60: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Build > test > repeat

Unit testingPerformance testingNetwork interrupt testingTest on actual devicesTest on different operating systems

Page 62: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Geolocation

Page 63: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Geolocation

github.com/Esri/html5-geolocation-tool-js

Page 64: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

GeolocationWorks online and offlineApproximate location only! Always requires user opt-inSame exact API for PhoneGap

Page 65: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured
Page 66: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Resourceshttp://www.andygup.net/web-mobile/https://github.com/Esri/html5-geolocation-tool-jshttps://github.com/Esri/quickstart-map-phonegaphttps://github.com/Esri/jquery-mobile-map-js

Page 68: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured
Page 69: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Bonus slides!

Page 70: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

How-toBuild a Multiple-view app

Page 71: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Multiple-View Design• Framework for single page apps with

multiple views• Similar to native look, feel and

behavior• Cross-browser

Page 72: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Get jquery-mobile-map-js

https://github.com/Esri/jquery-mobile-map-js

Page 73: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Desktop vs. Device

Page 74: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Desktop vs. Device

Page 75: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

VIEW 1 VIEW 2

Page 76: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured
Page 77: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

<html>

<div data-role=“page” id=“page1”>

</div>

<div data-role=“page” id=“page2”>

</div>

</html>

One HTML page

Multiple Views

Page 78: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Add Some CSS

Page 79: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Add a little more CSS

Page 80: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Add 2 pages

Page 81: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Add jQuery & bootstrap.js

Page 82: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Add jQuery & ArcGIS JS API

Page 83: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Add the map

Page 84: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

VIEW 1 VIEW 2

Page 85: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured
Page 86: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Web, hybrid or native?

Page 87: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Web

Web = HTML, JavaScript, CSS skillsCross-browser, cross-deviceNo special access needed to sensorsNo special storage needs

Page 88: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Hybrid

Hybrid = Native Chrome-less browser plusHTML, CSS, JavaScriptExample: PhoneGap/Cordova

Compiled as a native applicationAccesses device via browser APIs & plug-ins

Page 89: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Hybrid

JavaScript, CSS skillsCross-browser, cross-deviceSome special access needed to sensorsSome special storage needsApp Store and/or Google Play

Page 90: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Native

Native = Objective C, Java or C#

Compiled to run on device OSAccesses device directly via native API

Page 91: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Native

Objective C, Java and/or C# skillsHigh-performance requirementsSpecial access needed to sensorsSpecial storage needsOffline + related tables, domains and subtypes

Page 92: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Native

Better memory managementControl over battery lifeApp Store and/or Google Play

Page 93: ArcGIS API for JavaScript Building Mobile Web Apps · 2015-11-18 · All modern browsers support it All modern browsers will request it. Server needs to be configured

Additional Resources• http://zurb.com/word/mobile-first• https://facebook.github.io/react-native/• https://www.ampproject.org/