File tree Expand file tree Collapse file tree 4 files changed +32
-4
lines changed
Expand file tree Collapse file tree 4 files changed +32
-4
lines changed Original file line number Diff line number Diff line change 5252 "imageAlt" : " luftbilder.berlin.codefor.de screenshot" ,
5353 "twitter" : " @codeforbe"
5454 }
55- }
55+ }
Original file line number Diff line number Diff line change 11<template >
2- <Nav :brand =" brand" :maps =" maps" :map =" map" @changeMap =" changeMap" @changeCenter =" changeCenter" />
3- <Map :map =" map" :center =" center" :zoom =" zoom" />
2+ <Nav :brand =" brand" :maps =" maps" :map =" map" :center = " center " :zoom = " zoom " @changeMap =" changeMap" @changeCenter =" changeCenter" />
3+ <Map :map =" map" :center =" center" :zoom =" zoom" @changeCenter = " changeCenter " @changeZoom = " changeZoom " />
44</template >
55
66<script >
2828 },
2929 changeCenter (center ) {
3030 this .center = center
31+ },
32+ changeZoom (zoom ) {
33+ this .zoom = zoom
3134 }
3235 }
3336 }
Original file line number Diff line number Diff line change 2424 this .leafletMap = L .map (' map' )
2525 this .changeView ()
2626 this .changeMap ()
27+ this .leafletMap .on (' moveend' , () => {
28+ const c = this .leafletMap .getCenter ()
29+ const [currentLat , currentLon ] = this .center ;
30+ if (currentLat !== c .lat && currentLon !== c .lng ) {
31+ this .$emit (' changeCenter' , [c .lat , c .lng ])
32+ }
33+ })
34+ this .leafletMap .on (' zoomend' , () => {
35+ const z = this .leafletMap .getZoom ()
36+ if (z !== this .zoom ) {
37+ this .$emit (' changeZoom' , z)
38+ }
39+ })
2740 },
2841 changeMap : function () {
2942 if (this .leafletLayer ) {
Original file line number Diff line number Diff line change 4949 brand: Object ,
5050 maps: Array ,
5151 map: Object ,
52+ center: Array ,
53+ zoom: Number ,
5254 },
5355 components: {
5456 Info
9294 changeMap : function (index ) {
9395 this .$emit (' changeMap' , index)
9496 },
97+ latLonToTile : function (lat , lon , z ) {
98+ const rad = Math .PI / 180
99+ const n = Math .pow (2 , z)
100+ const x = Math .floor ((lon + 180 ) / 360 * n)
101+ const latRad = lat * rad
102+ const y = Math .floor ((1 - Math .log (Math .tan (latRad) + 1 / Math .cos (latRad)) / Math .PI ) / 2 * n)
103+ return { x, y }
104+ },
95105 getBackgroundImage : function (map ) {
96- return map .url .replace (/ \{ z\}\/\{ x\}\/\{ y\} / i , ' 16/35198/21494' )
106+ const [lat , lon ] = this .center .map (x => parseFloat (x))
107+ const { x , y } = this .latLonToTile (lat, lon, this .zoom )
108+ return map .url .replace (/ \{ z\}\/\{ x\}\/\{ y\} / i , ` ${ this .zoom } /${ x} /${ y} ` )
97109 },
98110 getYear : function (map ) {
99111 return map .name .split (' ' )[1 ]
You can’t perform that action at this time.
0 commit comments