-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use touch event's scale and rotation fields.
Thanks to @natevw, I see there are `scale` and `rotation` fields on the touch event that we can use to compute the zoom and angle offsets more easily. Also, this commit updates the example to auto-detect retina displays using the devicePixelRatio field of the current window.
- Loading branch information
Showing
6 changed files
with
88 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
var po = org.polymaps; | ||
|
||
// Note: po.interact has built-in touch support! | ||
var map = po.map() | ||
.container(document.getElementById("map").appendChild(po.svg("svg"))) | ||
.add(po.interact()); // built-in touch support | ||
.add(po.interact()); | ||
|
||
// Compute zoom offset for retina display. | ||
var dz = Math.log(window.devicePixelRatio || 1) / Math.LN2; | ||
|
||
// CloudMade image tiles, hooray! | ||
map.add(po.image() | ||
.url(po.url("http://{S}tile.cloudmade.com" | ||
+ "/1a1b06b230af4efdbb989ea99e9841af" // http://cloudmade.com/register | ||
+ "/998/256/{Z}/{X}/{Y}.png") | ||
.repeat(false) | ||
.hosts(["a.", "b.", "c.", ""])) | ||
.zoom(function(z) { return z + 1; })); // use 2x resolution tiles | ||
.zoom(function(z) { return z + dz; })); | ||
|
||
// no compass! pinch-to-zoom ftw |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.