123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444 |
- $(function(){
-
- var on_off = true;
- var cityString = new Object();
- var page = 1;
-
-
- var _h = $(window).height();
- $('.max_box').css({'height':_h,'position':'relative','top':'-20px'});
- $('#allmap').css('height',_h);
- $('.m_qhcs_box').css('height',_h);
-
- $('.m_City_ul_li').on('touchstart','div.m_City_province',function(){
- $(this).addClass('on').siblings().removeClass('on'),
- on_off = true;
- var _this = $(this);
- var txt = _this.text();
- var city_id = _this.attr('data-id');
- FnAera(city_id);
- page = 1;
- $('.batch').fadeOut();
-
- $('.map_aera a').html(txt);
- $('.m_qhcs_box').animate({top:"-"+_h+"px"});
- $('.m_qhcs_box').fadeOut();
- })
-
- $('.map_aera').on('touchstart',function(){
- $('.m_qhcs_box').fadeIn();
- $('.m_qhcs_box').animate({top:"0px"});
- $('.batch').fadeOut();
- })
-
- function FnAera(cityN){
- $.ajax({
- url:"/map/getcity",
- type:"post",
- data:{city:cityN,csrf_token_m:csrfToken},
- dataType:"json",
- success:function(data){
- remove_overlay();
- if(data.code == 200){
- $.each(data.data,function(k,v){
- labelFu(v);
- })
- }
- },
- error:function(request){
- console.log('加载失败!');
- }
- })
- }
-
- $('.batch').on('touchstart',function(){
- ++page;
- if(cityString.hasOwnProperty('page')){
- page = cityString.page;
- delete cityString.page;
- }
- $('.max_box').append('<div class="load"><img src="/map/image/loading1.gif" alt="" /></div>')
- var prov = cityString.city;
- fuAjaxLabel(prov,page);
- })
-
-
-
-
- var currentLocation,cityName,map,point;
- var cityObject = {cityName:'海口',cityPoint:{lng:'110.300805',lat:'20.003838'}}
-
-
- map = new BMap.Map("allmap");
- point=new BMap.Point(cityObject.cityPoint.lng,cityObject.cityPoint.lat);
- map.centerAndZoom(point, 8);
- map.setCurrentCity(cityObject.cityName);
- map.enableScrollWheelZoom(true);
- var geoc = new BMap.Geocoder();
-
- var top_left_navigation = new BMap.NavigationControl({anchor: BMAP_ANCHOR_BOTTOM_RIGHT,offset: new BMap.Size(10, 50)});
- map.addControl(top_left_navigation);
-
- function labelFu(data){
- var datacenter = data;
- var text = datacenter.name;
-
- var count = datacenter.number;
- var point = newPoint(datacenter.point);
- var _points = new BMap.Point(point[0],point[1]);
- if(on_off){
- map.centerAndZoom(_points, 8);
- on_off = false;
- }
-
-
- function ComplexCustomOverlays(point){
- this._point = point;
- }
- ComplexCustomOverlays.prototype = new BMap.Overlay();
- ComplexCustomOverlays.prototype.initialize = function(map){
- this._map = map;
- var div = this._div = document.createElement("div");
- div.style.position = "absolute";
- div.style.zIndex = BMap.Overlay.getZIndex(this._point.lat);
- div.style.height = "45px";
- div.style.width="45px";
- div.style.cursor="pointer";
- div.style.zIndex = 0;
-
-
-
-
- var arrow = this._arrow = document.createElement("p");
- arrow.style.background = "url(/map/image/yuan1.png) no-repeat 0px 0px/62px 117px";
- arrow.style.backgroundPosition = "8px -54px";
- arrow.style.width = "70px";
- arrow.style.height = "55px";
- arrow.style.lineHeight = "20px";
- arrow.style.marginTop = "-8px";
- arrow.style.textAlign = "center";
- arrow.style.top = "30px";
- arrow.style.padding = "10px 0";
- arrow.style.left = "68px";
- arrow.style.color = "#FFF";
- arrow.style.fontSize="0.75rem";
-
- var _ew = this.arow = document.createElement("em");
- _ew.innerHTML = text;
- var _arow = this.arow = document.createElement("span");
- _arow.style.display = " block";
- _arow.innerHTML = count;
- arrow.appendChild(_ew);
- div.appendChild(arrow);
- arrow.appendChild(_arow);
-
- div.onmouseover = function(){
- arrow.style.background = "url(/map/image/yuan1.png) no-repeat center/62px 117px";
- arrow.style.backgroundPosition = "8px 1px";
- this.style.zIndex = 99990;
- }
- div.onmouseout = function(){
- arrow.style.background = "url(/map/image/yuan1.png) no-repeat center/62px 117px";
- arrow.style.backgroundPosition = "8px -54px";
- this.style.zIndex = 0;
- }
-
- div.addEventListener("touchstart", function () {
- var province = $(this).find('em').text();
- on_off = true;
- cityString.city = province;
- $('.batch').fadeIn();
- fuAjaxLabel(province,page);
-
- });
- map.getPanes().labelPane.appendChild(div);
-
- return div;
-
- }
-
- ComplexCustomOverlays.prototype.draw = function(){
- var map = this._map;
- var pixel = map.pointToOverlayPixel(this._point);
- this._div.style.left = pixel.x - parseInt(this._arrow.style.left) + "px";
- this._div.style.top = pixel.y - 30 + "px";
- }
- var myCompOverlay = new ComplexCustomOverlays(_points);
- map.addOverlay(myCompOverlay);
-
- }
-
- function fuAjaxLabel(cityName,page){
- $.ajax({
- url:"/map/houselist",
- type:"post",
- data:{city:cityName,page:page,csrf_token_m:csrfToken},
- dataType:"json",
- success:function(data){
- setTimeout(function(){
- $('.load').remove();
- },300);
- setTimeout(function(){
- if(data.code == 200){
- remove_overlay();
-
-
- $.each(data.data.data,function(k,v){
- addCover(v);
- })
- if(data.data.data.length < 20){
- cityString.page = 1;
- }
- }else if(data.code == 300){
- cityString.page = 1;
- }
- },350);
- },
- error:function(request){
- console.log('加载失败!');
- }
- })
- }
-
- function addCover(objData){
-
- var pic = objData.price;
- var _pic = (pic != '0' && pic != null && pic != '' && pic != 'null' ) ? objData.price : "待定";
-
- var txt = objData.name, mouseoverTxt ="";
- var information = objData;
- var coordinate = newPoint(objData.longitude_latitude);
-
- var _point = new BMap.Point(coordinate[0],coordinate[1]);
- var myCompOverlay = new ComplexCustomOverlay(_point, txt,mouseoverTxt,information);
- map.addOverlay(myCompOverlay);
- if(on_off){
- map.centerAndZoom(_point, 11);
- on_off = false;
- }
- }
-
-
- function ComplexCustomOverlay(point, text, mouseoverText,information){
- this._point = point;
- this._text = text;
- this._overText = mouseoverText;
- this.information = information;
-
- }
- ComplexCustomOverlay.prototype = new BMap.Overlay();
- ComplexCustomOverlay.prototype.initialize = function(map){
- this._map = map;
- var div = this._div = document.createElement("div");
- div.style.position = "absolute";
- div.style.zIndex = BMap.Overlay.getZIndex(this._point.lat);
- div.style.backgroundColor = "#33C0D0";
- div.style.border = "1px solid #33C0D0";
- div.style.color = "white";
-
- div.style.padding = "5px 15px";
- div.style.lineHeight = "18px";
- div.style.whiteSpace = "nowrap";
- div.style.MozUserSelect = "none";
- div.style.fontSize = "12px";
- div.setAttribute("class","shadow");
- div.setAttribute("pid", this.information.id);
- var span = this._span = document.createElement("span");
- div.appendChild(span);
- span.appendChild(document.createTextNode(this._text));
- var that = this;
- var arrow = this._arrow = document.createElement("div");
- arrow.style.background = "url(/map/image/label.png) no-repeat";
- arrow.style.position = "absolute";
- arrow.style.width = "11px";
- arrow.style.height = "10px";
- arrow.style.top = "28px";
- arrow.style.left = "10px";
- arrow.style.backgroundPosition = "0 -19px";
- arrow.style.overflow = "hidden";
- div.appendChild(arrow);
-
-
- div.addEventListener("touchstart", function(){
- var hid = $(this).attr('pid');
- FnInfo(hid);
-
- });
- div.onmouseover = function(){
- this.style.backgroundColor = "#6BADCA";
- this.style.borderColor = "#0000ff";
- this.getElementsByTagName("span")[0].innerHTML = that._text;
- arrow.style.backgroundPosition = "0px -20px";
- }
- div.onmouseout = function(){
- this.style.backgroundColor = "#EE5D5B";
- this.style.borderColor = "#BC3B3A";
- this.getElementsByTagName("span")[0].innerHTML = that._text;
- arrow.style.backgroundPosition = "0px 0px";
- }
- map.getPanes().labelPane.appendChild(div);
-
- return div;
- }
- ComplexCustomOverlay.prototype.draw = function(){
- var map = this._map;
- var pixel = map.pointToOverlayPixel(this._point);
- this._div.style.left = pixel.x - parseInt(this._arrow.style.left) + "px";
- this._div.style.top = pixel.y - 30 + "px";
- }
-
- function FnInfo(id){
- $.ajax({
- url:"/map/details",
- type:"get",
- data:{hid:id},
- dataType:"json",
- success:function(data){
- var v =data.data;
- if(data.code == 200){
-
-
- var price = '<span style="font-size:1rem;color:red;">待定</span>'
- if(v.sale_price != 0 && v.sale_price != "" && v.sale_price != null){
- price = '价格:<span><em>'+v.sale_price+'</em><i>'+v.price_unit+'</i></span>';
- }
-
- $('.w_info_box').find('.w_house_img img').attr('src',v.thumb);
- $('.w_info_box').find('.w_house_img > a').attr('href','/house/sanyashi-'+v.id+'/');
- $('.w_info_box').find('.w_house_img a > span').html(v.city_name);
- $('.w_info_box').find('.w_title').html('<span>'+v.name+'</span>');
-
- $('.w_info_box').find('.w_price').html(price);
- var _li =""
- $.each(v.characteristic,function(k,j){
- _li += '<i>'+j+'</i>'
- })
- $('.w_info_box').find('.w_feature').html(_li);
-
- $('.w_info_box').fadeIn();
- $('.w_info_box').animate({top:'20%'});
- $('.cover').fadeIn();
- }
- },
- error:function(request){
- console.log('加载失败!');
- }
- })
- }
-
-
- $('.w_btn').on('touchstart',function(){
- $('.w_info_box').animate({top:'-100%'});
- $('.cover').fadeOut();
- })
-
- $('.cover').on('touchstart',function(){
- $('.w_info_box').animate({top:'-100%'});
- $(this).fadeOut();
- })
-
-
- function remove_overlay(){
- map.clearOverlays();
- }
-
- function newPoint(_point){
- var pointArr = [];
- if(_point != null){
- if(_point.indexOf(',') !== -1){
- var _pointx = _point.split(',')[0];
- var _pointy = _point.split(',')[1];
- }else if(_point.indexOf('|') !== -1){
- var _pointx = _point.split('|')[0];
- var _pointy = _point.split('|')[1];
- }
-
- pointArr.push(_pointx,_pointy);
- return pointArr;
- }
- }
- setInterval(function(){
- $('#LXB_CONTAINER_SHOW').hide();
- $('#LRMINIBar').hide();
- },80);
- })
|