SlideShare une entreprise Scribd logo
1  sur  62
Esri Southwest User Conference
September 17-19, 2012 | Denver, Colorado


         Building Mobile Applications with
          the ArcGIS API for JavaScript

                                  Andy Gup
Agenda

 Goal: You’ll get an A to Z mobile web primer

 Why build mobile map apps?

 3 Approaches

 Frameworks

 CSS3 & HTML5

 Hybrid Map apps
Who am I?



   Andy Gup, Esri
   Tech Lead for Web APIs and Android
   Esri Developer Network


   Email: agup@esri.com
   Twitter: @agup
Who are you?
Why mobile?
Demo
X
Mobile usage stats for my website?




Web Server logs


Web analytic tools
Sample web-site stats from esri.com
Your 3 Approaches


                        Web app
     1.                     +
                    Native mobile app



                       Web app
     2.                     +
                    Web mobile app
                     (a.k.a Hybrid)



     3.              Web app only
Many different screen sizes and pixel densities




                            1920x1080
Wait…how do I pan and zoom the map??
Hmmm…how many map layers do I load?




                     VS.




       1 GB RAM                   16 GB RAM
How come my map loads so slooow?




                        VS.




     Mostly connected              Always connected
My survey crews use GPS heavily…




                       VS.




     Limited battery               Unlimited power
arcgis.com




      1440 x 900   480 x 800 hdpi
resources.arcgis.com




      1440 x 900       480 x 800 hdpi
Mobile app – flip view port easily




   Portrait                          Landscape
Desktop app on smartphone
ArcGIS API for JavaScript - Compact




          http://esriurl.com/compactJS




<script type="text/javascript"
    src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.1compact">
Library Size vs. Download vs. Parse


         Compact




         Full
Many mobile frameworks, such as…
The challenge
Mobile frameworks help with…



           Views

           Visual Components

           Themes
Views




        Image courtesy Dojo
Views



<div id="mapView" dojoType="dojox.mobile.View“
        style="width:100%;height:100%;">
    <h1 dojoType="dojox.mobile.Heading"
        back="Back" moveTo="mainView">
        5 + 10 minute Drive Times
    </h1>
    <div id="map“ style="width:100%; height:100%;“/>
</div>
Visual Components



<div dojoType="dojox.charting.widget.Chart2D"
     theme="dojox.charting.themes.Claro" id="viewsChart"
     style="width: 550px; height: 550px;">

    <!-- Pie Chart: add the plot -->
    <div class="plot" name="default" type="Pie"
     radius="200" fontColor="#000" labelOffset="-20"></div>

    <!-- pieData is the data source -->
    <div class="series" name="Last Week's Visits"
        array="chartData">
    </div>

</div>
Themes


<!--Legend Dialog-->
<div data-role="dialog" id="legendDialog"
  data-theme="f">
  <div data-role="header">
    <h1>Legend</h1>
  </div>
  <div data-role="content" >
    <div id="legendDiv"></div>
  </div>
</div>
The view port
Setting the mobile view port




<meta name="viewport" content="width=device-width,
   initial-scale=1, maximum-scale=1, user-scalable=no"/>
Setting the mobile view port

                             Minimum view port




<meta name="viewport" content="width=device-width,
   initial-scale=1, maximum-scale=1, user-scalable=no"/>




Zoom level on page load

                               Force map to scale - not the page
No viewport   With viewport
Map touch events


               No Change!



function init() {
        var map = new esri.Map(...);
        dojo.connect(map, "onClick", myClickHandler);
}
Styling via resolution & rotation


          CSS3 Media Queries
CSS3 Media Queries
Target specific devices by screen width

@media screen and (min-device-width:768px) and (max-device-width:1024px) {
/* styles go here */
}



Apply styles by device orientation

@media (orientation: landscape) {
/* styles go here */
}



Target high density screens such as iPhone 4

@media (-webkit-min-device-pixel-ratio: 2) {
/* high resolution device styles go here */
}
Listen for device rotation

var supportsOrientationChange = "onorientationchange" in window,
        orientationEvent =
            supportsOrientationChange ? "orientationchange" : "resize";

       window.addEventListener(orientationEvent,
               dojo.hitch(this,function(){
                    //... TODO
                    this.orientationChanged = orientationChanged;
                }), false
        );
Demo
Putting it all together
Hybrid Web Apps




Android SDK
               +       HTML +
                   Mobile JavaScript
                                       =
Java Project
                     Framework
