SlideShare a Scribd company logo
When Google Maps
    Gives You Lemons,
     Make Lemonade
            Wm Leler
            Flightstats
  http://www.slideshare.net/
wmleler/opensourcebridge2012
Audience
• This talk is about JavaScript map APIs
• Do you just want to put a simple map on a
  web page or blog post?
 • Use a static image of a map
 • Mapbox Embed (no JavaScript!)
    http://mapbox.com/hosting/embedding/
 • If you need traffic info (or street view, ...)
    you’re likely stuck with Google Maps
    (or MapQuest, Bing, Nokia, etc.)
Google Maps API
• 7 years old, used by 350,000 websites
• Was free until recently
 • Now charging heavy users (price drop!)
 • Google will be adding advertising
• Suppressed development of alternatives
• Google owns you and controls you
 • V2 to V3 API bungle
Problems with
     Google Maps API
• Closed, proprietary system - no source
 • Difficult to fix bugs or add features
 • Clumsy object model
 • Poor separation of maps from API
• Generic, one-size-fits-all
 • Three basemaps: street, satellite, terrain
 • Largely automobile centric
Maps in 3 Movements
 Map           Imagery Geography
          Maps & Info & Routes
 Data


Server     Map Tiles, Geom, etc.


                                   • User controls
 Client
            JavaScript Map API
                                   • Loads Map Tiles
Browser                            • Markers and
                                    annotations
What You Need
1. A JavaScript map API
2. A server to serve map tiles and geometry
  •   your own or other (paid or free)
3. One or more base maps (lots of choices)
  • comes with server, or custom
1. JavaScript Map APIs
• Proprietary:
 • Google Maps API
 • Mapquest, Microsoft Bing, Nokia, ...
• Open:
 • OpenLayers - http://openlayers.org/
 • Leaflet - http://leaflet.cloudmade.com/
 • Modest Maps - http://modestmaps.com/
 • Polymaps - http://polymaps.org/
Google Maps
<html style="height:100%"><head>
<title>Google Maps Example</title>
<script src="http://maps.googleapis.com/maps/api/js?
key=API_KEY&sensor=false"></script>
</head><body style="height:100%;margin:0;padding:0">
  <div id="map" style="width:100%; height:100%"></div>
<script type="text/javascript">
  var pdx = new google.maps.LatLng(45.53, -122.67);
  var map = new google.maps.Map(
    document.getElementById('map'),
    { center: pdx, zoom: 14,
      mapTypeID: google.maps.MapTypeId.ROADMAP) } );
</script>
</body></html>
OpenLayers
<html style="height:100%"><head>
<title>OpenLayers Example</title>
<script src="http://openlayers.org/api/OpenLayers.js">
</script>
</head><body style="height:100%;margin:0;padding:0">
  <div id="map" style="width:100%; height:100%"></div>
<script type="text/javascript">
  var map = new OpenLayers.Map('map');
  var mapnik = new OpenLayers.Layer.OSM();
  map.addLayer(mapnik);
  var pdx = new OpenLayers.LonLat(-122.67, 45.53).
    transform(new OpenLayers.Projection("EPSG:4326"),
    map.getProjectionObject());
  map.setCenter(pdx, 14);
</script>
</body></html>
Leaflet
<html style="height:100%"><head>
  <title>Leaflet Example</title>
  <link rel="stylesheet" href="leaflet.css" />
  <!--[if lte IE 8]><link rel="stylesheet"
href="leaflet.ie.css" /><![endif]-->
  <script type="text/javascript" src="leaflet.js"></script>
</head><body style="height:100%;margin:0;padding:0">
<div id="map" style="height: 100%;width:100%"></div>
<script type="text/javascript">
  var map = new L.Map('map');
  var tiles = new L.TileLayer(
'http://mt{s}.google.com/vt/v=w2.106&x={x}&y={y}&z={z}&s=',
{ subdomains:'0123', attribution:'&copy; Google 2011' });
  var pdx = new L.LatLng(45.58961, -122.592121);
  map.addLayer(tiles).setView(pdx, 14);
</script>
</body></html>
Comparison
• OpenLayers is mature, very powerful,
  somewhat complicated and large
• Leaflet is new but lots of committers,
  excellent object model, easily extensible,
  modern design, good for mobile
• Modest maps is compact, minimal
• Polymaps uses SVG, renders geometry
  directly on client (no tiles)
Map Tiles

• Instead of downloading entire map into
  the browser, slice up into square pieces
