123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- var map;
- map = new BMap.Map("divMap");
- map.centerAndZoom(new BMap.Point(116.404, 39.915), 11);
-
- map.addControl(new BMap.MapTypeControl({
- mapTypes:[
- BMAP_NORMAL_MAP,
- BMAP_HYBRID_MAP
- ]}));
- map.setCurrentCity("北京");
- map.enableScrollWheelZoom(true);
-
- var bounds = map.getBounds();
- var sw = bounds.getSouthWest();
- var ne = bounds.getNorthEast();
- var lngSpan = Math.abs(sw.lng - ne.lng);
- var latSpan = Math.abs(ne.lat - sw.lat);
- var markers = new BMap.Marker(new BMap.Point(116.404, 39.915));
- var point;
- var marker;
- var marker1;
- var marker2;
- var marker3;
- var marker4;
-
- var sContent =
- "<div style='width: 350px'>"+
- "<h4 style='margin:6px 0;padding:0.2em 0'><span>MG2013</span><span style='float: right'>水质监测</span></h4>" +
- "<p style='margin:0;line-height:1.5;font-size:13px;'><label style='font-weight: 600'>维护单位:</label>沱江简阳段31号1段</p>" +
- "<p style='margin:0;line-height:1.5;font-size:13px;'><label style='font-weight: 600'>位置:</label>沱江简阳段31号1段</p>" +
- "<p style='border-bottom: 1px dashed #cccccc'></p>"+
- "<p style='margin-top:10px;line-height:1.5;font-size:13px;'><span style='display: inline-block;width: 32%;text-align: center;color: red'>高猛酸盐(1.2M/L)</span><span style='display: inline-block;width: 32%;text-align: center'>总磷(1.2M/L)</span><span style='display: inline-block;width: 32%;text-align: center'>氨氮(1.2M/L)</span></p>"+
- "</div>";
-
- var sContent1 =
- "<div style='width: 350px'>"+
- "<h4 style='margin:6px 0;padding:0.2em 0'><span>MG2013</span><span style='float: right'>流量监测</span></h4>" +
- "<p style='margin:0;line-height:1.5;font-size:13px;'><label style='font-weight: 600'>维护单位:</label>沱江简阳段31号1段</p>" +
- "<p style='margin:0;line-height:1.5;font-size:13px;'><label style='font-weight: 600'>位置:</label>沱江简阳段31号1段</p>" +
- "<p style='border-bottom: 1px dashed #cccccc'></p>"+
- "<p style='margin-top:10px;line-height:1.5;font-size:13px;'><span style='display: inline-block;width: 32%;text-align: center;color: red'>水流时速(1.2KM/S)</span><span style='display: inline-block;width: 32%;text-align: center'>大小(1.2M/L)</span></p>"+
- "</div>";
-
- var sContent2 =
- "<div style='width: 350px'>"+
- "<h4 style='margin:6px 0;padding:0.2em 0'><span>MG2013</span><span style='float: right'>水位监测</span></h4>" +
- "<p style='margin:0;line-height:1.5;font-size:13px;'><label style='font-weight: 600'>维护单位:</label>沱江简阳段31号1段</p>" +
- "<p style='margin:0;line-height:1.5;font-size:13px;'><label style='font-weight: 600'>位置:</label>沱江简阳段31号1段</p>" +
- "<p style='border-bottom: 1px dashed #cccccc'></p>"+
- "<p style='margin-top:10px;line-height:1.5;font-size:13px;'><span style='display: inline-block;width: 32%;text-align: center;color: red'>最高位(1.2M)</span><span style='display: inline-block;width: 32%;text-align: center'>最低位(0.2M)</span></p>"+
- "</div>";
-
- var sContent3 =
- "<div style='width: 350px'>"+
- "<h4 style='margin:6px 0;padding:0.2em 0'><span>MG2013</span><span style='float: right'>视频监测</span></h4>" +
- "<p style='margin:0;line-height:1.5;font-size:13px;'><video style='width: 100%;height: 200px;background-color: black'></video></p>"
- "</div>";
-
- var sContent4 =
- "<div style='width: 350px'>"+
- "<h4 style='margin:6px 0;padding:0.2em 0'><span>川A2013</span><span style='float: right'>车辆监测</span></h4>" +
- "<p style='margin:0;line-height:1.5;font-size:13px;'><label style='font-weight: 600'>驾驶人:</label>李小华</p>" +
- "<p style='margin:0;line-height:1.5;font-size:13px;'><label style='font-weight: 600'>所属人:</label>李小华</p>" +
- "<p style='margin:0;line-height:1.5;font-size:13px;'><label style='font-weight: 600'>所在位置:</label>沱江简阳段31号1段</p>" +
- "<p style='border-bottom: 1px dashed #cccccc'></p>"+
- "<p style='margin-top:10px;line-height:1.5;font-size:13px;'><span style='display: inline-block;width: 32%;text-align: center;'>标志(508)</span><span style='display: inline-block;width: 32%;text-align: center'>排量(2T)</span><span style='display: inline-block;width: 32%;text-align: center;'>2015-10-09</span></p>"+
- "</div>";
- var infoWindow = new BMap.InfoWindow(sContent);
- var infoWindow1 = new BMap.InfoWindow(sContent1);
- var infoWindow2 = new BMap.InfoWindow(sContent2);
- var infoWindow3 = new BMap.InfoWindow(sContent3);
- var infoWindow4 = new BMap.InfoWindow(sContent4);
-
-
- $("#zt_4").change(function(){
- inputCheck(point,marker,infoWindow);
- })
-
- $("#zt_1").change(function(){
- inputCheck(point,marker1,infoWindow1);
- })
-
- $("#zt_5").change(function(){
- inputCheck(point,marker3,infoWindow2);
- })
-
- $("#zt_6").change(function(){
- inputCheck(point,marker2,infoWindow3);
- })
-
- $("#zt_2").change(function(){
- inputCheck(point,marker4,infoWindow4);
- })
- function addLocal(){
- map.addOverlay(markers);
- markers.addEventListener("click",function(){
- this.openInfoWindow(infoWindow);
- })
- }
- function inputCheck(pt,mak,info){
- if($('input[type=checkbox]').is(':checked')){
- for (var i = 0; i < 25; i ++) {
- pt = new BMap.Point(sw.lng + lngSpan * (Math.random() * 0.7), ne.lat - latSpan * (Math.random() * 0.7));
- mak= new BMap.Marker(pt);
- map.addOverlay(mak);
- mak.addEventListener("click", function(){
- this.openInfoWindow(info);})
- }
- }
- else{
- map.clearOverlays();
- }
- }
- $(".search_location").click(function(){
- addLocal();
- })
- function run(){
- var myP1 = new BMap.Point(116.380967,39.913285);
- var myP2 = new BMap.Point(116.424374,39.914668);
- var myIcon = new BMap.Icon("img/car.png", new BMap.Size(32, 70), {
-
- imageOffset: new BMap.Size(0, 0)
- });
- var driving2 = new BMap.DrivingRoute(map, {renderOptions:{map: map, autoViewport: true}});
- driving2.search(myP1, myP2);
- var driving = new BMap.DrivingRoute(map);
- driving.search(myP1, myP2);
- driving.setSearchCompleteCallback(function(){
- var pts = driving.getResults().getPlan(0).getRoute(0).getPath();
- var paths = pts.length;
- var carMk = new BMap.Marker(pts[0],{icon:myIcon});
- map.addOverlay(carMk);
- i=0;
- function resetMkPoint(i){
- carMk.setPosition(pts[i]);
- if(i < paths){
- setTimeout(function(){
- i++;
- resetMkPoint(i);
- },100);
- }
- }
- setTimeout(function(){
- resetMkPoint(5);
- },100)
- });
- }
|