Adding XYZ example using MapBox tiles.

This commit is contained in:
tschaub
2012-03-01 13:13:35 -07:00
parent 6d5544ca96
commit 31219c90f5
2 changed files with 104 additions and 0 deletions

73
examples/mapbox.html Normal file
View File

@@ -0,0 +1,73 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>OpenLayers MapBox Example</title>
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
<style>
.olControlAttribution {
bottom: 5px;
font-size: 9px;
}
div.olControlZoomPanel {
top: 10px;
left: 10px;
}
div.olControlZoomPanel .olControlZoomInItemInactive,
div.olControlZoomPanel .olControlZoomOutItemInactive {
background: rgba(0, 0, 0, 0.2);
position: absolute;
}
div.olControlZoomPanel .olControlZoomInItemInactive {
border-radius: 3px 3px 0 0;
}
div.olControlZoomPanel .olControlZoomOutItemInactive {
border-radius: 0 0 3px 3px ;
top: 20px;
}
div.olControlZoomPanel div:hover {
background: rgba(0, 0, 0, 0.5);
}
div.olControlZoomPanel .olControlZoomOutItemInactive:after ,
div.olControlZoomPanel .olControlZoomInItemInactive:after {
font-weight: bold;
content: '+';
font-size: 18px;
padding: 0 2px;
z-index: 2000;
color: #fff;
line-height: 1em;
}
div.olControlZoomPanel .olControlZoomOutItemInactive:after {
content: '';
line-height: 0.9em;
padding: 0 5px;
}
div.olControlZoomPanel .olControlZoomToMaxExtentItemInactive {
display: none;
}
</style>
</head>
<body>
<h1 id="title">Basic MapBox OSM Example</h1>
<div id="tags">mapbox xyz osm</div>
<div id="shortdesc">Shows how to use MapBox tiles in an OpenLayers map.</div>
<div id="map" class="smallmap"></div>
<div id="docs">
<p>This example demonstrates the use of an XYZ layer that accesses tiles from MapBox.</p>
<p>
See the <a href="mapbox.js" target="_blank">mapbox.js</a> source
for details. Make sure to read the <a href="http://mapbox.com/tos/">Terms of Service</a>
before using MapBox tiles in your application.
</p>
</div>
<script src="../lib/OpenLayers.js"></script>
<script src="mapbox.js"></script>
</body>
</html>

31
examples/mapbox.js Normal file
View File

@@ -0,0 +1,31 @@
var streets = new OpenLayers.Layer.XYZ(
"MapBox Streets",
[
"http://a.tiles.mapbox.com/v3/mapbox.mapbox-streets/${z}/${x}/${y}.png",
"http://b.tiles.mapbox.com/v3/mapbox.mapbox-streets/${z}/${x}/${y}.png",
"http://c.tiles.mapbox.com/v3/mapbox.mapbox-streets/${z}/${x}/${y}.png",
"http://d.tiles.mapbox.com/v3/mapbox.mapbox-streets/${z}/${x}/${y}.png"
], {
attribution: "<a href='http://mapbox.com'>MapBox</a> | <a href='http://mapbox.com/tos/'>Terms of Service</a>",
sphericalMercator: true,
transitionEffect: "resize",
numZoomLevels: 16
}
);
var map = new OpenLayers.Map({
div: "map",
projeciton: "EPSG:900913",
layers: [streets],
controls: [
new OpenLayers.Control.Attribution(),
new OpenLayers.Control.TouchNavigation({
dragPanOptions: {
enableKinetic: true
}
}),
new OpenLayers.Control.ZoomPanel(),
new OpenLayers.Control.Permalink({anchor: true})
]
});
map.setCenter([0, 0], 1);