@@ -5,11 +5,12 @@ let streets = L.tileLayer('https://api.mapbox.com/styles/v1/mapbox/streets-v9/ti
55 dark = L . tileLayer ( 'https://api.mapbox.com/styles/v1/mapbox/dark-v9/tiles/256/{z}/{x}/{y}?access_token=pk.eyJ1IjoiYmlza2F6eiIsImEiOiJjaXJkOTFkb3owMDdxaTltZ21vemsxcGViIn0.70mwo4YYnbxY_BJoEsGYxw' , { attribution : '© <a href="https://www.mapbox.com">Mapbox</a> Dark' } ) ,
66 light = L . tileLayer ( 'https://api.mapbox.com/styles/v1/mapbox/light-v9/tiles/256/{z}/{x}/{y}?access_token=pk.eyJ1IjoiYmlza2F6eiIsImEiOiJjaXJkOTFkb3owMDdxaTltZ21vemsxcGViIn0.70mwo4YYnbxY_BJoEsGYxw' , { attribution : '© <a href="https://www.mapbox.com">Mapbox</a> Light' } ) ,
77 satelite = L . tileLayer ( 'https://api.mapbox.com/styles/v1/mapbox/satellite-v9/tiles/256/{z}/{x}/{y}?access_token=pk.eyJ1IjoiYmlza2F6eiIsImEiOiJjaXJkOTFkb3owMDdxaTltZ21vemsxcGViIn0.70mwo4YYnbxY_BJoEsGYxw' , { attribution : '© <a href="https://www.mapbox.com">Mapbox</a> Satelite' } ) ,
8- sateliteStreets = L . tileLayer ( 'https://api.mapbox.com/styles/v1/mapbox/satellite-streets-v9/tiles/256/{z}/{x}/{y}?access_token=pk.eyJ1IjoiYmlza2F6eiIsImEiOiJjaXJkOTFkb3owMDdxaTltZ21vemsxcGViIn0.70mwo4YYnbxY_BJoEsGYxw' , { attribution : '© <a href="https://www.mapbox.com">Mapbox</a> Satelite Streets' } ) ;
8+ sateliteStreets = L . tileLayer ( 'https://api.mapbox.com/styles/v1/mapbox/satellite-streets-v9/tiles/256/{z}/{x}/{y}?access_token=pk.eyJ1IjoiYmlza2F6eiIsImEiOiJjaXJkOTFkb3owMDdxaTltZ21vemsxcGViIn0.70mwo4YYnbxY_BJoEsGYxw' , { attribution : '© <a href="https://www.mapbox.com">Mapbox</a> Satelite Streets' } ) ,
9+ OpenStreetMap = L . tileLayer ( 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png' , { attribution : '© <a href="http://openstreetmap.org">OpenStreetMap</a> OpenStreetMap' } ) ;
910
1011let map = L . map ( 'map' , {
1112 center : [ 0 , 0 ] ,
12- zoom : 14 ,
13+ zoom : 8 ,
1314 layers : outdoors ,
1415 fullscreenControl : true ,
1516} ) ;
@@ -26,14 +27,64 @@ lc.start();
2627map . zoomControl . setPosition ( 'bottomright' ) ;
2728
2829let baseMaps = {
29- "Streets" : streets ,
3030 "Outdoors" : outdoors ,
31+ "Streets" : streets ,
3132 "Dark" : dark ,
3233 "Light" : light ,
3334 "Satelite" : satelite ,
34- "Satelite Streets" : sateliteStreets
35+ "Satelite Streets" : sateliteStreets ,
36+ "OpenStreetMap" : OpenStreetMap
3537} ;
3638
3739L . control . layers ( baseMaps ) . addTo ( map ) ;
3840
39- console . log ( map . getBounds ( ) ) ;
41+
42+ $ . get ( "/getimages.php" , function ( data ) {
43+ let result = JSON . parse ( data ) ;
44+ loadImages ( result ) ;
45+ } ) ;
46+
47+
48+ function loadImages ( images ) {
49+ let imgArray = [ ] ;
50+ let imgObjectArray = [ ] ;
51+
52+ images . forEach ( ( src , index ) => {
53+ let img = new Image ( ) ;
54+ img . src = src ;
55+ imgArray . push ( img ) ;
56+ } ) ;
57+
58+ imgArray . forEach ( ( img ) => {
59+ img . onload = function ( ) {
60+ EXIF . getData ( img , function ( ) {
61+ let imageLat = EXIF . getTag ( this , 'GPSLatitude' ) ;
62+ let imageLong = EXIF . getTag ( this , 'GPSLongitude' ) ;
63+ let imageAlt = EXIF . getTag ( this , 'GPSAltitude' ) ;
64+ let imageName = this . src . split ( "/" ) . reverse ( ) [ 0 ] ;
65+
66+ let realImageLat = imageLat [ 0 ] . numerator + imageLat [ 1 ] . numerator /
67+ ( 60 * imageLat [ 1 ] . denominator ) + imageLat [ 2 ] . numerator / ( 3600 * imageLat [ 2 ] . denominator ) ;
68+ let realImageLong = imageLong [ 0 ] . numerator + imageLong [ 1 ] . numerator /
69+ ( 60 * imageLong [ 1 ] . denominator ) + imageLong [ 2 ] . numerator / ( 3600 * imageLong [ 2 ] . denominator ) ;
70+ let realImageAlt = imageAlt . numerator / imageAlt . denominator ;
71+
72+ let imgObject = { } ;
73+ imgObject . realImageLat = realImageLat ;
74+ imgObject . realImageLong = realImageLong ;
75+ imgObject . realImageAlt = realImageAlt ;
76+ imgObject . imageName = imageName ;
77+ imgObjectArray . push ( imgObject ) ;
78+ console . log ( imgObject ) ;
79+ console . log ( imgObjectArray ) ;
80+ let imageDisplayString = '<img src="' + this . src + '" alt="Cool Photo" height="281" width="500">' ;
81+ L . marker ( [ realImageLat , realImageLong ] )
82+ . addTo ( map )
83+ . bindPopup ( imageDisplayString , {
84+ maxWidth : 1920 ,
85+ autoPanPadding : L . point ( 50 , 50 )
86+ } ) ( ) ;
87+ } ) ;
88+ } ;
89+ } ) ;
90+ }
0 commit comments