-
Notifications
You must be signed in to change notification settings - Fork 6
/
example.html
58 lines (48 loc) · 1.6 KB
/
example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!DOCTYPE html>
<html>
<head>
<title>Mapbox + Google Hybrid Satellite</title>
<script src="https://api.tiles.mapbox.com/mapbox.js/v2.1.9/mapbox.js"></script>
<link rel="stylesheet" href="https://api.tiles.mapbox.com/mapbox.js/v2.1.9/mapbox.css" />
</head>
<body>
<div style="width:500px; height:500px" id="map"></div>
<script type='text/javascript'>
L.mapbox.accessToken = 'pk.eyJ1Ijoid293amFrZTEiLCJhIjoiMzMyMWY2Njk4MTA0NDZjNjVkMWVmNGQ3YWMzMjM3MTMifQ.MQ5_BYB1G5e6g0ne9AP0pg';
var coordinateOslo = [59.916667, 10.75];
var zoomLevel = 12;
map = L.mapbox.map('map', null, {
center:coordinateOslo,
zoom: zoomLevel
});
var layers = {
Satellite: L.mapbox.tileLayer('mapbox.streets-satellite'),
Streets: L.mapbox.tileLayer('mapbox.streets'),
Google: L.tileLayer('https://mts{s}.google.com/vt/lyrs=s@186112443&hl=x-local&src=app&x={x}&y={y}&z={z}&s=Galile', {
subdomains: '0123',
attribution: '© Google Maps'
}),
};
layers.Satellite.addTo(map);
L.control.layers(layers).addTo(map);
// google hybrid
var google_hybrid_overlay = L.tileLayer('https://mts{s}.google.com/vt/lyrs=h@186112443&hl=x-local&src=app&x={x}&y={y}&z={z}&s=Galile', {
subdomains: '0123',
attribution: '© Google Maps',
zIndex: 4
})
google_hybrid_overlay.setOpacity(0);
map.addLayer(google_hybrid_overlay)
// listen for google maps
map.on('baselayerchange', function(eo)
{
if( eo.name == 'Google' ) {
google_hybrid_overlay.setOpacity(1);
}
else {
google_hybrid_overlay.setOpacity(0);
}
})
</script>
</body>
</html>