16 |
16 |
17 STYLESHEETS = ( |
17 STYLESHEETS = ( |
18 'https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css', |
18 'https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css', |
19 'https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css', |
19 'https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css', |
20 'http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css', |
20 'http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css', |
21 '/static/pngtile/image.css', |
21 '/static/pngtile/map.css', |
22 ) |
22 ) |
23 |
23 |
24 SCRIPTS = ( |
24 SCRIPTS = ( |
25 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js', |
25 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js', |
26 'https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js', |
26 'https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js', |
27 'http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js', |
27 'http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js', |
|
28 '/static/pngtile/map.js', |
28 ) |
29 ) |
29 |
30 |
30 def __init__ (self, **opts): |
31 def __init__ (self, **opts): |
31 BaseApplication.__init__(self, **opts) |
32 BaseApplication.__init__(self, **opts) |
32 |
33 |
37 name: request path for .png image |
38 name: request path for .png image |
38 """ |
39 """ |
39 |
40 |
40 image_info = image.info() |
41 image_info = image.info() |
41 |
42 |
42 config = dict( |
43 map_config = dict( |
43 tile_url = 'http://zovoweix.qmsk.net:8080/{name}?x={x}&y={y}&zoom={z}', |
44 tile_url = 'http://zovoweix.qmsk.net:8080/{name}?x={x}&y={y}&zoom={z}', |
44 tile_name = name, |
45 tile_name = name, |
45 |
46 |
46 tile_size = pngtile.tile.TILE_SIZE, |
47 tile_size = pngtile.tile.TILE_SIZE, |
47 tile_zoom = pngtile.tile.MAX_ZOOM, |
48 tile_zoom = pngtile.tile.MAX_ZOOM, |
56 html.div(id='wrapper', *[ |
57 html.div(id='wrapper', *[ |
57 html.div(id='map') |
58 html.div(id='map') |
58 ]), |
59 ]), |
59 ), |
60 ), |
60 end = ( |
61 end = ( |
61 html.script("""\ |
62 html.script("""$(function() {{ map_init({map_config}); }});""".format(map_config=json.dumps(map_config))), |
62 $(function() {{ |
|
63 var config = {config}; |
|
64 |
|
65 var bounds = [ |
|
66 [ 0, config.image_height ], |
|
67 [ -config.image_width, 0 ] |
|
68 ]; |
|
69 var center = [ |
|
70 -256, 512 |
|
71 ]; |
|
72 var zoom = config.tile_zoom; |
|
73 |
|
74 var map = L.map('map', {{ |
|
75 crs: L.CRS.Simple, |
|
76 center: center, |
|
77 zoom: zoom, |
|
78 maxBounds: bounds |
|
79 }}); |
|
80 |
|
81 L.tileLayer(config.tile_url, {{ |
|
82 name: config.tile_name, |
|
83 minZoom: 0, |
|
84 maxZoom: config.tile_zoom, |
|
85 tileSize: config.tile_size, |
|
86 continuousWorld: true, |
|
87 noWrap: true, |
|
88 zoomReverse: true, |
|
89 bounds: bounds |
|
90 }}).addTo(map); |
|
91 }}); |
|
92 """.format(config=json.dumps(config))), |
|
93 ), |
63 ), |
94 ) |
64 ) |
95 |
65 |
96 def handle (self, request): |
66 def handle (self, request): |
97 """ |
67 """ |