1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < title data-i18n ="resources.title_lianjia "> </ title >
6+ < script type ="text/javascript " src ="../js/include-web.js "> </ script >
7+ < style >
8+ body {
9+ margin : 0 ;
10+ overflow : hidden;
11+ background : # fff;
12+ width : 100% ;
13+ height : 100% ;
14+ position : absolute;
15+ top : 0 ;
16+ }
17+ # map {
18+ margin : 0 auto;
19+ width : 100% ;
20+ height : 100%
21+ }
22+
23+ # titleContainer {
24+ width : 100% ;
25+ position : absolute;
26+ top : 30px ;
27+ color : white;
28+ z-index : 999 ;
29+ font-size : 20px ;
30+ font-weight : bold;
31+ text-align : center;
32+ }
33+
34+ # titleContainer > # title {
35+ letter-spacing : 0.1em ;
36+ }
37+ </ style >
38+ </ head >
39+ < body >
40+ < div id ="map "> </ div >
41+ < div id ="titleContainer ">
42+ < h2 id ="title " data-i18n ="resources.text_lianjia_title "> </ h2 >
43+ </ div >
44+ < script type ="text/javascript " include ="echarts " src ="../../dist/include-leaflet.js "> </ script >
45+ < script >
46+ var host = window . isLocal ? window . server : "http://support.supermap.com.cn:8090" ;
47+ var baseurl = host + "/iserver/services/map-china400/rest/maps/ChinaDark" ;
48+ var dataUrl = "https://www.supermapol.com/iserver/services/map_201802beijingfangjia/rest/maps/2018年2月北京房价_链家小区参考价_格网" ;
49+ var map = L . map ( 'map' , {
50+ center : [ 39.88076184888246 , 116.42898559570312 ] ,
51+ zoom : 11 ,
52+ maxZoom : 18 ,
53+ minZoom : 6
54+ } ) ;
55+ L . supermap . tiledMapLayer ( baseurl ) . addTo ( map ) ;
56+ query ( ) ;
57+
58+ function query ( ) {
59+ var param = new SuperMap . QueryBySQLParameters ( {
60+ queryParams : {
61+ name : "lj_xq_500gw@BJ_201802LJ" ,
62+ attributeFilter : "SMID > 0"
63+ } ,
64+ fromIndex : 0 ,
65+ toIndex : 10000 ,
66+ maxFeatures : 10000
67+ } ) ;
68+ L . supermap . queryService ( dataUrl ) . queryBySQL ( param , function ( serviceResult ) {
69+ var result = serviceResult . result ;
70+ var features = result . recordsets [ 0 ] . features . features ;
71+ //构造数据
72+ var data = [ ] ;
73+ for ( var i = 0 ; i < features . length ; i ++ ) {
74+ var pointLeftTop = coordsTo4326 ( features [ i ] . geometry . coordinates [ 0 ] [ 0 ] [ 0 ] ) ;
75+ var pointRightBottom = coordsTo4326 ( features [ i ] . geometry . coordinates [ 0 ] [ 0 ] [ 2 ] ) ;
76+ var value = parseFloat ( ( features [ i ] . properties . average_price_1 / 10000 ) . toFixed ( 2 ) ) ;
77+ data . push ( pointLeftTop . concat ( value ) . concat ( pointRightBottom ) ) ;
78+ }
79+ var COLORS = [ '#e0dffb' , '#8c88ef' , '#5954e8' , '#221cd2' , '#17138d' , '#0c0a48' , '#030314' , 'red' ] ;
80+ var option = {
81+ tooltip : { } ,
82+ visualMap : {
83+ type : 'piecewise' ,
84+ inverse : true ,
85+ top : 110 ,
86+ left : 10 ,
87+ pieces : [ {
88+ gt : 0 , lte : 2 , color : COLORS [ 0 ]
89+ } , {
90+ gt : 2 , lte : 4 , color : COLORS [ 1 ]
91+ } , {
92+ gt : 4 , lte : 6 , color : COLORS [ 2 ]
93+ } , {
94+ gt : 6 , lte : 8 , color : COLORS [ 3 ]
95+ } , {
96+ gt : 8 , lte : 10 , color : COLORS [ 4 ]
97+ } , {
98+ gt : 10 , lte : 15 , color : COLORS [ 5 ]
99+ } , {
100+ gt : 15 , lte : 20 , color : COLORS [ 8 ]
101+ } , {
102+ gt : 20 , lte : 28 , color : COLORS [ 9 ]
103+ } ] ,
104+ borderColor : '#ccc' ,
105+ borderWidth : 2 ,
106+ backgroundColor : '#eee' ,
107+ dimension : 2 ,
108+ inRange : {
109+ color : COLORS ,
110+ opacity : 0.7
111+ }
112+ } ,
113+ series : [ {
114+ type : 'custom' ,
115+ coordinateSystem : "leaflet" ,
116+ data : data ,
117+ renderItem : renderItem ,
118+ animation : false ,
119+ itemStyle : {
120+ emphasis : {
121+ color : 'pink'
122+ }
123+ } ,
124+ encode : {
125+ tooltip : 2
126+ }
127+ } ]
128+ } ;
129+ // 自定义渲染
130+ function renderItem ( params , api ) {
131+ pointLeftTop = map . latLngToContainerPoint ( new L . LatLng ( api . value ( 1 ) , api . value ( 0 ) ) ) ;
132+
133+ pointRightBottom = map . latLngToContainerPoint ( new L . LatLng ( api . value ( 4 ) , api . value ( 3 ) ) ) ;
134+
135+ return {
136+ type : 'rect' ,
137+ shape : {
138+ x : pointLeftTop . x ,
139+ y : pointLeftTop . y ,
140+ width : pointLeftTop . x - pointRightBottom . x ,
141+ height : pointLeftTop . y - pointRightBottom . y
142+ } ,
143+ style : api . style ( {
144+ stroke : 'rgba(0,0,0,0.1)'
145+ } ) ,
146+ styleEmphasis : api . styleEmphasis ( )
147+ } ;
148+ }
149+ function coordsTo4326 ( coords ) {
150+ var lngLat = L . CRS . EPSG3857 . unproject ( L . point ( coords ) ) ;
151+ return [ lngLat . lng , lngLat . lat ] ;
152+ }
153+ L . supermap . echartsLayer ( option ) . addTo ( map ) ;
154+ } ) ;
155+ }
156+ </ script >
157+ </ body >
158+ </ html >
0 commit comments