• Enables interactivity, smooth scrolling
 • uses AJAX calls to download tiles
 • lowers resource needs for browser and
    server, lowers bandwidth demands
The Tao of Tiles
• Longitude (x) goes
  from -180º to 180º

• Latitude (y) goes from
  85.051º to -85.051º
  (arctan sinh π), not 90º

• Tile is 256 x 256 pixels
• Zoom level 0 has one
  tile for entire world
Zoom level 1 has 4 tiles
                 number of tiles
                           zoom
                   =   4
                       1
                   4 =4
Tile Explosion
• City level (11) = 4,194,304 tiles

• Street level (16) =
  4,294,967,296 tiles


Google maps goes
to level 22 =
> 17 trillion tiles
Subdomains
• Browsers used to be limited to 2 network
  connections per domain. (Recent browsers
  raised limit as high as 6.)
• To get around this limitation, map servers
  generally point multiple (3 or 4) subdomains
  at a single tile server.
  http://mt0.google.com/
  http://mt1.google.com/
  http://mt2.google.com/
  http://mt3.google.com/
Tile Alternatives
                (side note)

• Google’s experimental MapsGL uses
  WebGL to draw streets, buildings, and
  other features directly in a canvas
• Polymaps uses SVG
• GeoJSON draws geography
• Renders in browser instead of using tiles
• Bad for satellite or other imagery
• Doesn’t work on all browsers
2. Map Servers
• Use a free public map server:
  • MapQuest Open (Open Street Map)
• Use someone else’s map server
• Use a commercial map server
  • CloudMade, MapBox
• Your own server
  • or cloud storage
MapQuest Open
• http://developer.mapquest.com/web/
  products/open/map
• OpenStreetMap, aerial, and overlay tiles
• Free!
• Supports high bandwidth on request
• Reliability is not guaranteed
Mapquest Open Tiles
• Leaflet templates (subdomains: 1 2 3 4):
 http://otile{s}.mqcdn.com/tiles/
 1.0.0/osm/{z}/{x}/{y}.jpg

 http://oatile{s}.mqcdn.com/tiles/
 1.0.0/sat/{z}/{x}/{y}.jpg

 http://otile{s}.mqcdn.com/tiles/
 1.0.0/hyb/{z}/{x}/{y}.png
Someone Else’s Server
• Almost all map tile servers are unsecured
• You are identified by the referrer header
• OK for low volume use
• No reliability guarantees
• Just need to determine server URL
 • (except for Microsoft Bing maps)
Map Server URLs
Easy to determine URL using browser debugger

                         Google Maps

                         Safari Browser
                            debugger
Constructing
            Tile URLs
http://mt1.google.com/vt/lyrs=m@174227760&hl=en&

                src=app&x=81&y=183&z=9&s=Ga
  subdomain
                    column      row    zoom
new L.TileLayer(
'http://mt{s}.google.com/vt/lyrs=m@174227760&hl=en&
  src=app&x={x}&y={y}&z={z}&s=Ga',
{ subdomains:'0123', attribution:'&copy; Google' })

• Leaflet plugs in the values for you
Slippy Maps

• “slippy” naming convention for map tiles:
http://otile1.mqcdn.com/tiles/1.0.0/osm/4/63/99.png

http://<sub>.domain.com/.../<zoom>/<x>/<y>.png

• Tiles can be served as normal files
   No need for a special tile server
3. Rendering Map Data
 Map Data: roads, boundaries, names, ...
                                Styles:
                                colors,
  Zoom
                Render          line widths,
  levels
                                fonts,
                  Tile          hill shading,
                                visibility,
                                detail, ...
           Map Tiles to Serve
CloudMade
• Has a large number of maps, or
• Map Studio allows you to create your own
  map styles
• Based on OSM data
• CloudMade will host your map tiles ($)
 • or you can download and host yourself
• CloudMade also created Leaflet API
MapBox
• TileMill allows you to create maps, using
  any data (not just styles)
• Uses Mapnik, Carto, other open tools
• MapBox will host your tiles ($)
 • or you can download and host yourself
• They have created a large number of maps
• Can dynamically modify tiles
Sources of Map Data
• Not free: Navteq, Navinfo, DigitalGlobe,
  SRTM, Planetary Visions, Google
• OpenStreetMap, US Census TIGER
• NASA/JPL, US Dept. of Agriculture
• Natural Earth, CGIAR-CSI
• any geographic source
 • anyone with a GPS unit
Hosting Your Own Tiles

