1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="utf-8 ">
5+ < title > Examples - Geohashes</ title >
6+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
7+ < meta name ="description " content ="">
8+ < meta name ="author " content ="">
9+
10+ <!-- Le styles -->
11+ < link href ="../lib/bootstrap/css/bootstrap.css " rel ="stylesheet ">
12+ < style >
13+ body {
14+ overflow : hidden;
15+ }
16+
17+ .leaflet-tile-pane {
18+ opacity : 0.3 ;
19+ }
20+
21+ div .navbar {
22+ margin-bottom : 0px ;
23+ }
24+
25+ # map {
26+ padding : 0px ;
27+ margin : 0px ;
28+ }
29+
30+ </ style >
31+ < link rel ="stylesheet " href ="../lib/bootstrap/css/bootstrap-responsive.css ">
32+ < link rel ="stylesheet " href ="../lib/leaflet-1.0/leaflet.css " type ="text/css " media ="screen "/>
33+ < link rel ="stylesheet " href ="../../dist/css/dvf.css " type ="text/css " media ="screen "/>
34+ < link rel ="stylesheet " href ="../css/example.css " type ="text/css " media ="screen "/>
35+
36+ </ head >
37+
38+ < body >
39+ < div class ="navbar ">
40+ < div class ="navbar-inner ">
41+ < div class ="container ">
42+ < a class ="btn btn-navbar " data-toggle ="collapse " data-target =".nav-collapse ">
43+ < span class ="icon-bar "> </ span >
44+ < span class ="icon-bar "> </ span >
45+ < span class ="icon-bar "> </ span >
46+ </ a >
47+ < a class ="brand " href ="# "> Geohashes</ a >
48+
49+ < div class ="nav-collapse collapse ">
50+ < ul class ="nav ">
51+ < li class ="active "> < a href ="http://humangeo.github.io/leaflet-dvf "> Home</ a > </ li >
52+ </ ul >
53+ </ div >
54+ <!--/.nav-collapse -->
55+ </ div >
56+ </ div >
57+ </ div >
58+
59+ < div id ="map "> </ div >
60+ < script >
61+ ( function ( i , s , o , g , r , a , m ) {
62+ i [ 'GoogleAnalyticsObject' ] = r ;
63+ i [ r ] = i [ r ] || function ( ) {
64+ ( i [ r ] . q = i [ r ] . q || [ ] ) . push ( arguments )
65+ } , i [ r ] . l = 1 * new Date ( ) ;
66+ a = s . createElement ( o ) ,
67+ m = s . getElementsByTagName ( o ) [ 0 ] ;
68+ a . async = 1 ;
69+ a . src = g ;
70+ m . parentNode . insertBefore ( a , m )
71+ } ) ( window , document , 'script' , 'http://www.google-analytics.com/analytics.js' , 'ga' ) ;
72+
73+ ga ( 'create' , 'UA-42733116-1' , 'humangeo.github.io' ) ;
74+ ga ( 'send' , 'pageview' ) ;
75+ </ script >
76+ < script type ="text/javascript " src ="http://code.jquery.com/jquery-1.9.1.min.js "> </ script >
77+ < script type ="text/javascript " src ="../lib/bootstrap/js/bootstrap.min.js "> </ script >
78+ < script type ="text/javascript " src ="../lib/leaflet-1.0/leaflet-src.js "> </ script >
79+ < script type ="text/javascript " src ="../lib/jsts/javascript.util.js "> </ script >
80+ < script type ="text/javascript " src ="../lib/jsts/jsts.js "> </ script >
81+ < script type ="text/javascript " src ="../lib/date.format.js "> </ script >
82+ < script type ="text/javascript " src ="../lib/geohash.js "> </ script >
83+ < script type ="text/javascript " src ="http://maps.stamen.com/js/tile.stamen.js?v1.2.4 "> </ script >
84+ < script type ="text/javascript " src ="../../dist/leaflet-dvf.min.js "> </ script >
85+ < script type ="text/javascript " src ="http://chancejs.com/chance.min.js "> </ script >
86+ < script type ="text/javascript ">
87+ $ ( document ) . ready ( function ( ) {
88+ var map ;
89+
90+ // Function for resizing the map to fill the available space on the screen
91+ var resize = function ( ) {
92+ var $map = $ ( '#map' ) ;
93+
94+ $map . height ( $ ( window ) . height ( ) - $ ( 'div.navbar' ) . outerHeight ( ) ) ;
95+
96+ if ( map ) {
97+ map . invalidateSize ( ) ;
98+ }
99+ } ;
100+
101+ // Resize the map element on window resize
102+ $ ( window ) . on ( 'resize' , function ( ) {
103+ resize ( ) ;
104+ } ) ;
105+
106+ // Resize the map element
107+ resize ( ) ;
108+
109+ // create a map in the "map" div, set the view to a given place and zoom
110+ map = L . map ( 'map' , {
111+ renderer : L . canvas ( )
112+ } ) . setView ( [ 0.0 , 0.0 ] , 2 ) ;
113+
114+ var baseLayer = new L . StamenTileLayer ( 'toner' , {
115+ detectRetina : true
116+ } ) ;
117+
118+ baseLayer . addTo ( map ) ;
119+
120+ var max = 30000 ;
121+ var geohashData = {
122+ "terms" : [ ] ,
123+ } ;
124+
125+ for ( var h = 0 ; h < 5000 ; h ++ ) {
126+ geohashData . terms . push ( {
127+ count : ~ ~ ( Math . random ( ) * max ) ,
128+ term : chance . geohash ( { length : 3 } )
129+ } ) ;
130+ }
131+
132+ var colorFunction = new L . HSLHueFunction ( new L . Point ( 0 , 200 ) , new L . Point ( max , 0 ) , { outputSaturation : '100%' , outputLuminosity : '25%' } ) ;
133+ var fillColorFunction = new L . HSLHueFunction ( new L . Point ( 0 , 200 ) , new L . Point ( max , 0 ) , { outputSaturation : '100%' , outputLuminosity : '50%' } ) ;
134+
135+ var options = {
136+ recordsField : 'terms' ,
137+ geohashField : 'term' ,
138+ displayOptions : {
139+ count : {
140+ color : colorFunction ,
141+ fillColor : fillColorFunction ,
142+ gradient : true ,
143+ displayName : 'Count'
144+ }
145+ } ,
146+ legendOptions : {
147+ gradient : true
148+ } ,
149+ layerOptions : {
150+ fillOpacity : 0.7 ,
151+ opacity : 1 ,
152+ weight : 1
153+ }
154+ } ;
155+
156+ var options2 = {
157+ recordsField : 'data' ,
158+ geohashField : null ,
159+ layerOptions : {
160+ fillOpacity : 0.7 ,
161+ opacity : 1 ,
162+ weight : 1
163+ }
164+ } ;
165+
166+ var legendControl = new L . Control . Legend ( ) ;
167+ map . addControl ( legendControl ) ;
168+
169+ var layer = new L . GeohashDataLayer ( geohashData , options ) ;
170+
171+ map . addLayer ( layer ) ;
172+
173+ } ) ;
174+ </ script >
175+ </ body >
176+ </ html >
0 commit comments