newmap1.html 27.6 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <title>附近车场</title>
    <link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
    <link rel="stylesheet" href="../iconfont/iconfont.css" />
    <link rel="stylesheet" href="js/tcyd.css" />
    <link rel="stylesheet" href="../js/bootstrap/bootstrap.css" />   
    <style type="text/css">
    	body{
    		width: 100%;
    		/*padding: 10px;*/
    		box-sizing: border-box;
    		position: relative;
    	}
    	.row{
    		width: 100%;
    		margin-left: 0;
    		margin-right: 0;
    	}
        .amap-marker .marker-route {
            position: absolute;
            width: 40px;
            height: 44px;
            color: #e90000;
            background: url(http://webapi.amap.com/theme/v1.3/images/newpc/poi-1.png) no-repeat;
            cursor: pointer;
        }
        .amap-marker .marker-marker-bus-from {
            background-position: -334px -180px;
        }
        .amap-geolocation-con{
            /*bottom:30% !important;*/
            position: absolute;
            z-index: 9999;
            left: 20px;
            /*top:50%;*/
            top: 66%;
            width: 35px;
            height: 35px;
        }
        .neir{
            width:100%;
            background: #0D9BF2;
			/*border-radius: 5px;*/
			border:1px solid #9B9B9B;
            display: table;
            background: #307ff5;
        }
        .neir>div{
            display: inline-block;
            height:100px;
            padding:10px;
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
            vertical-align: middle;
            display: table-cell;
        }
        .neir>div.leftinfo{
            background: #fff;
            width:80%;
        }
        .neir>div.rightinfo{
            width:20%;
            text-align: center;
            color: #fff;
            font-size: 14px;
        }
        .neir>div.rightinfo i{
        	font-size: 30px;
        	color: #fff;
        }
        .marker-marker-bus-from>span>span{
            position: absolute;
            top:-30px;
            display: inline-block;
            height: 30px;
            line-height: 30px;
            background: #fff;
            padding: 0 3px;
            box-shadow: 0 0 5px rgba(0,0,0,0.2);
        }
        .mark>span>span{
            display: none;
        }
        .list{
            left:10px;
            top:70px;
            margin-bottom:-50px;
        }
        /*list 样式*/
        .leftinfo{
            padding:0 10px;
        }
        .leftinfo .lname{
            font-size:14px;
            margin-bottom:8px;
            height: 20px;
            overflow: hidden;
        }
        .leftinfo .bg00f{
            background: #00ff00;
            color: #fff;
            border-radius: 3px;
            font-size:12px;
            padding:3px 5px;
        }
        .leftinfo .lnum,.leftinfo .ladres{
            font-size:13px;
            color: #ACB3BB;
        }
        .leftinfo .font00f{
            color: #0f0;
        }
        .leftinfo .ladres .font0f0{
            color: #00f;
        } 
        .iconlist{
        	background: #fff;
        	font-size: 25px;
        	text-align: center;
        }
        .iconlist.iconfont{
        	color: #666;
        	font-size: 14px !important;
        }
        .searchb{
       		width: 100%;
       		position: absolute;
       		padding: 10px;
       		box-sizing: border-box;
       		z-index: 887;
        }
        .search{
        	box-sizing: border-box;
        	width: 100%;
			height: 40px;
			line-height: 40px;
			border-radius: 20px;
			overflow: hidden;
			margin: 0;
			background: rgba(106,178,180,0.7);
			padding: 0 10px;
			box-sizing: border-box;
		}
		.search div{
				box-sizing: border-box;
				padding: 0;
		}
		.search div i{
			color: #fff;
		}
		.search div input{
				height: 40px;
				line-height: 40px;
				border-style: none;
				background: none;
				width: 100%;
		}
		::-webkit-input-placeholder { /* WebKit browsers */
		    color:    #fff;
		}
		:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
		    color:    #fff;
		}
		::-moz-placeholder { /* Mozilla Firefox 19+ */
		    color:    #fff;
		}
		:-ms-input-placeholder { /* Internet Explorer 10+ */
		    color:    #fff;
		}
		.amap-ui-control-theme-normal{
			top: 50% !important;
			margin-top: -12px !important;
			right: 10px !important;
		}
        .amap-ui-control-theme-normal{
        	/*top: 60px !important;*/
        }
        .P{
			width: 30px;
			height: 30px;
			border-radius: 50%;
			
			margin:200px auto;
			padding: 3px;
			background: #fff;
			box-sizing: border-box;
			position: relative;
			box-shadow: 0 0 10px rgba(0,0,0,0.4);
		}
		.P>div{
			background: #00FF00;
			width: 100%;
			height: 100%;
			border-radius: 50%;
		}
		.P>span{
			display: inline-block;
			position: absolute;
			width: 5px;
			height: 5px;
			transform: rotate(135deg);
			background: #CE3C39;
			bottom: -2px;
			left: 11px;
			background: #fff;
		}
		
		.amap-simple-marker-label {
		    line-height: 30px; 
		    color: #fff;
		}
		.layui-layer-demo .layui-layer-content{
			padding: 10px;
			border-radius: 6px;
		}
		.mapdata{
			width: 100%;
			z-index: 887;
			background: #fff;
			margin-top: 15px;
			position: relative;
		}
		.mapdata .infolist{
			width: 100%;
			padding: 10px;
			position: relative;
			overflow: hidden;
			padding-right: 70px;
		}
		.mapdata .infolist img{
			width: 100%;
			position: absolute;
			top: 0;
			left: 0;
			z-index: -1;
		}
		.mapdata .infolist .infocarnum{
			position: absolute;
			bottom: 15px;
			right: 10px;
			width: 50px;
			height: 50px;
			background: #75CBBE;
			text-align: center;
			color: #fff;
			/*display:flex;
            justify-content:center;
            align-items:center;*/
            display: table-cell;
            vertical-align: middle;
		}
		.mapdata .infolist .infocarnum>div{
			width: 50px;
			height: 50px;
			display: table-cell;
            vertical-align: middle;
		}
		.mapdata .infolist .infocarnum .carnofz{
			font-size: 20px;
			text-align: center;
		}
		.mapdata .infolist .infocarnum .carnofzs{
			font-size: 13px;
			text-align: center;
		}
		.mapdata .infolist .addrN{
			color: #fff;
		}
		.mapdata .infolist .addrN p:nth-child(2){
			font-size: 12px;
		}
		.mapdata .infolist .addrN p:last-child span{
			font-size: 12px;
			background: rgba(0,0,0,0.5);
			padding: 5px 10px;
			border-radius: 3px;
			color: #fff;
		}
		.mapdata .div2{
			background: #fff;
			/*padding: 10px;*/
		}
		.mapdata .div2 div{
			padding: 10px;
		}
		.mapdata .div2 div,.mapdata .div2 div i{
			text-align: center;
			color: #88929a;
		}
		.mapdata .div2 div:first-child>span{
			width: 1px;
			height: 16px;
			background: #F5F5F5;
			float: right;
			margin-top: 3px;
		}
		.mapdata .div2 div:first-child,.mapdata .div2 div:first-child i{
			color: #75CBBE;
		}
    </style>
    <script  type="text/javascript" src="https://3gimg.qq.com/lightmap/components/geolocation/geolocation.min.js" ></script>   
    <script type="text/javascript" src="http://webapi.amap.com/maps?v=1.4.1&key=4ffd877f121218774f565671ba9d3b10"></script>
    