• Can host as files, using Slippy map format
• Or as database, using MBTiles (SQLite)
• Host in cloud
• Or use caching proxy
• Open (CC) maps, or your own maps
http://rtp.trimet.org/
• Multi-modal regional trip planner
 • car, bus, light rail, streetcar, trolley,
   commuter train, aerial tram, bicycle, walk
 • Open data allows customization
• OpenLayers on the browser
• Open Mapquest servers, OpenStreetMap
• Developing their own map
Foursquare
• Leaflet on the browser
• Mapbox servers (paid)
• Mapbox “Streets” map
  (based on OSM data)
Flightstats
• Leaflet
• Amazon S3 and CloudFront servers
• various open maps:
 • Stamen Design Terrain map
 • University of Heidelberg Open Map Surfer
 • NASA Blue Marble
 • our own maps
http://www.slideshare.net/wmleler/
       opensourcebridge2012

       http://flightstats.com
     http://flightstats-inc.com

More Related Content

Viewers also liked

Resume Stanglin 2015
Resume Stanglin 2015Resume Stanglin 2015
Resume Stanglin 2015
Gerald Stanglin
 
Teclado partes principales
Teclado partes principalesTeclado partes principales
Teclado partes principales
valenronchi
 
BUS 115 Chap011 written contracts
BUS 115 Chap011   written contractsBUS 115 Chap011   written contracts
BUS 115 Chap011 written contracts
neogenesis6
 
Mobile LBS
Mobile LBSMobile LBS
Mobile LBS
Jaak Laineste
 
Major economic indicators of Banladesh in mid 2015
Major economic indicators of Banladesh in mid 2015Major economic indicators of Banladesh in mid 2015
Major economic indicators of Banladesh in mid 2015
Zahidul Islam
 
Desafios primer ciclo
Desafios primer cicloDesafios primer ciclo
Desafios primer ciclo
raquelexmariorta
 
Importance of foregin Reserve to maintain stable foreign exchange rate
Importance of foregin Reserve to maintain stable foreign exchange rateImportance of foregin Reserve to maintain stable foreign exchange rate
Importance of foregin Reserve to maintain stable foreign exchange rate
A.R. Rabin Islam
 
HTE - Low OHM Power Resistors
HTE - Low OHM Power ResistorsHTE - Low OHM Power Resistors
HTE - Low OHM Power Resistors
htrindia
 
Daily Routines:Vocabulary Activities (video)
Daily Routines:Vocabulary Activities (video)Daily Routines:Vocabulary Activities (video)
Daily Routines:Vocabulary Activities (video)
A. Simoes
 

Viewers also liked (9)

Resume Stanglin 2015
Resume Stanglin 2015Resume Stanglin 2015
Resume Stanglin 2015
 
Teclado partes principales
Teclado partes principalesTeclado partes principales
Teclado partes principales
 
BUS 115 Chap011 written contracts
BUS 115 Chap011   written contractsBUS 115 Chap011   written contracts
BUS 115 Chap011 written contracts
 
Mobile LBS
Mobile LBSMobile LBS
Mobile LBS
 
Major economic indicators of Banladesh in mid 2015
Major economic indicators of Banladesh in mid 2015Major economic indicators of Banladesh in mid 2015
Major economic indicators of Banladesh in mid 2015
 
Desafios primer ciclo
Desafios primer cicloDesafios primer ciclo
Desafios primer ciclo
 
Importance of foregin Reserve to maintain stable foreign exchange rate
Importance of foregin Reserve to maintain stable foreign exchange rateImportance of foregin Reserve to maintain stable foreign exchange rate
Importance of foregin Reserve to maintain stable foreign exchange rate
 
HTE - Low OHM Power Resistors
HTE - Low OHM Power ResistorsHTE - Low OHM Power Resistors
HTE - Low OHM Power Resistors
 
Daily Routines:Vocabulary Activities (video)
Daily Routines:Vocabulary Activities (video)Daily Routines:Vocabulary Activities (video)
Daily Routines:Vocabulary Activities (video)
 

Recently uploaded

Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
SitimaJohn
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
Zilliz
 

Recently uploaded (20)

Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
 

