| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <!doctype html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title></title>
- <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
- <link rel="stylesheet" href="../css/mui.min.css" />
- <link rel="stylesheet" href="../css/common.css" />
- <link rel="stylesheet" type="text/css" href="../css/equipList.css" />
- <style type="text/css">
- .mapBox {
- position: fixed;
- left: 0;
- right: 0;
- top: 0;
- bottom: 0;
- /*background: pink;*/
- }
-
- #map {
- height: 100%;
- width: 100%;
- }
- </style>
- </head>
- <body>
- <header class="mui-bar mui-bar-nav">
- <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
- <h1 class="mui-title">手动定位</h1>
- <a id="addbtn" class="mui-icon mui-icon-gear mui-pull-right"></a>
- </header>
- <div class="mui-content">
- <!--srfwegwerg-->
- <!--<div class="searchBox">
- <div class="searchControl">
- <div class="mui-input-row mui-search">
- <input type="search" id="searchInp" class="mui-input-clear" placeholder="请输入设备ID">
- </div>
- <button id="searchBtn" class="searchBtn">搜索</button>
- </div>
- </div>-->
- <div class="mapBox">
- <div id="map"></div>
- </div>
- </div>
- <script src="../js/jquery-2.1.0.js"></script>
- <script src="../js/mui.min.js"></script>
- <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=La58N63t7hPhafQ7Eror2kon"></script>
- <script type="text/javascript">
- mui.init();
- mui.plusReady(function() {
- //百度地图获取坐标
- var map = new BMap.Map("map"); // 创建地图实例
- map.centerAndZoom(new BMap.Point(113.64964385, 34.75661006), 13); // 创建点坐标
- map.enableScrollWheelZoom(true);
- map.addControl(new BMap.ScaleControl()); // 添加比例尺控件
- map.addControl(new BMap.NavigationControl()); //为地图添加鱼骨(默认)
- map.addEventListener("tilesloaded", function() {
- $(".BMap_cpyCtrl").hide();
- }); //地图加载完毕后 隐藏百度图标
- var lng = '',
- lat = '';
- //单击获取点击的经纬度
- map.addEventListener("click", function(e) {
- map.clearOverlays();
- lng = '';
- lat = '';
- $('#lng').val(e.point.lng);
- $('#lat').val(e.point.lat);
- var point = new BMap.Point(e.point.lng, e.point.lat);
- var marker = new BMap.Marker(point);
- map.addOverlay(marker);
- lng = e.point.lng;
- lat = e.point.lat;
- mui.confirm('添加经纬度', '添加经纬度', ['确定', '取消'], function() {
- mui.ajax('http://120.27.222.26/qxz_location', {
- dataType: 'json', //服务器返回json格式数据
- type: 'post', //HTTP请求类型
- timeout: 10000, //超时时间设置为10秒;
- data: {
- e_id: self.imei,
- lng: lng,
- lat: lat,
- },
- success: function(data) {
- console.log(data)
- if(data == 0) {
- mui.toast('添加成功')
- } else {
- mui.toast('添加失败')
- }
- },
- error: function(type) {
- console.log(type)
- }
- });
- }, 'div')
- // alert(e.point.lng + "," + e.point.lat);
- });
- var self = plus.webview.currentWebview(); //获取上页发送的id
- console.log(self.imei)
- //添加位置
- document.getElementById('addbtn').addEventListener('tap', function(e) {
- mui('#popover').popover('toggle'); //show hide toggle
- e.detail.gesture.preventDefault(); //修复iOS 8.x平台存在的bug,使用plus.nativeUI.prompt会造成输入法闪一下又没了
- var btnArray = ['确定', '取消'];
- mui.prompt('英文逗号隔开:', '请填写设备经纬度', '请填写设备经纬度', btnArray, function(e) {
- if(e.index == 0) {
- var value = document.querySelector('.mui-popup-input textarea').value;
- if(value == '') {
- return false;
- }
- lng = value.split(',')[0];
- lat = value.split(',')[1];
- map.clearOverlays();
- var points = []
- var point = new BMap.Point(lng, lat);
- var marker = new BMap.Marker(point);
- map.addOverlay(marker);
- points.push(point)
- console.log(points)
- map.setViewport(points);
- mui.ajax('http://120.27.222.26/qxz_location', {
- dataType: 'json', //服务器返回json格式数据
- type: 'post', //HTTP请求类型
- timeout: 10000, //超时时间设置为10秒;
- data: {
- e_id: self.imei,
- lng: lng,
- lat: lat,
- },
- success: function(data) {
- console.log(data)
- if(data == 0) {
- mui.toast('添加成功')
- } else {
- mui.toast('添加失败')
- }
- },
- error: function(type) {
- console.log(type)
- }
- });
- } else {
- // info.innerText = '你点了取消按钮';
- console.log('你点了取消按钮')
- }
- }, 'div')
- $('.mui-popup-input').html('');
- $('.mui-popup-input').append('<textarea></textarea>')
- //prompt默认值
- if(lng != '' && lng != '') {
- document.querySelector('.mui-popup-input textarea').value = lng + ',' + lat;
- }
- })
- })
- //搜索操作
- // $("#searchInp").on('keypress',function(e) {
- // var keycode = e.keyCode;
- // if(keycode=='13') {
- // e.preventDefault();
- // //请求搜索接口
- // if(mui('#searchInp')[0].value) {
- // getListData({num:1, size:10})
- // } else {
- // mui.toast("请输入设备ID");
- // }
- // }
- // })
- // document.getElementById('searchBtn').addEventListener('tap', function() {
- // if(mui('#searchInp')[0].value) {
- // getListData({num:1, size:10})
- // } else {
- // mui.toast("请输入设备ID");
- // }
- // })
- </script>
- </body>
- </html>
|