</head>
<body>
	<div class="searchb">
		<div class="search row" id="search">
			<div class=" col-xs-1">
				<i class="icon iconfont">&#xe603;</i>
			</div>
			<div class=" col-xs-11">
				<input class="" type="text" placeholder="输入位置/停车场名称搜索包年包月卡" />
			</div>
		</div>
		<div class="mapdata onepark">
			<div class="infolist"  onclick="gaodec();">
				<img src="imgs/pinfo.png" />
				<div class="addrN">
					<p id="parkname">中国传感网国家创新园</p>
					<p id="laddre">江苏省无锡市新吴区菱湖大道200号</p>
					<p>
						<span id="distace">0.8km</span>
						<span>3min</span>
					</p>
				</div>
				<div class="infocarnum">
					<div>
						<div class="carnofz" id="idleberths">143</div>
						<div class="carnofzs">空位</div>
					</div>
				</div>
			</div>
			<div class="div2 row">
				<div class="col-xs-6"  onclick="gaodec();">
					<i class="icon iconfont">&#xe605;</i>
					导航
					<span></span>
				</div>
				<div class="col-xs-6">
					<i class="icon iconfont">&#xe614;</i>
					更多信息
				</div>
			</div>
		</div>
	</div>
	
	<div id="container"></div>
	<div class="amap-ui-control-container amap-ui-mobile amap-ui-retina" style="border-radius: 4px;left: 10px; top: 74%;box-shadow: 1px 1px 2px silver;border: solid 1px silver;background: #fff;overflow: hidden;width: 35px;height: 35px;">
		<div class="amap-ui-control-traffic" onclick="parklist();">
	    	<div class="iconlist icon iconfont">&#xe69f;</div>
		    <div class="amap-ui-control-traffic-text">列表</div>
		</div>
	</div>
	<!--<div class="onepark" style="display: none;" onclick="gaodec();">
	    <div class="neir">
	        <div class="leftinfo">
	            <div class="lname">
	                <span class="bg00f" id="status">充足</span>
	                <span id="parkname">放技能粗人哦</span>
	            </div>
	            <div class="lnum">
	               
	            </div>
	            <div class="ladres">
	                <span id="laddre">菱湖大道200号</span>&nbsp;&nbsp;
	                <span id="distace" class="font0f0">距离您0km</span>
	            </div>
	        </div>
	        <div class="rightinfo" >
	        	<div><i class="icon iconfont">&#xe6ce;</i></div>
	        	<div>导航</div>
	        </div>
	    </div>
	</div>-->