OpenSourceBridge2012: When Google Maps Gives You Lemons, Make Lemonade

  • 1. When Google Maps Gives You Lemons, Make Lemonade Wm Leler Flightstats http://www.slideshare.net/ wmleler/opensourcebridge2012
  • 2. Audience • This talk is about JavaScript map APIs • Do you just want to put a simple map on a web page or blog post? • Use a static image of a map • Mapbox Embed (no JavaScript!) http://mapbox.com/hosting/embedding/ • If you need traffic info (or street view, ...) you’re likely stuck with Google Maps (or MapQuest, Bing, Nokia, etc.)
  • 3. Google Maps API • 7 years old, used by 350,000 websites • Was free until recently • Now charging heavy users (price drop!) • Google will be adding advertising • Suppressed development of alternatives • Google owns you and controls you • V2 to V3 API bungle
  • 4.
  • 5. Problems with Google Maps API • Closed, proprietary system - no source • Difficult to fix bugs or add features • Clumsy object model • Poor separation of maps from API • Generic, one-size-fits-all • Three basemaps: street, satellite, terrain • Largely automobile centric
  • 6. Maps in 3 Movements Map Imagery Geography Maps & Info & Routes Data Server Map Tiles, Geom, etc. • User controls Client JavaScript Map API • Loads Map Tiles Browser • Markers and annotations
  • 7. What You Need 1. A JavaScript map API 2. A server to serve map tiles and geometry • your own or other (paid or free) 3. One or more base maps (lots of choices) • comes with server, or custom
  • 8. 1. JavaScript Map APIs • Proprietary: • Google Maps API • Mapquest, Microsoft Bing, Nokia, ... • Open: • OpenLayers - http://openlayers.org/ • Leaflet - http://leaflet.cloudmade.com/ • Modest Maps - http://modestmaps.com/ • Polymaps - http://polymaps.org/
  • 9. Google Maps <html style="height:100%"><head> <title>Google Maps Example</title> <script src="http://maps.googleapis.com/maps/api/js? key=API_KEY&sensor=false"></script> </head><body style="height:100%;margin:0;padding:0"> <div id="map" style="width:100%; height:100%"></div> <script type="text/javascript"> var pdx = new google.maps.LatLng(45.53, -122.67); var map = new google.maps.Map( document.getElementById('map'), { center: pdx, zoom: 14, mapTypeID: google.maps.MapTypeId.ROADMAP) } ); </script> </body></html>
  • 10.
  • 11. OpenLayers <html style="height:100%"><head> <title>OpenLayers Example</title> <script src="http://openlayers.org/api/OpenLayers.js"> </script> </head><body style="height:100%;margin:0;padding:0"> <div id="map" style="width:100%; height:100%"></div> <script type="text/javascript"> var map = new OpenLayers.Map('map'); var mapnik = new OpenLayers.Layer.OSM(); map.addLayer(mapnik); var pdx = new OpenLayers.LonLat(-122.67, 45.53). transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()); map.setCenter(pdx, 14); </script> </body></html>
  • 12.
  • 13. Leaflet <html style="height:100%"><head> <title>Leaflet Example</title> <link rel="stylesheet" href="leaflet.css" /> <!--[if lte IE 8]><link rel="stylesheet" href="leaflet.ie.css" /><![endif]--> <script type="text/javascript" src="leaflet.js"></script> </head><body style="height:100%;margin:0;padding:0"> <div id="map" style="height: 100%;width:100%"></div> <script type="text/javascript"> var map = new L.Map('map'); var tiles = new L.TileLayer( 'http://mt{s}.google.com/vt/v=w2.106&x={x}&y={y}&z={z}&s=', { subdomains:'0123', attribution:'&copy; Google 2011' }); var pdx = new L.LatLng(45.58961, -122.592121); map.addLayer(tiles).setView(pdx, 14); </script> </body></html>
  • 14.
  • 15. Comparison • OpenLayers is mature, very powerful, somewhat complicated and large • Leaflet is new but lots of committers, excellent object model, easily extensible, modern design, good for mobile • Modest maps is compact, minimal • Polymaps uses SVG, renders geometry directly on client (no tiles)
  • 16. Map Tiles • Instead of downloading entire map into the browser, slice up into square pieces • Enables interactivity, smooth scrolling • uses AJAX calls to download tiles • lowers resource needs for browser and server, lowers bandwidth demands
  • 17. The Tao of Tiles • Longitude (x) goes from -180º to 180º • Latitude (y) goes from 85.051º to -85.051º (arctan sinh π), not 90º • Tile is 256 x 256 pixels • Zoom level 0 has one tile for entire world
  • 18. Zoom level 1 has 4 tiles number of tiles zoom = 4 1 4 =4
  • 19. Tile Explosion • City level (11) = 4,194,304 tiles • Street level (16) = 4,294,967,296 tiles Google maps goes to level 22 = > 17 trillion tiles
  • 20. Subdomains • Browsers used to be limited to 2 network connections per domain. (Recent browsers raised limit as high as 6.) • To get around this limitation, map servers generally point multiple (3 or 4) subdomains at a single tile server. http://mt0.google.com/ http://mt1.google.com/ http://mt2.google.com/ http://mt3.google.com/
  • 21. Tile Alternatives (side note) • Google’s experimental MapsGL uses WebGL to draw streets, buildings, and other features directly in a canvas • Polymaps uses SVG • GeoJSON draws geography • Renders in browser instead of using tiles • Bad for satellite or other imagery • Doesn’t work on all browsers
  • 22. 2. Map Servers • Use a free public map server: • MapQuest Open (Open Street Map) • Use someone else’s map server • Use a commercial map server • CloudMade, MapBox • Your own server • or cloud storage
  • 23. MapQuest Open • http://developer.mapquest.com/web/ products/open/map • OpenStreetMap, aerial, and overlay tiles • Free! • Supports high bandwidth on request • Reliability is not guaranteed
  • 24. Mapquest Open Tiles • Leaflet templates (subdomains: 1 2 3 4): http://otile{s}.mqcdn.com/tiles/ 1.0.0/osm/{z}/{x}/{y}.jpg http://oatile{s}.mqcdn.com/tiles/ 1.0.0/sat/{z}/{x}/{y}.jpg http://otile{s}.mqcdn.com/tiles/ 1.0.0/hyb/{z}/{x}/{y}.png
  • 25. Someone Else’s Server • Almost all map tile servers are unsecured • You are identified by the referrer header • OK for low volume use • No reliability guarantees • Just need to determine server URL • (except for Microsoft Bing maps)
  • 26. Map Server URLs Easy to determine URL using browser debugger Google Maps Safari Browser debugger
  • 27. Constructing Tile URLs http://mt1.google.com/vt/lyrs=m@174227760&hl=en& src=app&x=81&y=183&z=9&s=Ga subdomain column row zoom new L.TileLayer( 'http://mt{s}.google.com/vt/lyrs=m@174227760&hl=en& src=app&x={x}&y={y}&z={z}&s=Ga', { subdomains:'0123', attribution:'&copy; Google' }) • Leaflet plugs in the values for you
  • 28. Slippy Maps • “slippy” naming convention for map tiles: http://otile1.mqcdn.com/tiles/1.0.0/osm/4/63/99.png http://<sub>.domain.com/.../<zoom>/<x>/<y>.png • Tiles can be served as normal files No need for a special tile server
  • 29. 3. Rendering Map Data Map Data: roads, boundaries, names, ... Styles: colors, Zoom Render line widths, levels fonts, Tile hill shading, visibility, detail, ... Map Tiles to Serve
  • 30. CloudMade • Has a large number of maps, or • Map Studio allows you to create your own map styles • Based on OSM data • CloudMade will host your map tiles ($) • or you can download and host yourself • CloudMade also created Leaflet API
  • 31.
  • 32. MapBox • TileMill allows you to create maps, using any data (not just styles) • Uses Mapnik, Carto, other open tools • MapBox will host your tiles ($) • or you can download and host yourself • They have created a large number of maps • Can dynamically modify tiles
  • 33. Sources of Map Data • Not free: Navteq, Navinfo, DigitalGlobe, SRTM, Planetary Visions, Google • OpenStreetMap, US Census TIGER • NASA/JPL, US Dept. of Agriculture • Natural Earth, CGIAR-CSI • any geographic source • anyone with a GPS unit
  • 34. Hosting Your Own Tiles • Can host as files, using Slippy map format • Or as database, using MBTiles (SQLite) • Host in cloud • Or use caching proxy • Open (CC) maps, or your own maps
  • 35. http://rtp.trimet.org/ • Multi-modal regional trip planner • car, bus, light rail, streetcar, trolley, commuter train, aerial tram, bicycle, walk • Open data allows customization • OpenLayers on the browser • Open Mapquest servers, OpenStreetMap • Developing their own map
  • 36.
  • 37. Foursquare • Leaflet on the browser • Mapbox servers (paid) • Mapbox “Streets” map (based on OSM data)
  • 38. Flightstats • Leaflet • Amazon S3 and CloudFront servers • various open maps: • Stamen Design Terrain map • University of Heidelberg Open Map Surfer • NASA Blue Marble • our own maps
  • 39. http://www.slideshare.net/wmleler/ opensourcebridge2012 http://flightstats.com http://flightstats-inc.com

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n