performance and scalability for maps api sites (dev fest '10 mexico)

37
Performance and Scalability for Maps API Sites Ossama Alami Developer Advocate, Google @ossamaalami @googlemapsapi

Upload: ossama-alami

Post on 19-May-2015

2.334 views

Category:

Technology


1 download

DESCRIPTION

Also available here: http://docs.google.com/a/google.com/present/view?id=df3mpx45_65gz4fwtht Geo 2 - DevFext MX 2010

TRANSCRIPT

Page 1: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

Performance andScalability for Maps API Sites

Ossama AlamiDeveloper Advocate, Google@ossamaalami@googlemapsapi

Page 2: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

“Every millisecond counts”

Google User Experience Guidelineshttp://www.google.com/corporate/ux.html

Page 3: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

Loading the JavaScript API

Page 4: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

Lots of Resources

V2:    Simple Map

V3:    Simple Map

Page 5: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

Maps API v3

• Latency #1 priority• Aggressive modularization• Latency features• Mobile Web (iPhone, Android)

Page 6: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

Displaying Many Markers

Page 7: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

Problem: GMarker/Marker

= <img>*5 + <map>*1

Page 8: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

Many Markers Comparison V2 V3

Solution: Light Weight Marker

Page 9: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

Creating a Custom Overlay

First, subclass OverlayView:1. function MarkerLight(latlng, opts, map) {•   this.latlng = latlng;•   if (!opts) opts = {};•   this.map_ = map;•  •   this.height_ = opts.height || 32;•   this.width_ = opts.width || 32;•   this.image_ = opts.image;•  •   this.setMap(map);• }•  • MarkerLight.prototype = new google.maps.OverlayView();

Page 10: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

Then implement onAdd() and onRemove() called by the API:1. MarkerLight.prototype.onAdd = function() {•   // Create the DIV representing our MarkerLight•   var div = document.createElement("div");•   div.style.border = "1px solid white";•   div.style.position = "absolute";•   div.style.paddingLeft = "0px";•   div.style.cursor = 'pointer';•  •   var img = document.createElement("img");•   img.src = this.image_;•   img.style.width = this.width_ + "px";•   img.style.height = this.height_ + "px";•   div.appendChild(img);•  •   var panes = this.getPanes();•   panes.overlayLayer.appendChild(div);•  •   this.div_ = div;• };•  • MarkerLight.prototype.onRemove = function() {•   this.div_.parentNode.removeChild(this.div_);•   this.div_ = null;• };

Creating a Custom Overlay

Page 11: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

Then implement draw() and position the DIV:1. MarkerLight.prototype.draw = function() {•   var overlayProjection = this.getProjection();•  •   // Calculate the DIV coordinates of two opposite corners•   // of our bounds to get the size and position of our MarkerLight•   var divPixel = overlayProjection.fromLatLngToDivPixel(this.latlng);•  •   // Now position our DIV based on the DIV coordinates of our bounds•   this.div_.style.width = this.width_ + "px";•   this.div_.style.left = (divPixel.x) + "px";•   this.div_.style.height = (this.height_) + "px";•   this.div_.style.top = (divPixel.y) - this.height_ + "px";• };

Creating a Custom Overlay

Then, just create the Marker:1. var marker = new MarkerLight(latlng, •   {image:"bluecirclemarker.png"},  map));

Page 12: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

Many Markers Comparison V2 V3

Solution: Light Weight Marker

Page 13: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

MadoffMap 

Light Weight Marker for Flash, Too!

Page 14: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

Problem: Too Many DOM Nodes

Page 15: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

AuthorMapper

Solution: Clustering

Page 16: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

360Cities

Solution: K-means Clustering

Page 17: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

MarkerClusterer V2 V3

Solution: Grid Based Clustering

Page 18: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

Solution: Regional Clustering

US Pizzas Travellr

Page 19: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

Article: Handling Large Amounts of Markers

Python k-means

Maptimize

More Clustering Resources

Page 20: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

FundRace

Solution: View Only Visualization

Page 21: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

HeatMapAPI Boston Pizza

Solution: View Only Visualization

NY Times Taxi Map

Page 22: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

Google Local Search

Clickable Tile Layer

Solution: Clickable Marker Layer

Page 23: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

Rendering Large Polys

Page 24: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

Problem: Polygon/GPolygon

Page 25: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

Solution: Lightweight Polys

Polygonzo

Page 26: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

13500 points 2200 points

Problem: Too Many Points

Page 27: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

MapShaperMapSimplification  

Mapping the Votes: Resources  

Solution: Data Simplification

Page 28: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

Encoded Poly Example 

Solution: Encoded Polys

Page 29: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

SVGCanvas

VML

Problem: Browsers + Vector Graphics

Page 30: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

Thematic Mapping HowSFVotes 

Solution: Maps API for Flash

Page 31: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

Map of The Fallen

Solution: Earth API

Page 32: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

Solution: Tile Layers

Page 33: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

Generated County Tiles• Tiles generated with Perl script using data in PostGRE

database for zoom levels 5-9

Zoom 5

Zoom 6

Zoom 7

Zoom 8

Zoom 9

Static Data Tiles: Counties Example

Page 34: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

Hosting Geo Data

Page 35: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

Hosting Geo DataGoogle Maps Data API • Stores geo data and associated attributes. • Supports geospatial and attribute queries• Storage scales simply with usage.• Geodata is accessible across platforms and devices. • Geodata from the Google Maps Data API can be instantly

indexed and made searchable in Google Maps.App Engine• Host and run your web applications on Google's infrastructure.• Easy to build, maintain and scale. Highly customizable.• Supports Python and Java• Libraries available to make geospatial queries easier on App

Engineo http://code.google.com/p/geodatastore/o http://code.google.com/p/geomodel/

Page 36: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

Developer Qualification

Community Driven. 

Page 37: Performance and Scalability for Maps API Sites (Dev Fest '10 Mexico)

Q & AThanks!