Hybrid Web Apps
Hybrid Web Apps

                  Direct access to:

                  GPS
                  Camera
                  SD Card
Examples of Hybrid Web Apps
        http://www.phonegap.com/app
Hybrid Web App Platforms
build.phonegap.com
build.phonegap.com
Scan the QR code to install
Hello-World PhoneGap Map
Remote debugging
HTML5

        HTML + CSS3 + JavaScript




                                   HTML5 Logo by W3C
HTML5 APIs
•   Several new APIs
    -   Drag and drop API
    -   FileSystem API(s)
    -   Geolocation API
    -   Web Storage: localStorage/sessionStorage
    -   Web Workers (threaded JavaScript!)
    -   Cross-Origin Resource Sharing (CORS)
    -   Browser History
Web Storage API
•   5 MB limit vs. 4 KB per regular cookie
•   Stores key/value pairs
•   localStorage and sessionStorage

// Put the object into storage
localStorage.setItem(“address”, someAddress);

// Retrieve the object from storage
var userAddress = localStorage.getItem(“address”);


// Save data to a the current session's store
sessionStorage.setItem("username", "John");


// Access some stored data
var userName = sessionStorage.getItem("username"));
Geolocation API
•   Provides user’s approximate location
•   Opt-in only!




navigator.geolocation.getCurrentPosition(
    zoomToLocation, locationError
);

watchId = navigator.geolocation.watchPosition(
    updateLocation, locationError
);
Geolocation API
Understanding browsers




          !=         !=
caniuse.com
Feature detection pattern

useLocalStorage = supports_local_storage();

function supports_local_storage() {
   try {
     return 'localStorage' in window &&
        window['localStorage'] !== null;
   }
   catch( e ){
     return false;
   }
}

function doSomething() {
    if(useLocalStorage == true){
       //write to local storage
    }
    else {
         //degrade gracefully
    }
}
Test on different devices
Andy Gup, Esri
Tech Lead for Web APIs and Android
Esri Developer Network


agup@esri.com
http://blog.andygup.net
@agup
3 Approaches to Mobile - An A to Z Primer.

Contenu connexe

Similaire à 3 Approaches to Mobile - An A to Z Primer.

Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...
Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...
Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...
Esri Nederland
 
Devon 2011-f-1 반응형 웹 디자인
Devon 2011-f-1  반응형 웹 디자인Devon 2011-f-1  반응형 웹 디자인
Devon 2011-f-1 반응형 웹 디자인
Daum DNA
 
Web APIs & Apps - Mozilla
Web APIs & Apps - MozillaWeb APIs & Apps - Mozilla
Web APIs & Apps - Mozilla
Robert Nyman
 
Web app and more
Web app and moreWeb app and more
Web app and more
faming su
 
HTML5 is the Future of Mobile, PhoneGap Takes You There Today
HTML5 is the Future of Mobile, PhoneGap Takes You There TodayHTML5 is the Future of Mobile, PhoneGap Takes You There Today
HTML5 is the Future of Mobile, PhoneGap Takes You There Today
davyjones
 
Web enabling your survey business ppt version
Web enabling your survey business ppt versionWeb enabling your survey business ppt version
Web enabling your survey business ppt version
rudy_stricklan
 

Similaire à 3 Approaches to Mobile - An A to Z Primer. (20)

Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...
Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...
Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...
 
Gup web mobilegis
Gup web mobilegisGup web mobilegis
Gup web mobilegis
 
Pinkoi Mobile Web
Pinkoi Mobile WebPinkoi Mobile Web
Pinkoi Mobile Web
 
Location Based Services Without the Cocoa
Location Based Services Without the CocoaLocation Based Services Without the Cocoa
Location Based Services Without the Cocoa
 
phonegap with angular js for freshers
phonegap with angular js for freshers    phonegap with angular js for freshers
phonegap with angular js for freshers
 
Devon 2011-f-1 반응형 웹 디자인
Devon 2011-f-1  반응형 웹 디자인Devon 2011-f-1  반응형 웹 디자인
Devon 2011-f-1 반응형 웹 디자인
 
Making your site mobile-friendly - DevCSI Reading 21.07.2010
Making your site mobile-friendly - DevCSI Reading 21.07.2010Making your site mobile-friendly - DevCSI Reading 21.07.2010
Making your site mobile-friendly - DevCSI Reading 21.07.2010
 
The Mobile Development Landscape
The Mobile Development LandscapeThe Mobile Development Landscape
The Mobile Development Landscape
 
Best Practices for Mobile Web Design
Best Practices for Mobile Web DesignBest Practices for Mobile Web Design
Best Practices for Mobile Web Design
 