<script src="../js/jquery-3.2.1.min.js"></script>
<script src="../js/bootstrap/bootstrap.js"></script>
<script src="../js/layui/layui/layui.js"></script>
<!--md5 start-->
<script src="../js/md5.min.js"></script>
<!--md5 end-->
<script src="../js/url.js"></script>
<script src="../js/ajax.js"></script>
<script type="text/javascript" src="js/tcyd.js" ></script> 
<script src="js/main.js"></script>
<script src="//webapi.amap.com/ui/1.0/main.js?v=1.0.11"></script>
<script>
	var plon=plat=null;
	var iii = 0;
	var markers = [];
	var mapObj = new AMap.Map('container');
	var src = location.href;
	var s = src.split('?')[1];
	layui.use(['layer'], function(){});
	if(s){
		var local = s.split('&');
		plon = local[0].split('=')[1];
		plat = local[1].split('=')[1];
		mapObj.setZoomAndCenter(15, [plon, plat]);
		console.log('src dtaa '+plon);
	}	
	$(function(){
		//点击覆盖层
		$('div.layui-layer-shade').on('click',function(){
			console.log('点击影');
			//return false;
		});
		//点击覆盖层
		$('body').on('click','.layui-layer-content p',function(){
			console.log($(this).attr('id'));
		});
	})
	
	var bb = 0;
	var infoWindow = new AMap.InfoWindow({offset: new AMap.Pixel(0, -30)});
	AMapUI.loadUI(['misc/MarkerList', 'overlay/SimpleMarker', 'overlay/SimpleInfoWindow'],
        function(MarkerList, SimpleMarker, SimpleInfoWindow) {
        	var markerList = new MarkerList({
                //关联的map对象
                map: mapObj,
                zoom:mapObj.getZoom(),
                autoSetFitView:false,
                //列表的dom容器的id
                //返回数据项的Id
                getDataId: function(dataItem, index) {
                    return dataItem.id;
                },
                //返回数据项的位置信息,需要是AMap.LngLat实例,或者是经纬度数组,比如[116.79, 39.90]
                getPosition: function(dataItem) {
                    return dataItem.position;
                },
                //返回数据项对应的Marker
                getMarker: function(dataItem, context, recycledMarker) {
                    //存在可回收利用的marker
                    if (recycledMarker) {
                    	//直接更新内容返回
                       // recycledMarker.setIconLabel(dataItem.icon);
                        //recycledMarker.setIcon(dataItem.icon);
                        //recycledMarker.setIconStyle(dataItem.position);
                        //return recycledMarker;
                    }
                    var iconlabel = 0;
                    var img = '';
                    var cnum = parseInt(dataItem.extData.idleberths);
                    if(dataItem.idleberths>10){
                    	img = 'a4.png';//充足
                	}else if(dataItem.idleberths<10&&dataItem.idleberths>0){
                		img = 'a1.png';//紧张
                	}else if(dataItem.idleberths<=0){
                		img = 'a3.png';//停满
                	}
                	if(dataItem.idleberths>99){
            			iconlabel = '99';
            		}else if(dataItem.idleberths<=99){
            			iconlabel = dataItem.idleberths;
            		}
                    if(dataItem.extData.type==3){
                    	img = 'a4.png';//充足
                    	iconlabel = 'P';
                    }
                    /*return new AMap.Marker({
				        map: mapObj,
			            position: [dataItem.position[0], dataItem.position[1]],
			            clickable:true,
			            title:dataItem.extData.name,
			            content:'1',
			            icon: new AMap.Icon({            
				            size: new AMap.Size(40, 50),  //图标大小
				            image: "http://webapi.amap.com/theme/v1.3/images/newpc/way_btn2.png",
				            imageOffset: new AMap.Pixel(0, -60)
				        }),
				        
						extData:dataItem.extData,
				    });*/
                    //返回一个新的Marker
                    return new SimpleMarker({
                    	map: mapObj,
			            position: [dataItem.position[0], dataItem.position[1]],
			            clickable:true,
			            title:dataItem.extData.name,
			            iconStyle: {
                            src: img,
                            style: {
                                width:'30px',
                                color:'#fff'
                            }
                    	},
                    	iconLabel:iconlabel,
						extData:dataItem.extData,
                    });
                },
                //返回数据项对应的infoWindow
                getInfoWindow: function(dataItem, context, recycledInfoWindow) {
                    var tpl = dataItem.extData.name;
	                //MarkerList.utils.template支持underscore语法的模板
	                var content = MarkerList.utils.template(tpl, {
	                    dataItem: dataItem,
	                    dataIndex: context.index
	                });
	                var n1 = [plon,plat];
					var n2 = [dataItem.extData.longitude,dataItem.extData.latitude];
					var d = distances(n2);
	                datax(dataItem.extData.idleberths,dataItem.extData.name,dataItem.extData.totalberths,dataItem.extData.address,d,dataItem.extData.latitude,dataItem.extData.longitude);
        			//$(".onepark").css('display','block');
        			$(".onepark").attr('data-parkCode',dataItem.extData.pklNo);
        					/*infoWindow.setContent(name);
							infoWindow.open(mapObj, ds.position);*/
	                //返回一个新的InfoWindow
	                return new AMap.InfoWindow({
	                    offset: new AMap.Pixel(0, -23),
	                    content: content
	                });
                },
            });
			//监听Marker和ListElement上的点击
	        markerList.on('markerClick ', function(event, record) {
	            //console.log('6777');
	            //JSON.stringify(info)
	        });
	        mapObj.on('dragend',function(e){
	        	
		        var zuob = mapObj.getCenter();
		        var lng = zuob.lng;
		        var lat = zuob.lat;
		        console.log('tuodong'+lng+"  "+lat);
		        iii=0;
		        smarker(lng,lat,function(data){
		        	markerList.render(data);
		        });
		        //mapObj.setZoom(10);
	        	
		    });
		    if(plon&&plat&&plon!=null&&plat!=null){
		    	//if(plon&&plat&&plon!=null&&plat!=null){}
		    	console.log('有经纬度时候、');
		    	if(!markers||markers==null||markers==undefined||markers==''){
		    		console.log('有经纬度时候、无值时候');
		    		iii=0;
		    		var str = smarker(plon,plat,function(data){
		    			console.log('ii5788888888888888888888888888888888');
		    			markerList.render(data);
		    		});
		    	}else{
		    		console.log('有经纬度时候、有值值时候');
		    		console.log('markers2   '+markers+"  "+typeof(markers));
		    		markerList.render(markers);
		    	}
		    }else{
		    	console.log('执行1定位');
		    	//需要定位得到数据
			    mapObj.plugin('AMap.Geolocation', function () {
				    geolocation = new AMap.Geolocation({
				        enableHighAccuracy: true,//是否使用高精度定位,默认:true
				        timeout: 10000,          //超过10秒后停止定位,默认:无穷大
				        maximumAge: 0,           //定位结果缓存0毫秒,默认:0
				        convert: true,           //自动偏移坐标,偏移后的坐标为高德坐标,默认:true
				        showButton: true,        //显示定位按钮,默认:true
				        buttonPosition: 'LB',    //定位按钮停靠位置,默认:'LB',左下角
				        buttonOffset: new AMap.Pixel(10, 20),//定位按钮与设置的停靠位置的偏移量,默认:Pixel(10, 20)
				        showMarker: true,        //定位成功后在定位到的位置显示点标记,默认:true
				        showCircle: true,        //定位成功后用圆圈表示定位精度范围,默认:true
				        panToLocation: false,     //定位成功后将定位到的位置作为地图中心点,默认:true
				        zoomToAccuracy:false      //定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false
				    });
				    mapObj.addControl(geolocation);
				    geolocation.getCurrentPosition();
				    AMap.event.addListener(geolocation, 'complete', function(data){
				    	plon = data.position.lng;
				    	plat = data.position.lat;
				    	//alert(plon+"   "+plat);
				    	console.log('定位成功  '+plon+"  纬度:"+plat);
				    	iii=0;
				    	var localtion = {
							plon:plon,
							plat:plat
						};
				    	sessionStorage.setItem('rntlonandlat',JSON.stringify(localtion));
				    	smarker(plon,plat,function(datas){
							markerList.render(datas);
						});
				    });//返回定位信息
				    AMap.event.addListener(geolocation, 'error', function(data){
				    	console.log("定位失败"+data);
				    	var lng = 120.365681;
				    	var lat = 31.502592;
				    	var localtion = {
							plon:lng,
							plat:lat
						};
				    	sessionStorage.setItem('rntlonandlat',JSON.stringify(localtion));
				    	smarker(lng,lat,function(datas){
							markerList.render(datas);
						});
						//mapObj.setZoom(15);
				    });      //返回定位出错信息
				});
				/*plon = 120.365681;
				plat = 31.502592;*/
				/*var localtion = {
					plon:plon,
					plat:plat
				};
				sessionStorage.setItem('rntlonandlat',JSON.stringify(localtion));
				mapObj.setZoomAndCenter(15, [plon, plat]);
				smarker(plon,plat,function(datas){
					markerList.render(datas);
				});*/
				//markerList.render(markers);
		    }
	});
	//点击调用高德
	function gaodec(){
		var idleberths = $(".onepark").attr('data-idleberths');
		var dic = $(".onepark").attr('data-dic');
		var lon = $(".onepark").attr('data-lon');
		var lat = $(".onepark").attr('data-lat');
		var status = $(".onepark").attr('data-status');
		var name = $(".onepark").attr('data-name');
		var parkCode = $(".onepark").attr('data-parkCode');
		//console.log('空余车位:'+idleberths+"距离:"+dic+"状态:"+status+"名称:"+name);
		console.log('缓存经纬度  '+sessionStorage.getItem('rntlonandlat'));
		if(status=='1'){
			var salt = jsajax.salt(32); 
			var deviceInfo = mUrl.getDevice();
			var sortd = [
				{keyname:'app_id',value:'0eca8f5373ca4866aec2f8e9d9367104'},
				{keyname:'deviceInfo',value:deviceInfo},
				{keyname:'salt',value:salt},
				{keyname:'sign_type',value:'md5'},
				{keyname:'parkCode',value:parkCode},
				{keyname:'parkName',value:name},
				//{keyname:'token',value:''},
				{keyname:'localongitude',value:lon},
				{keyname:'localatitude',value:lat},
				{keyname:'idleberths',value:idleberths},
				{keyname:'distance',value:dic},
			];
			
			var mdsign = jsajax.getsign(sortd);
			var jsond = {
				app_id:'0eca8f5373ca4866aec2f8e9d9367104',
				deviceInfo:deviceInfo,
				salt:salt,
				sign_type:'md5',
				parkCode:parkCode,
				parkName:name,
				sign:mdsign,
				//token:'',
				localongitude:lon,
				localatitude:lat,
				idleberths:idleberths,
				distance:dic,
			}
			jsajax.defaultReq(
				mUrl.sendFreepark,
				JSON.stringify(jsond),
				function(data){
					console.log(JSON.stringify(data));
					if(data.code=='0'){
						if(data.data&&data.data.parkCode){
							var pklNo = data.data.parkCode;
							var cn = data.data.idleberths;
							var n2 = data.data.parkName;
							var positiona = [data.data.longitude,data.data.latitude];
							var d2 = toDecimal2((parseFloat(distances(positiona))*0.001));
							if(pklNo==parkCode){
								ktrnty(name,dic,cn,positiona);
							}else{
								var p = [lon,lat];
								ktrntw(name,dic,idleberths,p,n2,d2,cn,positiona)
							}
						}else{
							var p = [lon,lat];
							ktrnty(name,dic,idleberths,p);
						}
						
					}else{
						console.log(data.message);
					}
				}
			);
		}else{
			var positiona = [lon,lat];
			wktrnt(name,dic,positiona);
		}
		//点击哦     layui-layer-shade
		//var lon = $(".onepark").attr('data-lon');
		//var lat = $(".onepark").attr('data-lat');
		//window.location.href = '//uri.amap.com/navigation?from='+plon+','+plat+',startpoint&to='+lon+','+lat+',endpoint&mode=car&policy=1&src=mypage&coordinate=gaode&callnative=1';
	}
	
	function click(){
		console.log('11');
	}
	//返回数据
	function smarker(lon,lat,success){
		//console.log('shuuju   '+lon+"  "+lat);
    	var markersz = [];
    	var marks = [];
    	var salt = jsajax.salt(32);
    	var sortd = [
    		{keyname:'app_id',value:'0eca8f5373ca4866aec2f8e9d9367104'},
    		{keyname:'deviceInfo',value:'BC0703A4-AFB0-4B51-9089-9B7487C0CC6E'},
    		{keyname:'latitude',value:lat},
    		{keyname:'limit',value:'2000'},
    		{keyname:'longitude',value:lon},
    		{keyname:'salt',value:salt},
    		{keyname:'sign_type',value:'md5'},
    		{keyname:'type',value:'01'}
    	];
    	var mdsign = jsajax.getsign(sortd);
    	var jsondata = {
    		app_id:'0eca8f5373ca4866aec2f8e9d9367104',
    		deviceInfo:'BC0703A4-AFB0-4B51-9089-9B7487C0CC6E',
    		latitude:lat,
    		longitude:lon,
    		salt:salt,
    		sign_type:'md5',
    		type:'01',
    		limit:'2000',
    		sign:mdsign
    	};
    	jsajax.defaultReq(
    		mUrl.ParkingLots,
    		JSON.stringify(jsondata),
    		function(data){
    			//console.log(JSON.stringify(data));
    			if(data.code==0){
    				//console.log('正确之后的数据   ');
    				var datas = data.data;
    				markers = datas;
    				for(var i=0;i<datas.length;i++){
    					var address = datas[i].address;
    					var chargeDetail = datas[i].chargeDetail;
         				var distance = datas[i].distance;
        				var idleberths = datas[i].idleberths;
        				var latitude = datas[i].latitude;
        				var longitude = datas[i].longitude;
        				var name = datas[i].name;
        				var phone = datas[i].phone;
        				var pklNo = datas[i].pklNo;
        				var totalberths = datas[i].totalberths;
        				var type = datas[i].type;
        				var ds = {
        					content: '<div class="marker-route marker-marker-bus-from"></div>',
					        position: [longitude, latitude],
					        extData:datas[i],
					        idleberths:idleberths
        				}
        				if(i==0&&iii==0){
        					var n2 = [longitude,latitude];
        					var d = distances(n2);
        					datax(idleberths,name,totalberths,address,d,latitude,longitude);
        					//$(".onepark").css('display','block');
        					$(".onepark").attr('data-parkCode',pklNo);
        					infoWindow.setContent(name);
							infoWindow.open(mapObj, ds.position);
        					iii++;
        				}
        				markersz.push(ds);
        			}
    				success(markersz);
    			}
    		}
    	);
    }
	function parklist() {
    	if(plon&&plat&&plon!=''&&plat!=''){
    		window.location.href = 'parklist.html?plon='+plon+'&plat='+plat;
    	}
    }
    //mapObj.setFitView();
    //数据填写
    function datax(idleberths,name,totalberths,address,distance,latitude,longitude){
    	if(idleberths>10){
        	$("#status").text('充足');
        	$("#status").css('background','#0f0');
        }else if(idleberths>0&&idleberths<10){
        	$("#status").text('紧张');
        	$("#status").css('background','#ff9e04');
        }else if(idleberths==0&&totalberths&&totalberths!=0&&totalberths!='0'){
        	$("#status").text('停满');
        	$("#status").css('background','#f00');
        }else {
			$("#status").text('充足');
        	$("#status").css('background','#0f0');
		}
        $("#parkname").text(name);
        $('#idleberths').text(idleberths);
        /*var n2 = [longitude,latitude];
        var dic = distances(n2);*/
        $(".onepark").attr('data-name',name);
        $(".onepark").attr('data-lon',longitude);
        $(".onepark").attr('data-lat',latitude);
        $(".onepark").attr('data-idleberths',idleberths);
        $(".onepark").attr('data-dic','0');
        if(totalberths&&totalberths!=0&&totalberths!='0'&&idleberths){
        	$(".onepark").attr('data-status','1');
        	var yt = parseInt(totalberths) - parseInt(idleberths);
        	
			///$(".lnum").html('当前车位:<span class="font00f" id="kongnum">'+idleberths+'</span>/<span id="allnum">'+totalberths+'</span>');
        	//console.log(totalberths+"  "+idleberths+"  "+yt);
        }else{
        	$(".onepark").attr('data-status','0');
			//$(".lnum").html('<span class="flan">暂未开通任你停</span>');
        }
        $("#laddre").text(address);
        
        if(distance&&distance!='null'){
        	var distancep = toDecimal2((parseFloat(distance)*0.001)) ;
            /*$("#distace").text('距离您'+distancep+'km');*/
            $("#distace").text(distancep+'km');
            $(".onepark").attr('data-dic',distancep);
        }else{
        	$("#distace").text('0km');
        }
        
    }
    function distances(n2){
    	/*var lnglat = new AMap.LngLat(plon, plat);
	    AMap.event.addDomListener(document.getElementById('calc'), 'click', function() {
	        var dist = lnglat.distance(n2);
	        dist = dist*0.001;
	        return dist;
	    });*/
	   console.log('原来  '+sessionStorage.getItem('rntlonandlat'));
	    if(sessionStorage.getItem('rntlonandlat')){
	    	var lon = sessionStorage.getItem('rntlonandlat');
	    	lon = JSON.parse(lon);
	    	var lng,lat;
	    	if(lon!=''){
	    		lng = lon.plon;
	    		lat = lon.plat;
	    	}		
		    var lnglat = new AMap.LngLat(lng, lat);
		    console.log('两点间距离   '+lnglat.distance(n2));
		    return lnglat.distance(n2);
	    }
	    /*AMap.event.addDomListener(document.getElementById('calc'), 'click', function() {
	        alert('两点间距离为:' + lnglat.distance([116.387271, 39.922501]) + '米');
	    });*/
    }
    //制保留2位小数,如:2,会在2后面补上00.即2.00
    function toDecimal2(x) {
        var f = parseFloat(x);
        if (isNaN(f)) {
            return false;
        }
        var f = Math.round(x*100)/100;
        var s = f.toString();
        var rs = s.indexOf('.');
        if (rs < 0) {
            rs = s.length;
            s += '.';
        }
        while (s.length <= rs + 2) {
            s += '0';
        }
        return s;
    }
    AMapUI.loadUI(['control/BasicControl'], function(BasicControl) {
        var traffic = new BasicControl.Traffic({
            showButton: true,
            theme: 'normal',
            open:false
        });

        mapObj.addControl(traffic);
    });
</script>
</body>
</html>