Building responsive web mobile mapping applications
Building responsive web mobile mapping applicationsBuilding responsive web mobile mapping applications
Building responsive web mobile mapping applications
 
Web APIs & Apps - Mozilla
Web APIs & Apps - MozillaWeb APIs & Apps - Mozilla
Web APIs & Apps - Mozilla
 
Web Apps and more
Web Apps and moreWeb Apps and more
Web Apps and more
 
Web app and more
Web app and moreWeb app and more
Web app and more
 
Multi screen HTML5
Multi screen HTML5Multi screen HTML5
Multi screen HTML5
 
移动端Web app开发
移动端Web app开发移动端Web app开发
移动端Web app开发
 
HTML5 is the Future of Mobile, PhoneGap Takes You There Today
HTML5 is the Future of Mobile, PhoneGap Takes You There TodayHTML5 is the Future of Mobile, PhoneGap Takes You There Today
HTML5 is the Future of Mobile, PhoneGap Takes You There Today
 
Bruce lawson-over-the-air
Bruce lawson-over-the-airBruce lawson-over-the-air
Bruce lawson-over-the-air
 
Html5 on Mobile(For Developer)
Html5 on Mobile(For Developer)Html5 on Mobile(For Developer)
Html5 on Mobile(For Developer)
 
Web enabling your survey business ppt version
Web enabling your survey business ppt versionWeb enabling your survey business ppt version
Web enabling your survey business ppt version
 
Intro to PhoneGap and PhoneGap Build
Intro to PhoneGap and PhoneGap BuildIntro to PhoneGap and PhoneGap Build
Intro to PhoneGap and PhoneGap Build
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Dernier (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 

3 Approaches to Mobile - An A to Z Primer.

  • 1. Esri Southwest User Conference September 17-19, 2012 | Denver, Colorado Building Mobile Applications with the ArcGIS API for JavaScript Andy Gup
  • 2. Agenda Goal: You’ll get an A to Z mobile web primer Why build mobile map apps? 3 Approaches Frameworks CSS3 & HTML5 Hybrid Map apps
  • 3. Who am I? Andy Gup, Esri Tech Lead for Web APIs and Android Esri Developer Network Email: agup@esri.com Twitter: @agup
  • 7.
  • 8. X
  • 9.
  • 10. Mobile usage stats for my website? Web Server logs Web analytic tools
  • 11. Sample web-site stats from esri.com
  • 12. Your 3 Approaches Web app 1. + Native mobile app Web app 2. + Web mobile app (a.k.a Hybrid) 3. Web app only
  • 13. Many different screen sizes and pixel densities 1920x1080
  • 14. Wait…how do I pan and zoom the map??
  • 15. Hmmm…how many map layers do I load? VS. 1 GB RAM 16 GB RAM
  • 16. How come my map loads so slooow? VS. Mostly connected Always connected
  • 17.
  • 18. My survey crews use GPS heavily… VS. Limited battery Unlimited power
  • 19. arcgis.com 1440 x 900 480 x 800 hdpi
  • 20. resources.arcgis.com 1440 x 900 480 x 800 hdpi
  • 21. Mobile app – flip view port easily Portrait Landscape
  • 22. Desktop app on smartphone
  • 23. ArcGIS API for JavaScript - Compact http://esriurl.com/compactJS <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.1compact">
  • 24. Library Size vs. Download vs. Parse Compact Full
  • 25. Many mobile frameworks, such as… The challenge
  • 26. Mobile frameworks help with… Views Visual Components Themes
  • 27. Views Image courtesy Dojo
  • 28. Views <div id="mapView" dojoType="dojox.mobile.View“ style="width:100%;height:100%;"> <h1 dojoType="dojox.mobile.Heading" back="Back" moveTo="mainView"> 5 + 10 minute Drive Times </h1> <div id="map“ style="width:100%; height:100%;“/> </div>
  • 29. Visual Components <div dojoType="dojox.charting.widget.Chart2D" theme="dojox.charting.themes.Claro" id="viewsChart" style="width: 550px; height: 550px;"> <!-- Pie Chart: add the plot --> <div class="plot" name="default" type="Pie" radius="200" fontColor="#000" labelOffset="-20"></div> <!-- pieData is the data source --> <div class="series" name="Last Week's Visits" array="chartData"> </div> </div>
  • 30. Themes <!--Legend Dialog--> <div data-role="dialog" id="legendDialog" data-theme="f"> <div data-role="header"> <h1>Legend</h1> </div> <div data-role="content" > <div id="legendDiv"></div> </div> </div>
  • 32. Setting the mobile view port <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
  • 33. Setting the mobile view port Minimum view port <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/> Zoom level on page load Force map to scale - not the page
  • 34. No viewport With viewport
  • 35. Map touch events No Change! function init() { var map = new esri.Map(...); dojo.connect(map, "onClick", myClickHandler); }
  • 36. Styling via resolution & rotation CSS3 Media Queries
  • 37. CSS3 Media Queries Target specific devices by screen width @media screen and (min-device-width:768px) and (max-device-width:1024px) { /* styles go here */ } Apply styles by device orientation @media (orientation: landscape) { /* styles go here */ } Target high density screens such as iPhone 4 @media (-webkit-min-device-pixel-ratio: 2) { /* high resolution device styles go here */ }
  • 38. Listen for device rotation var supportsOrientationChange = "onorientationchange" in window, orientationEvent = supportsOrientationChange ? "orientationchange" : "resize"; window.addEventListener(orientationEvent, dojo.hitch(this,function(){ //... TODO this.orientationChanged = orientationChanged; }), false );
  • 40. Hybrid Web Apps Android SDK + HTML + Mobile JavaScript = Java Project Framework
  • 42. Hybrid Web Apps Direct access to: GPS Camera SD Card
  • 43. Examples of Hybrid Web Apps http://www.phonegap.com/app
  • 44. Hybrid Web App Platforms
  • 47. Scan the QR code to install
  • 49.
  • 51. HTML5 HTML + CSS3 + JavaScript HTML5 Logo by W3C
  • 52. HTML5 APIs • Several new APIs - Drag and drop API - FileSystem API(s) - Geolocation API - Web Storage: localStorage/sessionStorage - Web Workers (threaded JavaScript!) - Cross-Origin Resource Sharing (CORS) - Browser History
  • 53. Web Storage API • 5 MB limit vs. 4 KB per regular cookie • Stores key/value pairs • localStorage and sessionStorage // Put the object into storage localStorage.setItem(“address”, someAddress); // Retrieve the object from storage var userAddress = localStorage.getItem(“address”); // Save data to a the current session's store sessionStorage.setItem("username", "John"); // Access some stored data var userName = sessionStorage.getItem("username"));
  • 54. Geolocation API • Provides user’s approximate location • Opt-in only! navigator.geolocation.getCurrentPosition( zoomToLocation, locationError ); watchId = navigator.geolocation.watchPosition( updateLocation, locationError );
  • 58. Feature detection pattern useLocalStorage = supports_local_storage(); function supports_local_storage() { try { return 'localStorage' in window && window['localStorage'] !== null; } catch( e ){ return false; } } function doSomething() { if(useLocalStorage == true){ //write to local storage } else { //degrade gracefully } }
  • 59. Test on different devices
  • 60.
  • 61. Andy Gup, Esri Tech Lead for Web APIs and Android Esri Developer Network agup@esri.com http://blog.andygup.net @agup

Notes de l'éditeur

  1. Demographics app
  2. 835 million smartphone users in 2011
  3. http://www.esri.com/site/pdfs/visitorprofile_q3_2011.pdf
  4. http://mobile.businessweek.com/articles/2012-09-13/the-4g-era-arrives-how-much-will-you-pay
  5. Arcgis.com
  6. Arcgis.com
  7. http://esriurl.com/compactJS
  8. http://dojotoolkit.org/reference-guide/1.8/dojox/mobile.htmlhttp://docs.sencha.com/touch/2-0/#!/api
  9. jQuery
  10. Locks entire window. Focuses pinch zoom on components (e.g. map).Pinch zoom not available on Android 3+ until ArcGIS API for JavaScript v3.2
  11. https://developer.mozilla.org/en-US/docs/Mobile/Viewport_meta_tag
  12. http://edn1.esri.com/jsdevstarter/device_sim/index.html
  13. You can do the same thing with iOS
  14. http://phonegap.com/2012/03/19/phonegap-cordova-and-what%E2%80%99s-in-a-name/
  15. http://phonegap.com/2012/03/19/phonegap-cordova-and-what%E2%80%99s-in-a-name/
  16. http://venturebeat.com/2012/05/02/linkedin-ipad-app-engineering/#s:1-linkedin-ipadhttp://www.mobilemarketer.com/cms/news/software-technology/13786.html
  17. Modernizr
  18. Be careful when reusing desktop content on the mobile web