Commit 8050bb6cc8bc29ff4c8b4dafe07a4ab3d7c04668
1.部分内容与浦交分支合并
Showing
46 changed files
with
7551 additions
and
7140 deletions
pom.xml
| @@ -181,27 +181,32 @@ | @@ -181,27 +181,32 @@ | ||
| 181 | 181 | ||
| 182 | <!-- pentaho kettle 依赖 --> | 182 | <!-- pentaho kettle 依赖 --> |
| 183 | <dependency> | 183 | <dependency> |
| 184 | - <groupId>com.pentaho.kettle</groupId> | 184 | + <groupId>pentaho-kettle</groupId> |
| 185 | <artifactId>kettle-core</artifactId> | 185 | <artifactId>kettle-core</artifactId> |
| 186 | <version>6.0.1.0-386</version> | 186 | <version>6.0.1.0-386</version> |
| 187 | + <exclusions> | ||
| 188 | + <exclusion> | ||
| 189 | + <groupId>org.apache.xmlgraphics</groupId> | ||
| 190 | + <artifactId>batik-js</artifactId> | ||
| 191 | + </exclusion> | ||
| 192 | + </exclusions> | ||
| 193 | + </dependency> | ||
| 194 | + <dependency> | ||
| 195 | + <groupId>pentaho-kettle</groupId> | ||
| 196 | + <artifactId>kettle-engine</artifactId> | ||
| 197 | + <version>6.0.1.0-386</version> | ||
| 187 | </dependency> | 198 | </dependency> |
| 188 | - <dependency> | ||
| 189 | - <groupId>com.pentaho.kettle</groupId> | ||
| 190 | - <artifactId>kettle-engine</artifactId> | ||
| 191 | - <version>6.0.1.0-386</version> | ||
| 192 | - </dependency> | ||
| 193 | <dependency> | 199 | <dependency> |
| 194 | - <groupId>com.pentaho.kettle</groupId> | 200 | + <groupId>pentaho</groupId> |
| 195 | <artifactId>metastore</artifactId> | 201 | <artifactId>metastore</artifactId> |
| 196 | <version>6.0.1.0-386</version> | 202 | <version>6.0.1.0-386</version> |
| 197 | </dependency> | 203 | </dependency> |
| 198 | <dependency> | 204 | <dependency> |
| 199 | - <groupId>com.pentaho.kettle</groupId> | ||
| 200 | - <artifactId>vfs2</artifactId> | 205 | + <groupId>org.apache.commons</groupId> |
| 206 | + <artifactId>commons-vfs2</artifactId> | ||
| 201 | <version>2.1-20150824</version> | 207 | <version>2.1-20150824</version> |
| 202 | </dependency> | 208 | </dependency> |
| 203 | 209 | ||
| 204 | - | ||
| 205 | <dependency> | 210 | <dependency> |
| 206 | <groupId>net.sourceforge.jexcelapi</groupId> | 211 | <groupId>net.sourceforge.jexcelapi</groupId> |
| 207 | <artifactId>jxl</artifactId> | 212 | <artifactId>jxl</artifactId> |
| @@ -291,12 +296,6 @@ | @@ -291,12 +296,6 @@ | ||
| 291 | 296 | ||
| 292 | 297 | ||
| 293 | <dependency> | 298 | <dependency> |
| 294 | - <groupId>ojdbc</groupId> | ||
| 295 | - <artifactId>ojdbc</artifactId> | ||
| 296 | - <version>14</version> | ||
| 297 | - </dependency> | ||
| 298 | - | ||
| 299 | - <dependency> | ||
| 300 | <groupId>org.apache.mina</groupId> | 299 | <groupId>org.apache.mina</groupId> |
| 301 | <artifactId>mina-core</artifactId> | 300 | <artifactId>mina-core</artifactId> |
| 302 | <version>2.0.13</version> | 301 | <version>2.0.13</version> |
src/main/java/com/bsth/Application.java
| @@ -17,7 +17,7 @@ import java.util.concurrent.ScheduledExecutorService; | @@ -17,7 +17,7 @@ import java.util.concurrent.ScheduledExecutorService; | ||
| 17 | @SpringBootApplication | 17 | @SpringBootApplication |
| 18 | public class Application extends SpringBootServletInitializer { | 18 | public class Application extends SpringBootServletInitializer { |
| 19 | 19 | ||
| 20 | - public static ScheduledExecutorService mainServices = Executors.newScheduledThreadPool(18); | 20 | + public static ScheduledExecutorService mainServices = Executors.newScheduledThreadPool(21); |
| 21 | 21 | ||
| 22 | @Override | 22 | @Override |
| 23 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { | 23 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { |
src/main/java/com/bsth/XDApplication.java
| @@ -97,8 +97,8 @@ public class XDApplication implements CommandLineRunner { | @@ -97,8 +97,8 @@ public class XDApplication implements CommandLineRunner { | ||
| 97 | timeDiff = (DateUtils.getTimestamp() + 1000 * 60 * 140) - System.currentTimeMillis(); | 97 | timeDiff = (DateUtils.getTimestamp() + 1000 * 60 * 140) - System.currentTimeMillis(); |
| 98 | if (timeDiff < 0) | 98 | if (timeDiff < 0) |
| 99 | timeDiff += (1000 * 60 * 60 * 24); | 99 | timeDiff += (1000 * 60 * 60 * 24); |
| 100 | - // 早上07:00 | ||
| 101 | - timeDiffTraffic = (DateUtils.getTimestamp() + 1000 * 60 * 60 * 7) - System.currentTimeMillis(); | 100 | + // 早上09:00 |
| 101 | + timeDiffTraffic = (DateUtils.getTimestamp() + 3600000 * 9) - System.currentTimeMillis(); | ||
| 102 | if (timeDiffTraffic < 0) | 102 | if (timeDiffTraffic < 0) |
| 103 | timeDiffTraffic += (1000 * 60 * 60 * 24); | 103 | timeDiffTraffic += (1000 * 60 * 60 * 24); |
| 104 | } | 104 | } |
| @@ -120,6 +120,9 @@ public class XDApplication implements CommandLineRunner { | @@ -120,6 +120,9 @@ public class XDApplication implements CommandLineRunner { | ||
| 120 | case "test": | 120 | case "test": |
| 121 | testInit(); | 121 | testInit(); |
| 122 | break; | 122 | break; |
| 123 | + case "cloud": | ||
| 124 | + cloudInit(); | ||
| 125 | + break; | ||
| 123 | default: | 126 | default: |
| 124 | break; | 127 | break; |
| 125 | } | 128 | } |
| @@ -266,4 +269,48 @@ public class XDApplication implements CommandLineRunner { | @@ -266,4 +269,48 @@ public class XDApplication implements CommandLineRunner { | ||
| 266 | //线路版本更新 | 269 | //线路版本更新 |
| 267 | //sexec.scheduleWithFixedDelay(fixedEnableVerionsThread, 60 * 4, 60 * 2 , TimeUnit.SECONDS); | 270 | //sexec.scheduleWithFixedDelay(fixedEnableVerionsThread, 60 * 4, 60 * 2 , TimeUnit.SECONDS); |
| 268 | } | 271 | } |
| 272 | + | ||
| 273 | + public void cloudInit(){ | ||
| 274 | + log.info("cloudInit..."); | ||
| 275 | + ScheduledExecutorService sexec = Application.mainServices; | ||
| 276 | + //安全驾驶 | ||
| 277 | + sexec.scheduleWithFixedDelay(safeDrivDataLoadThread, 180, 10, TimeUnit.SECONDS); | ||
| 278 | + | ||
| 279 | + GpsDataLoaderThread.setFlag(-1); | ||
| 280 | + /** 线调业务 */ | ||
| 281 | + sexec.scheduleWithFixedDelay(scheduleRefreshThread, 10, 120, TimeUnit.SECONDS);//班次更新线程 | ||
| 282 | + sexec.scheduleWithFixedDelay(scheduleLateThread, 140, 20, TimeUnit.SECONDS);//检查班次误点 | ||
| 283 | + sexec.scheduleWithFixedDelay(gpsDataLoader, 0, 2, TimeUnit.SECONDS);//抓取GPS数据 | ||
| 284 | + sexec.scheduleWithFixedDelay(rfidDataLoader, 5, 5, TimeUnit.SECONDS);//抓取RFID数据 | ||
| 285 | + sexec.scheduleWithFixedDelay(fixedCheckStationCodeThread, 60, 60 * 5, TimeUnit.SECONDS);//检查班次站点编码 | ||
| 286 | + | ||
| 287 | + sexec.scheduleWithFixedDelay(offlineMonitorThread, 120, 60, TimeUnit.SECONDS);//GPS设备掉离线 | ||
| 288 | + sexec.scheduleWithFixedDelay(schedulePstThread, 180, 10, TimeUnit.SECONDS);//班次延迟入库线程 | ||
| 289 | + sexec.scheduleWithFixedDelay(seiPstThread, 180, 60, TimeUnit.SECONDS);//班次修正日志入库 | ||
| 290 | + sexec.scheduleWithFixedDelay(directivesPstThread, 120, 60, TimeUnit.SECONDS);//调度指令延迟入库 | ||
| 291 | + sexec.scheduleWithFixedDelay(threadMonotor, 240, 60, TimeUnit.SECONDS);//线程监听(防止重要的线程阻塞、异常结束。以及部分主备切换工作) | ||
| 292 | + sexec.scheduleWithFixedDelay(sampleTimeDataLoader, 140, 120 * 60, TimeUnit.SECONDS);//到离站预测需要的站点间耗时数据 | ||
| 293 | + sexec.scheduleWithFixedDelay(basicDataLoader, 1, 1, TimeUnit.HOURS);//基础数据更新 | ||
| 294 | + sexec.scheduleWithFixedDelay(autoExecScanThread, 180, 50, TimeUnit.SECONDS);//班次自动执行 | ||
| 295 | + DirectivePushQueue.start();//消息队列 -指令,系统下发的 | ||
| 296 | + WebSocketPushQueue.start();//消息队列 -webSocket ,推送至线调web页面的 | ||
| 297 | + | ||
| 298 | + /** 线调为其他程序提供的数据 --写入数据库 */ | ||
| 299 | + sexec.scheduleWithFixedDelay(fcxxUpdateThread, 160, 30, TimeUnit.SECONDS);//发车信息(发车屏、信息发布) | ||
| 300 | + //线路首末班数据(网关用,班次更新时写入) | ||
| 301 | + //com.bsth.data.schedule.f_a_l.FirstAndLastHandler | ||
| 302 | + sexec.scheduleWithFixedDelay(schSiginUpdateDBThread, 160, 60 * 30, TimeUnit.SECONDS);//无法自动完成的班次信息(网关用,补信号) | ||
| 303 | + | ||
| 304 | + //运管处静态数据提交 | ||
| 305 | + log.info(timeDiff / 1000 / 60 + "分钟之后提交到运管处"); | ||
| 306 | + sexec.scheduleAtFixedRate(submitToTrafficManage, timeDiffTraffic / 1000, 60 * 60 * 24, TimeUnit.SECONDS); | ||
| 307 | + //计算油、公里加注 | ||
| 308 | + sexec.scheduleAtFixedRate(calcOilThread, timeDiff / 1000, 60 * 60 * 24, TimeUnit.SECONDS); | ||
| 309 | + | ||
| 310 | + //线路版本更新 | ||
| 311 | + sexec.scheduleWithFixedDelay(lineVersionsData, 60 * 5, 60 * 15, TimeUnit.SECONDS); | ||
| 312 | + | ||
| 313 | + //线路版本更新 | ||
| 314 | + //sexec.scheduleWithFixedDelay(fixedEnableVerionsThread, 60 * 4, 60 * 2 , TimeUnit.SECONDS); | ||
| 315 | + } | ||
| 269 | } | 316 | } |
src/main/java/com/bsth/common/Constants.java
| 1 | -package com.bsth.common; | ||
| 2 | - | ||
| 3 | -/** | ||
| 4 | - * | ||
| 5 | - * @ClassName: Constants | ||
| 6 | - * @Description: TODO(常量类) | ||
| 7 | - * @author PanZhao | ||
| 8 | - * @date 2016年3月18日 下午11:06:53 | ||
| 9 | - * | ||
| 10 | - */ | ||
| 11 | -public class Constants { | ||
| 12 | - | ||
| 13 | - /** | ||
| 14 | - * 不需要拦截的资源 | ||
| 15 | - */ | ||
| 16 | - public static final String LOGIN = "/user/login/**"; | ||
| 17 | - public static final String LOGIN_PAGE = "/login.html"; | ||
| 18 | - public static final String ASSETS_URL = "/assets/**"; | ||
| 19 | - public static final String FAVICON_URL = "/favicon.ico"; | ||
| 20 | - public static final String METRONIC_URL = "/metronic_v4.5.4/**"; | ||
| 21 | - public static final String LOGIN_FAILURE = "/user/loginFailure"; | ||
| 22 | - public static final String CAPTCHA = "/captcha.jpg"; | ||
| 23 | - | ||
| 24 | - // springboot manage health的检测url | ||
| 25 | - public static final String ACTUATOR_MANAGEMENT_HEALTH = "/manage/health"; | ||
| 26 | - // 车辆数据同步url | ||
| 27 | - public static final String VEHICLE_DATA_SYNC_URL = "/dataSync/vehicle/api/**"; | ||
| 28 | - | ||
| 29 | - //对外的营运数据接口 | ||
| 30 | - public static final String SERVICE_INTERFACE = "/companyService/**"; | ||
| 31 | - | ||
| 32 | - /** | ||
| 33 | - * 线调部分子页面不做拦截,便于浏览器缓存 | ||
| 34 | - */ | ||
| 35 | - public static final String XD_CHILD_PAGES = "/real_control_v2/**"; | ||
| 36 | - public static final String XD_REAL_GPS = "/gps/real/line"; | ||
| 37 | - //public static final String XD_TEMPS = "/pages/control/line/temps/**"; | ||
| 38 | - | ||
| 39 | - //车载网关上行接口 | ||
| 40 | - public static final String UPSTREAM_URL = "/control/upstream"; | ||
| 41 | - //rfid 上传入口 | ||
| 42 | - public static final String UP_RFID_URL = "/rfid/**"; | ||
| 43 | - | ||
| 44 | - public static final String SESSION_USERNAME = "sessionUserName"; | ||
| 45 | - public static final String COMPANY_AUTHORITYS = "cmyAuths"; | ||
| 46 | - public static final String STATION_AND_SECTION_COUNT = "/station/updateStationAndSectionCode"; | ||
| 47 | - | ||
| 48 | - /** | ||
| 49 | - * 解除调度指令和班次的外键约束 | ||
| 50 | - */ | ||
| 51 | - public static final String REMOVE_DIRECTIVE_SCH_FK = "update bsth_v_directive_60 set sch=NULL where sch=?"; | ||
| 52 | - | ||
| 53 | - /** | ||
| 54 | - * 批量解除调度指令和班次的外键约束 | ||
| 55 | - */ | ||
| 56 | - public static final String MULTI_REMOVE_DIRECTIVE_SCH_FK = "update bsth_v_directive_60 set sch=NULL where sch in "; | ||
| 57 | - | ||
| 58 | - /** | ||
| 59 | - * 批量解除子任务和班次的外键约束 | ||
| 60 | - */ | ||
| 61 | - public static final String MULTI_REMOVE_CHILDTASK_SCH_FK = "update bsth_c_s_child_task set schedule=NULL where schedule in "; | ||
| 62 | -} | 1 | +package com.bsth.common; |
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * | ||
| 5 | + * @ClassName: Constants | ||
| 6 | + * @Description: TODO(常量类) | ||
| 7 | + * @author PanZhao | ||
| 8 | + * @date 2016年3月18日 下午11:06:53 | ||
| 9 | + * | ||
| 10 | + */ | ||
| 11 | +public class Constants { | ||
| 12 | + | ||
| 13 | + /** | ||
| 14 | + * 不需要拦截的资源 | ||
| 15 | + */ | ||
| 16 | + public static final String LOGIN = "/user/login/**"; | ||
| 17 | + public static final String LOGIN_PAGE = "/login.html"; | ||
| 18 | + public static final String ASSETS_URL = "/assets/**"; | ||
| 19 | + public static final String FAVICON_URL = "/favicon.ico"; | ||
| 20 | + public static final String METRONIC_URL = "/metronic_v4.5.4/**"; | ||
| 21 | + public static final String LOGIN_FAILURE = "/user/loginFailure"; | ||
| 22 | + public static final String CAPTCHA = "/captcha.jpg"; | ||
| 23 | + | ||
| 24 | + // springboot manage health的检测url | ||
| 25 | + public static final String ACTUATOR_MANAGEMENT_HEALTH = "/manage/health"; | ||
| 26 | + // 车辆数据同步url | ||
| 27 | + public static final String VEHICLE_DATA_SYNC_URL = "/dataSync/vehicle/api/**"; | ||
| 28 | + | ||
| 29 | + //对外的营运数据接口 | ||
| 30 | + public static final String SERVICE_INTERFACE = "/companyService/**"; | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * 线调部分子页面不做拦截,便于浏览器缓存 | ||
| 34 | + */ | ||
| 35 | + public static final String XD_CHILD_PAGES = "/real_control_v2/**"; | ||
| 36 | + public static final String XD_REAL_GPS = "/gps/real/line"; | ||
| 37 | + //public static final String XD_TEMPS = "/pages/control/line/temps/**"; | ||
| 38 | + | ||
| 39 | + //车载网关上行接口 | ||
| 40 | + public static final String UPSTREAM_URL = "/control/upstream"; | ||
| 41 | + //rfid 上传入口 | ||
| 42 | + public static final String UP_RFID_URL = "/rfid/**"; | ||
| 43 | + | ||
| 44 | + public static final String SESSION_USERNAME = "sessionUserName"; | ||
| 45 | + public static final String COMPANY_AUTHORITYS = "cmyAuths"; | ||
| 46 | + public static final String STATION_AND_SECTION_COUNT = "/station/updateStationAndSectionCode"; | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * 解除调度指令和班次的外键约束 | ||
| 50 | + */ | ||
| 51 | + public static final String REMOVE_DIRECTIVE_SCH_FK = "update bsth_v_directive_60 set sch=NULL where sch=?"; | ||
| 52 | + | ||
| 53 | + /** | ||
| 54 | + * 批量解除调度指令和班次的外键约束 | ||
| 55 | + */ | ||
| 56 | + public static final String MULTI_REMOVE_DIRECTIVE_SCH_FK = "update bsth_v_directive_60 set sch=NULL where sch in "; | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * 批量解除子任务和班次的外键约束 | ||
| 60 | + */ | ||
| 61 | + public static final String MULTI_REMOVE_CHILDTASK_SCH_FK = "update bsth_c_s_child_task set schedule=NULL where schedule in "; | ||
| 62 | + | ||
| 63 | + public static final String WEAK_CIPHER = "weakCipher"; | ||
| 64 | + | ||
| 65 | + public static final String FILE_AUTH = "/.well-known/pki-validation/fileauth.txt"; | ||
| 66 | +} |
src/main/java/com/bsth/controller/realcontrol/ServiceDataInterface.java
| @@ -345,8 +345,8 @@ public class ServiceDataInterface { | @@ -345,8 +345,8 @@ public class ServiceDataInterface { | ||
| 345 | for (Map.Entry<String, String> m : BasicData.lineCode2NameMap.entrySet()){ | 345 | for (Map.Entry<String, String> m : BasicData.lineCode2NameMap.entrySet()){ |
| 346 | for (Map<String,String> emer : emergencyList){ | 346 | for (Map<String,String> emer : emergencyList){ |
| 347 | for (Map.Entry<String,String> t : emer.entrySet()){ | 347 | for (Map.Entry<String,String> t : emer.entrySet()){ |
| 348 | - if(m.getKey().equals(t.getKey())){ | ||
| 349 | - emergencyListAll.add(emer); // | 348 | + if (m.getKey().equals(t.getKey())) { |
| 349 | + emergencyListAll.add(emer); | ||
| 350 | Line line = lineRepository.findById(Integer.parseInt(t.getKey())).get(); | 350 | Line line = lineRepository.findById(Integer.parseInt(t.getKey())).get(); |
| 351 | line.setName(t.getValue()); | 351 | line.setName(t.getValue()); |
| 352 | Map<String, Object> status = service.update(line); | 352 | Map<String, Object> status = service.update(line); |
src/main/java/com/bsth/controller/schedule/TrafficManageController.java
| 1 | -package com.bsth.controller.schedule; | ||
| 2 | - | ||
| 3 | -import com.bsth.service.TrafficManageService; | ||
| 4 | - | ||
| 5 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 6 | -import org.springframework.web.bind.annotation.RequestMapping; | ||
| 7 | -import org.springframework.web.bind.annotation.RequestMethod; | ||
| 8 | -import org.springframework.web.bind.annotation.RequestParam; | ||
| 9 | -import org.springframework.web.bind.annotation.RestController; | ||
| 10 | - | ||
| 11 | -/** | ||
| 12 | - * | ||
| 13 | - * @author BSTH | ||
| 14 | - * | ||
| 15 | - */ | ||
| 16 | -@RestController | ||
| 17 | -@RequestMapping("trmg") | ||
| 18 | -public class TrafficManageController { | ||
| 19 | - | ||
| 20 | - @Autowired | ||
| 21 | - private TrafficManageService trManageService; | ||
| 22 | - | ||
| 23 | - | ||
| 24 | - @RequestMapping(value = "/setXL", method = RequestMethod.GET) | ||
| 25 | - public String setXL(@RequestParam("ids") String ids) throws Exception { | ||
| 26 | - try { | ||
| 27 | - return trManageService.setXL(ids); | ||
| 28 | - } catch (Exception exp) { | ||
| 29 | - throw new Exception(exp.getCause()); | ||
| 30 | - } | ||
| 31 | - } | ||
| 32 | - | ||
| 33 | - @RequestMapping(value = "/setXLByInUse", method = RequestMethod.GET) | ||
| 34 | - public String setXLByInUse(@RequestParam("inUse") String inUse) throws Exception { | ||
| 35 | - try { | ||
| 36 | - return trManageService.setXLByInUse(inUse); | ||
| 37 | - } catch (Exception exp) { | ||
| 38 | - throw new Exception(exp.getCause()); | ||
| 39 | - } | ||
| 40 | - } | ||
| 41 | - | ||
| 42 | - @RequestMapping(value = "/setCL", method = RequestMethod.GET) | ||
| 43 | - public String setCL() throws Exception { | ||
| 44 | - try { | ||
| 45 | - return trManageService.setCL(); | ||
| 46 | - } catch (Exception exp) { | ||
| 47 | - throw new Exception(exp.getCause()); | ||
| 48 | - } | ||
| 49 | - } | ||
| 50 | - | ||
| 51 | - @RequestMapping(value = "/setSJ", method = RequestMethod.GET) | ||
| 52 | - public String setSJ() throws Exception { | ||
| 53 | - try { | ||
| 54 | - return trManageService.setSJ(); | ||
| 55 | - } catch (Exception exp) { | ||
| 56 | - throw new Exception(exp.getCause()); | ||
| 57 | - } | ||
| 58 | - } | ||
| 59 | - | ||
| 60 | - @RequestMapping(value = "/setLD", method = RequestMethod.GET) | ||
| 61 | - public String setLD() throws Exception { | ||
| 62 | - try { | ||
| 63 | - return trManageService.setLD(); | ||
| 64 | - } catch (Exception exp) { | ||
| 65 | - throw new Exception(exp.getCause()); | ||
| 66 | - } | ||
| 67 | - } | ||
| 68 | - | ||
| 69 | - @RequestMapping(value = "/setLDByDate", method = RequestMethod.GET) | ||
| 70 | - public String setLDByDate(@RequestParam("theDate") String theDate) throws Exception { | ||
| 71 | - try { | ||
| 72 | - return trManageService.setLD(theDate); | ||
| 73 | - } catch (Exception exp) { | ||
| 74 | - throw new Exception(exp.getCause()); | ||
| 75 | - } | ||
| 76 | - } | ||
| 77 | - | ||
| 78 | - @RequestMapping(value = "/setLDFile", method = RequestMethod.GET) | ||
| 79 | - public String setLDFile() throws Exception { | ||
| 80 | - try { | ||
| 81 | - return trManageService.setLDFile(); | ||
| 82 | - } catch (Exception exp) { | ||
| 83 | - throw new Exception(exp.getCause()); | ||
| 84 | - } | ||
| 85 | - } | ||
| 86 | - | ||
| 87 | - @RequestMapping(value = "/setLCYH", method = RequestMethod.GET) | ||
| 88 | - public String setLCYH() throws Exception { | ||
| 89 | - try { | ||
| 90 | - return trManageService.setLCYH(); | ||
| 91 | - } catch (Exception exp) { | ||
| 92 | - throw new Exception(exp.getCause()); | ||
| 93 | - } | ||
| 94 | - } | ||
| 95 | - | ||
| 96 | - @RequestMapping(value = "/setDDRB", method = RequestMethod.GET) | ||
| 97 | - public String setDDRB() throws Exception { | ||
| 98 | - try { | ||
| 99 | - return trManageService.setDDRB(); | ||
| 100 | - } catch (Exception exp) { | ||
| 101 | - throw new Exception(exp.getCause()); | ||
| 102 | - } | ||
| 103 | - } | ||
| 104 | - | ||
| 105 | - @RequestMapping(value = "/setJHBC", method = RequestMethod.GET) | ||
| 106 | - public String setJHBC() throws Exception { | ||
| 107 | - try { | ||
| 108 | - return trManageService.setJHBC(); | ||
| 109 | - } catch (Exception exp) { | ||
| 110 | - throw new Exception(exp.getCause()); | ||
| 111 | - } | ||
| 112 | - } | ||
| 113 | - | ||
| 114 | - @RequestMapping(value = "/setJHBCByDate", method = RequestMethod.GET) | ||
| 115 | - public String setJHBCByDate(@RequestParam("theDate") String theDate) throws Exception { | ||
| 116 | - try { | ||
| 117 | - return trManageService.setJHBC(theDate); | ||
| 118 | - } catch (Exception exp) { | ||
| 119 | - throw new Exception(exp.getCause()); | ||
| 120 | - } | ||
| 121 | - } | ||
| 122 | - | ||
| 123 | - @RequestMapping(value = "/setSKB", method = RequestMethod.GET) | ||
| 124 | - public String setSKB(@RequestParam("ids") String ids) throws Exception { | ||
| 125 | - try { | ||
| 126 | - return trManageService.setSKB(ids); | ||
| 127 | - } catch (Exception exp) { | ||
| 128 | - throw new Exception(exp.getCause()); | ||
| 129 | - } | ||
| 130 | - } | ||
| 131 | - | ||
| 132 | - @RequestMapping(value = "/setXLPC", method = RequestMethod.GET) | ||
| 133 | - public String setXLPC() throws Exception { | ||
| 134 | - try { | ||
| 135 | - return trManageService.setXLPC(); | ||
| 136 | - } catch (Exception exp) { | ||
| 137 | - throw new Exception(exp.getCause()); | ||
| 138 | - } | ||
| 139 | - } | ||
| 140 | - | ||
| 141 | - @RequestMapping(value = "/setCS", method = RequestMethod.GET) | ||
| 142 | - public String setCS() throws Exception { | ||
| 143 | - try { | ||
| 144 | - return trManageService.setCS(); | ||
| 145 | - } catch (Exception exp) { | ||
| 146 | - throw new Exception(exp.getCause()); | ||
| 147 | - } | ||
| 148 | - } | ||
| 149 | - | ||
| 150 | - @RequestMapping(value = "/getDownLoadAllDataFile", method = RequestMethod.GET) | ||
| 151 | - public String getDownLoadAllDataFile() throws Exception { | ||
| 152 | - try { | ||
| 153 | - return trManageService.getDownLoadAllDataFile(); | ||
| 154 | - } catch (Exception exp) { | ||
| 155 | - throw new Exception(exp.getCause()); | ||
| 156 | - } | ||
| 157 | - } | ||
| 158 | - | ||
| 159 | -} | 1 | +package com.bsth.controller.schedule; |
| 2 | + | ||
| 3 | +import com.bsth.service.TrafficManageService; | ||
| 4 | + | ||
| 5 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 6 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 7 | +import org.springframework.web.bind.annotation.RequestMethod; | ||
| 8 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 9 | +import org.springframework.web.bind.annotation.RestController; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * | ||
| 13 | + * @author BSTH | ||
| 14 | + * | ||
| 15 | + */ | ||
| 16 | +@RestController | ||
| 17 | +@RequestMapping("trmg") | ||
| 18 | +public class TrafficManageController { | ||
| 19 | + | ||
| 20 | + @Autowired | ||
| 21 | + private TrafficManageService trManageService; | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + @RequestMapping(value = "/setXL", method = RequestMethod.GET) | ||
| 25 | + public String setXL(@RequestParam("ids") String ids) throws Exception { | ||
| 26 | + try { | ||
| 27 | + return trManageService.setXL(ids); | ||
| 28 | + } catch (Exception exp) { | ||
| 29 | + throw new Exception(exp.getCause()); | ||
| 30 | + } | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + @RequestMapping(value = "/setXLByInUse", method = RequestMethod.GET) | ||
| 34 | + public String setXLByInUse(@RequestParam("inUse") String inUse) throws Exception { | ||
| 35 | + try { | ||
| 36 | + return trManageService.setXLByInUse(inUse); | ||
| 37 | + } catch (Exception exp) { | ||
| 38 | + throw new Exception(exp.getCause()); | ||
| 39 | + } | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + @RequestMapping(value = "/setCL", method = RequestMethod.GET) | ||
| 43 | + public String setCL() throws Exception { | ||
| 44 | + try { | ||
| 45 | + return trManageService.setCL(); | ||
| 46 | + } catch (Exception exp) { | ||
| 47 | + throw new Exception(exp.getCause()); | ||
| 48 | + } | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + @RequestMapping(value = "/setSJ", method = RequestMethod.GET) | ||
| 52 | + public String setSJ() throws Exception { | ||
| 53 | + try { | ||
| 54 | + return trManageService.setSJ(); | ||
| 55 | + } catch (Exception exp) { | ||
| 56 | + throw new Exception(exp.getCause()); | ||
| 57 | + } | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + @RequestMapping(value = "/setLD", method = RequestMethod.GET) | ||
| 61 | + public String setLD() throws Exception { | ||
| 62 | + try { | ||
| 63 | + return trManageService.setLD(); | ||
| 64 | + } catch (Exception exp) { | ||
| 65 | + throw new Exception(exp.getCause()); | ||
| 66 | + } | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + @RequestMapping(value = "/setLDByDate", method = RequestMethod.GET) | ||
| 70 | + public String setLDByDate(@RequestParam("theDate") String theDate) throws Exception { | ||
| 71 | + try { | ||
| 72 | + return trManageService.setLD(theDate); | ||
| 73 | + } catch (Exception exp) { | ||
| 74 | + throw new Exception(exp.getCause()); | ||
| 75 | + } | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + @RequestMapping(value = "/setLDFile", method = RequestMethod.GET) | ||
| 79 | + public String setLDFile() throws Exception { | ||
| 80 | + try { | ||
| 81 | + return trManageService.setLDFile(); | ||
| 82 | + } catch (Exception exp) { | ||
| 83 | + throw new Exception(exp.getCause()); | ||
| 84 | + } | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + @RequestMapping(value = "/setLCYH", method = RequestMethod.GET) | ||
| 88 | + public String setLCYH() throws Exception { | ||
| 89 | + try { | ||
| 90 | + return trManageService.setLCYH(); | ||
| 91 | + } catch (Exception exp) { | ||
| 92 | + throw new Exception(exp.getCause()); | ||
| 93 | + } | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + @RequestMapping(value = "/setDDRB", method = RequestMethod.GET) | ||
| 97 | + public String setDDRB() throws Exception { | ||
| 98 | + try { | ||
| 99 | + return trManageService.setDDRB(); | ||
| 100 | + } catch (Exception exp) { | ||
| 101 | + throw new Exception(exp.getCause()); | ||
| 102 | + } | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + @RequestMapping(value = "/setJHBC", method = RequestMethod.GET) | ||
| 106 | + public String setJHBC() throws Exception { | ||
| 107 | + try { | ||
| 108 | + return trManageService.setJHBC(); | ||
| 109 | + } catch (Exception exp) { | ||
| 110 | + throw new Exception(exp.getCause()); | ||
| 111 | + } | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + @RequestMapping(value = "/setJHBCByDate", method = RequestMethod.GET) | ||
| 115 | + public String setJHBCByDate(@RequestParam("theDate") String theDate) throws Exception { | ||
| 116 | + try { | ||
| 117 | + return trManageService.setJHBC(theDate); | ||
| 118 | + } catch (Exception exp) { | ||
| 119 | + throw new Exception(exp.getCause()); | ||
| 120 | + } | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + @RequestMapping(value = "/setSKB", method = RequestMethod.GET) | ||
| 124 | + public String setSKB(@RequestParam("ids") String ids, @RequestParam("qyrqs") String qyrqs) throws Exception { | ||
| 125 | + try { | ||
| 126 | + return trManageService.setSKB(ids, qyrqs); | ||
| 127 | + } catch (Exception exp) { | ||
| 128 | + throw new Exception(exp.getCause()); | ||
| 129 | + } | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + @RequestMapping(value = "/setXLPC", method = RequestMethod.GET) | ||
| 133 | + public String setXLPC() throws Exception { | ||
| 134 | + try { | ||
| 135 | + return trManageService.setXLPC(); | ||
| 136 | + } catch (Exception exp) { | ||
| 137 | + throw new Exception(exp.getCause()); | ||
| 138 | + } | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + @RequestMapping(value = "/setCS", method = RequestMethod.GET) | ||
| 142 | + public String setCS() throws Exception { | ||
| 143 | + try { | ||
| 144 | + return trManageService.setCS(); | ||
| 145 | + } catch (Exception exp) { | ||
| 146 | + throw new Exception(exp.getCause()); | ||
| 147 | + } | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + @RequestMapping(value = "/getDownLoadAllDataFile", method = RequestMethod.GET) | ||
| 151 | + public String getDownLoadAllDataFile() throws Exception { | ||
| 152 | + try { | ||
| 153 | + return trManageService.getDownLoadAllDataFile(); | ||
| 154 | + } catch (Exception exp) { | ||
| 155 | + throw new Exception(exp.getCause()); | ||
| 156 | + } | ||
| 157 | + } | ||
| 158 | + | ||
| 159 | +} |
src/main/java/com/bsth/controller/sys/UserController.java
| 1 | -package com.bsth.controller.sys; | ||
| 2 | - | ||
| 3 | -import com.bsth.common.Constants; | ||
| 4 | -import com.bsth.common.ResponseCode; | ||
| 5 | -import com.bsth.controller.BaseController; | ||
| 6 | -import com.bsth.controller.sys.dto.CompanyData; | ||
| 7 | -import com.bsth.controller.sys.util.RSAUtils; | ||
| 8 | -import com.bsth.entity.sys.CompanyAuthority; | ||
| 9 | -import com.bsth.entity.sys.SysUser; | ||
| 10 | -import com.bsth.security.util.SecurityUtils; | ||
| 11 | -import com.bsth.service.sys.CompanyAuthorityService; | ||
| 12 | -import com.bsth.service.sys.SysUserService; | ||
| 13 | -import com.google.common.collect.ArrayListMultimap; | ||
| 14 | -import org.apache.commons.lang3.StringUtils; | ||
| 15 | -import org.slf4j.Logger; | ||
| 16 | -import org.slf4j.LoggerFactory; | ||
| 17 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 18 | -import org.springframework.security.authentication.BadCredentialsException; | ||
| 19 | -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | ||
| 20 | -import org.springframework.security.web.authentication.session.SessionAuthenticationException; | ||
| 21 | -import org.springframework.web.bind.annotation.RequestMapping; | ||
| 22 | -import org.springframework.web.bind.annotation.RequestMethod; | ||
| 23 | -import org.springframework.web.bind.annotation.RequestParam; | ||
| 24 | -import org.springframework.web.bind.annotation.RestController; | ||
| 25 | - | ||
| 26 | -import javax.servlet.http.HttpServletRequest; | ||
| 27 | -import javax.servlet.http.HttpSession; | ||
| 28 | -import java.util.*; | ||
| 29 | - | ||
| 30 | -@RestController | ||
| 31 | -@RequestMapping("user") | ||
| 32 | -public class UserController extends BaseController<SysUser, Integer> { | ||
| 33 | - | ||
| 34 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 35 | - | ||
| 36 | - @Autowired | ||
| 37 | - SysUserService sysUserService; | ||
| 38 | - | ||
| 39 | - @Autowired | ||
| 40 | - CompanyAuthorityService companyAuthorityService; | ||
| 41 | - | ||
| 42 | - @RequestMapping(value = "/login/jCryptionKey") | ||
| 43 | - public Map<String, Object> jCryptionKey(HttpServletRequest request) { | ||
| 44 | - //公匙返回页面 | ||
| 45 | - Map<String, Object> rs = new HashMap<>(); | ||
| 46 | - rs.put("publickey", RSAUtils.generateBase64PublicKey()); | ||
| 47 | - return rs; | ||
| 48 | - } | ||
| 49 | - | ||
| 50 | - @RequestMapping(value = "/getCurrentUser") | ||
| 51 | - public SysUser getCurrentUser() { | ||
| 52 | - SysUser user = SecurityUtils.getCurrentUser(); | ||
| 53 | - return user; | ||
| 54 | - } | ||
| 55 | - | ||
| 56 | - //需要验证码的账号 | ||
| 57 | - public static Map<String, Integer> captchaMap = new HashMap<>(); | ||
| 58 | - | ||
| 59 | - @RequestMapping(value = "/login", method = RequestMethod.POST) | ||
| 60 | - public Map<String, Object> login(HttpServletRequest request, @RequestParam String userName, | ||
| 61 | - @RequestParam String password, String captcha) { | ||
| 62 | - | ||
| 63 | - Map<String, Object> rs = new HashMap<>(); | ||
| 64 | - rs.put("status", ResponseCode.ERROR); | ||
| 65 | - try { | ||
| 66 | - HttpSession session = request.getSession(); | ||
| 67 | - rs.put("captcha", session.getAttribute("captcha")); | ||
| 68 | - | ||
| 69 | - if (captchaMap.get(userName) != null && captchaMap.get(userName) >= 3) { | ||
| 70 | - //校验验证码 | ||
| 71 | - String verCode = (String) session | ||
| 72 | - .getAttribute(com.google.code.kaptcha.Constants.KAPTCHA_SESSION_KEY); | ||
| 73 | - | ||
| 74 | - if (StringUtils.isBlank(captcha)) | ||
| 75 | - return put(rs, "msg", "请输入验证码"); | ||
| 76 | - | ||
| 77 | - if (!verCode.equals(captcha)) | ||
| 78 | - return put(rs, "msg", "验证码有误,请刷新后重新输入"); | ||
| 79 | - } | ||
| 80 | - | ||
| 81 | - //解密RSA | ||
| 82 | - try { | ||
| 83 | - userName = RSAUtils.decryptBase64(userName); | ||
| 84 | - password = RSAUtils.decryptBase64(password); | ||
| 85 | - } catch (RuntimeException e) { | ||
| 86 | - return put(rs, "msg", "decrypt RSA fail!可能页面已过期,尝试刷新页面。"); | ||
| 87 | - } | ||
| 88 | - | ||
| 89 | - SysUser user = sysUserService.findByUserName(userName); | ||
| 90 | - if (null == user) | ||
| 91 | - return put(rs, "msg", "不存在的用户"); | ||
| 92 | - | ||
| 93 | - if (!user.isEnabled()) | ||
| 94 | - return put(rs, "msg", "该用户已被锁定,请联系管理员"); | ||
| 95 | - | ||
| 96 | - // 校验密码 | ||
| 97 | - boolean matchStatus = new BCryptPasswordEncoder(4).matches(password, user.getPassword()); | ||
| 98 | - if (!matchStatus) { | ||
| 99 | - rs.put("msg", "密码有误"); | ||
| 100 | - | ||
| 101 | - Integer captchSize = captchaMap.get(userName); | ||
| 102 | - if (null == captchSize) | ||
| 103 | - captchSize = 0; | ||
| 104 | - | ||
| 105 | - captchSize++; | ||
| 106 | - captchaMap.put(userName, captchSize); | ||
| 107 | - return rs; | ||
| 108 | - } | ||
| 109 | - | ||
| 110 | - // 登录 | ||
| 111 | - SecurityUtils.login(user, request); | ||
| 112 | - //session里写入用户名,webSocket连接时标识身份用 | ||
| 113 | - session.setAttribute(Constants.SESSION_USERNAME, user.getUserName()); | ||
| 114 | - | ||
| 115 | - //获取公司权限数据 | ||
| 116 | - List<CompanyAuthority> cmyAuths = companyAuthorityService.findByUser(user); | ||
| 117 | - session.setAttribute(Constants.COMPANY_AUTHORITYS, cmyAuths); | ||
| 118 | - | ||
| 119 | - captchaMap.remove(userName); | ||
| 120 | - rs.put("status", ResponseCode.SUCCESS); | ||
| 121 | - logger.error("用户:" + user.getUserName() + "登录"); | ||
| 122 | - } catch (Exception e) { | ||
| 123 | - logger.error("", e); | ||
| 124 | - rs.put("msg", "服务器出现异常,请联系管理员"); | ||
| 125 | - } | ||
| 126 | - return rs; | ||
| 127 | - } | ||
| 128 | - | ||
| 129 | - @RequestMapping(value = "/change_user", method = RequestMethod.POST) | ||
| 130 | - public Map<String, Object> changeUser(HttpServletRequest request, @RequestParam String userName, | ||
| 131 | - @RequestParam String password) { | ||
| 132 | - | ||
| 133 | - Map<String, Object> rs = new HashMap<>(); | ||
| 134 | - rs.put("status", ResponseCode.ERROR); | ||
| 135 | - try { | ||
| 136 | - HttpSession session = request.getSession(); | ||
| 137 | - | ||
| 138 | - SysUser user = sysUserService.findByUserName(userName); | ||
| 139 | - if (null == user) | ||
| 140 | - return put(rs, "msg", "不存在的用户"); | ||
| 141 | - | ||
| 142 | - if (!user.isEnabled()) | ||
| 143 | - return put(rs, "msg", "该用户已被锁定,请联系管理员"); | ||
| 144 | - | ||
| 145 | - // 校验密码 | ||
| 146 | - boolean matchStatus = new BCryptPasswordEncoder(4).matches(password, user.getPassword()); | ||
| 147 | - if (!matchStatus) | ||
| 148 | - return put(rs, "msg", "密码有误"); | ||
| 149 | - | ||
| 150 | - // 登录 | ||
| 151 | - SecurityUtils.login(user, request); | ||
| 152 | - //session里写入用户名,webSocket连接时标识身份用 | ||
| 153 | - session.setAttribute(Constants.SESSION_USERNAME, user.getUserName()); | ||
| 154 | - | ||
| 155 | - //获取公司权限数据 | ||
| 156 | - List<CompanyAuthority> cmyAuths = companyAuthorityService.findByUser(user); | ||
| 157 | - session.setAttribute(Constants.COMPANY_AUTHORITYS, cmyAuths); | ||
| 158 | - rs.put("status", ResponseCode.SUCCESS); | ||
| 159 | - } catch (Exception e) { | ||
| 160 | - logger.error("", e); | ||
| 161 | - rs.put("msg", "服务器出现异常,请联系管理员"); | ||
| 162 | - } | ||
| 163 | - return rs; | ||
| 164 | - } | ||
| 165 | - | ||
| 166 | - /** | ||
| 167 | - * 返回当前用户的公司权限数据,用于构建页面级联下拉框 | ||
| 168 | - * | ||
| 169 | - * @return | ||
| 170 | - */ | ||
| 171 | - @RequestMapping("companyData") | ||
| 172 | - public List<CompanyData> companyData(HttpServletRequest request) { | ||
| 173 | - List<CompanyData> rs = new ArrayList<>(); | ||
| 174 | - CompanyData companyData; | ||
| 175 | - | ||
| 176 | - ArrayListMultimap<String, CompanyAuthority> map = ArrayListMultimap.create(); | ||
| 177 | - List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) request.getSession().getAttribute(Constants.COMPANY_AUTHORITYS); | ||
| 178 | - | ||
| 179 | - for (CompanyAuthority cAuth : cmyAuths) { | ||
| 180 | - map.put(cAuth.getCompanyCode() + "_" + cAuth.getCompanyName(), cAuth); | ||
| 181 | - } | ||
| 182 | - | ||
| 183 | - Set<String> keys = map.keySet(); | ||
| 184 | - String[] temps; | ||
| 185 | - for (String k : keys) { | ||
| 186 | - temps = k.split("_"); | ||
| 187 | - | ||
| 188 | - companyData = new CompanyData(); | ||
| 189 | - companyData.setCompanyCode(temps[0]); | ||
| 190 | - companyData.setCompanyName(temps[1]); | ||
| 191 | - companyData.setChildren(new ArrayList<CompanyData.ChildrenCompany>()); | ||
| 192 | - | ||
| 193 | - cmyAuths = map.get(k); | ||
| 194 | - for (CompanyAuthority c : cmyAuths) { | ||
| 195 | - companyData.getChildren().add(new CompanyData.ChildrenCompany(c.getSubCompanyCode(), c.getSubCompanyName())); | ||
| 196 | - } | ||
| 197 | - | ||
| 198 | - rs.add(companyData); | ||
| 199 | - } | ||
| 200 | - | ||
| 201 | - return rs; | ||
| 202 | - } | ||
| 203 | - | ||
| 204 | - @RequestMapping(value = "/login/captchaStatus") | ||
| 205 | - public int captchaStatus(String userName) { | ||
| 206 | - Integer size = captchaMap.get(userName); | ||
| 207 | - return size == null ? 0 : size; | ||
| 208 | - } | ||
| 209 | - | ||
| 210 | - public Map<String, Object> put(Map<String, Object> rs, String key, Object val) { | ||
| 211 | - rs.put(key, val); | ||
| 212 | - return rs; | ||
| 213 | - } | ||
| 214 | - | ||
| 215 | - /** | ||
| 216 | - * @Title: loginFailure @Description: TODO(查询登录失败的详细信息) @param @param | ||
| 217 | - * request @return String 返回类型 @throws | ||
| 218 | - */ | ||
| 219 | - @RequestMapping("/loginFailure") | ||
| 220 | - public String loginFailure(HttpServletRequest request) { | ||
| 221 | - String msg = ""; | ||
| 222 | - HttpSession session = request.getSession(); | ||
| 223 | - | ||
| 224 | - Object obj = session.getAttribute("SPRING_SECURITY_LAST_EXCEPTION"); | ||
| 225 | - | ||
| 226 | - if (obj instanceof BadCredentialsException) | ||
| 227 | - msg = "登录失败,用户名或密码错误."; | ||
| 228 | - else if (obj instanceof SessionAuthenticationException) | ||
| 229 | - msg = "登录失败,当前策略不允许重复登录."; | ||
| 230 | - session.removeAttribute("SPRING_SECURITY_LAST_EXCEPTION"); | ||
| 231 | - return msg; | ||
| 232 | - } | ||
| 233 | - | ||
| 234 | - @RequestMapping("/currentUser") | ||
| 235 | - public SysUser currentUser() { | ||
| 236 | - return SecurityUtils.getCurrentUser(); | ||
| 237 | - } | ||
| 238 | - | ||
| 239 | - /** | ||
| 240 | - * @param id 用户ID | ||
| 241 | - * @param enabled 状态 | ||
| 242 | - * @return | ||
| 243 | - * @Title changeEnabled | ||
| 244 | - * @Description: TODO(改变用户状态) | ||
| 245 | - */ | ||
| 246 | - @RequestMapping("/changeEnabled") | ||
| 247 | - public int changeEnabled(@RequestParam int id, @RequestParam int enabled) { | ||
| 248 | - return sysUserService.changeEnabled(id, enabled); | ||
| 249 | - } | ||
| 250 | - | ||
| 251 | - /** | ||
| 252 | - * @param oldPWD 原始密码 | ||
| 253 | - * @param newPWD 新密码 | ||
| 254 | - * @param cnewPWD 确认新密码 | ||
| 255 | - * @return | ||
| 256 | - * @Title changePWD | ||
| 257 | - * @Description: TODO(修改密码) | ||
| 258 | - */ | ||
| 259 | - @RequestMapping(value = "/changePWD", method = RequestMethod.POST) | ||
| 260 | - public String changePWD(@RequestParam String oldPWD, @RequestParam String newPWD, @RequestParam String cnewPWD) { | ||
| 261 | - SysUser sysUser = SecurityUtils.getCurrentUser(); | ||
| 262 | - String msg = ""; | ||
| 263 | - | ||
| 264 | - //解密RSA | ||
| 265 | - try{ | ||
| 266 | - oldPWD = (RSAUtils.decryptBase64(oldPWD)); | ||
| 267 | - newPWD = (RSAUtils.decryptBase64(newPWD)); | ||
| 268 | - cnewPWD = (RSAUtils.decryptBase64(cnewPWD)); | ||
| 269 | - }catch (RuntimeException e) { | ||
| 270 | - return "网络延迟,解密失败,请重新添加!"; | ||
| 271 | - } | ||
| 272 | - if (new BCryptPasswordEncoder(4).matches(oldPWD, sysUser.getPassword())) { | ||
| 273 | - if (oldPWD.equals(newPWD)) { | ||
| 274 | - msg = "新密码不能跟原始密码一样!"; | ||
| 275 | - } else { | ||
| 276 | - if (newPWD.equals(cnewPWD)) { | ||
| 277 | - sysUserService.changePWD(sysUser.getId(), newPWD); | ||
| 278 | - msg = "修改成功!"; | ||
| 279 | - } else { | ||
| 280 | - msg = "新密码两次输入不一致!"; | ||
| 281 | - } | ||
| 282 | - } | ||
| 283 | - } else { | ||
| 284 | - msg = "原始密码错误!"; | ||
| 285 | - } | ||
| 286 | - return msg; | ||
| 287 | - } | ||
| 288 | - | ||
| 289 | - @RequestMapping(value = "/register", method = RequestMethod.POST) | ||
| 290 | - public Map<String, Object> register(SysUser u) { | ||
| 291 | - return sysUserService.register(u); | ||
| 292 | - } | ||
| 293 | - | ||
| 294 | - // 查询用户下所有下级角色 | ||
| 295 | - @RequestMapping(value = "/all_distinct") | ||
| 296 | - public List<SysUser> findAll_distinct() { | ||
| 297 | - return sysUserService.findAll_distinct(); | ||
| 298 | - } | ||
| 299 | - | ||
| 300 | - // 重置密码 | ||
| 301 | - @RequestMapping(value = "/resetPassword", method = RequestMethod.POST) | ||
| 302 | - public Map<String, Object> resetPassword(@RequestParam Integer id) { | ||
| 303 | - return sysUserService.resetPassword(id); | ||
| 304 | - } | ||
| 305 | - | ||
| 306 | -} | 1 | +package com.bsth.controller.sys; |
| 2 | + | ||
| 3 | +import com.bsth.common.Constants; | ||
| 4 | +import com.bsth.common.ResponseCode; | ||
| 5 | +import com.bsth.controller.BaseController; | ||
| 6 | +import com.bsth.controller.sys.dto.CompanyData; | ||
| 7 | +import com.bsth.controller.sys.util.RSAUtils; | ||
| 8 | +import com.bsth.email.entity.EmailBean; | ||
| 9 | +import com.bsth.entity.sys.CompanyAuthority; | ||
| 10 | +import com.bsth.entity.sys.Role; | ||
| 11 | +import com.bsth.entity.sys.SysUser; | ||
| 12 | +import com.bsth.security.util.SecurityUtils; | ||
| 13 | +import com.bsth.service.sys.CompanyAuthorityService; | ||
| 14 | +import com.bsth.service.sys.SysUserService; | ||
| 15 | +import com.bsth.service.sys.impl.PwdGenerator; | ||
| 16 | +import com.bsth.util.IpUtils; | ||
| 17 | +import com.google.common.collect.ArrayListMultimap; | ||
| 18 | +import org.apache.commons.lang3.StringUtils; | ||
| 19 | +import org.slf4j.Logger; | ||
| 20 | +import org.slf4j.LoggerFactory; | ||
| 21 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 22 | +import org.springframework.security.authentication.BadCredentialsException; | ||
| 23 | +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | ||
| 24 | +import org.springframework.security.web.authentication.session.SessionAuthenticationException; | ||
| 25 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 26 | +import org.springframework.web.bind.annotation.RequestMethod; | ||
| 27 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 28 | +import org.springframework.web.bind.annotation.RestController; | ||
| 29 | + | ||
| 30 | +import javax.servlet.http.HttpServletRequest; | ||
| 31 | +import javax.servlet.http.HttpSession; | ||
| 32 | +import java.util.*; | ||
| 33 | +import java.util.regex.Matcher; | ||
| 34 | +import java.util.regex.Pattern; | ||
| 35 | + | ||
| 36 | +@RestController | ||
| 37 | +@RequestMapping("user") | ||
| 38 | +public class UserController extends BaseController<SysUser, Integer> { | ||
| 39 | + | ||
| 40 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 41 | + | ||
| 42 | + @Autowired | ||
| 43 | + SysUserService sysUserService; | ||
| 44 | + | ||
| 45 | + @Autowired | ||
| 46 | + CompanyAuthorityService companyAuthorityService; | ||
| 47 | + | ||
| 48 | + private Pattern pattern = Pattern.compile("^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*?[#?!@$%^&*-.]).{8,16}$"); | ||
| 49 | + | ||
| 50 | + @RequestMapping(value = "/login/jCryptionKey") | ||
| 51 | + public Map<String, Object> jCryptionKey(HttpServletRequest request) { | ||
| 52 | + //公匙返回页面 | ||
| 53 | + Map<String, Object> rs = new HashMap<>(); | ||
| 54 | + rs.put("publickey", RSAUtils.generateBase64PublicKey()); | ||
| 55 | + return rs; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + @RequestMapping(value = "/getCurrentUser") | ||
| 59 | + public SysUser getCurrentUser() { | ||
| 60 | + SysUser user = SecurityUtils.getCurrentUser(); | ||
| 61 | + return user; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + //需要验证码的账号 | ||
| 65 | + public static Map<String, Integer> USER_ERRTIMES = new HashMap<>(); | ||
| 66 | + public static Map<String, Long> USER_LOCKTIME = new HashMap<>(); | ||
| 67 | + | ||
| 68 | + @RequestMapping(value = "/login", method = RequestMethod.POST) | ||
| 69 | + public Map<String, Object> login(HttpServletRequest request, @RequestParam String userName, | ||
| 70 | + @RequestParam String password, String captcha) { | ||
| 71 | + | ||
| 72 | + Map<String, Object> rs = new HashMap<>(); | ||
| 73 | + rs.put("status", ResponseCode.ERROR); | ||
| 74 | + try { | ||
| 75 | + HttpSession session = request.getSession(); | ||
| 76 | + rs.put("captcha", session.getAttribute("captcha")); | ||
| 77 | + | ||
| 78 | + //解密RSA | ||
| 79 | + try { | ||
| 80 | + userName = RSAUtils.decryptBase64(userName); | ||
| 81 | + password = RSAUtils.decryptBase64(password); | ||
| 82 | + } catch (RuntimeException e) { | ||
| 83 | + return put(rs, "msg", "decrypt RSA fail!可能页面已过期,尝试刷新页面。"); | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + SysUser user = sysUserService.findByUserName(userName); | ||
| 87 | + | ||
| 88 | + // 校验用户状态 | ||
| 89 | + if (!user.isEnabled()) { | ||
| 90 | + return put(rs, "msg", "该用户已被锁定,请联系管理员"); | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + // 校验临时状态 | ||
| 94 | + if (USER_LOCKTIME.get(userName) != null && USER_LOCKTIME.get(userName) >= System.currentTimeMillis()) { | ||
| 95 | + return put(rs, "msg", "您的账户因密码错误次数过多,处于锁定状态中"); | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + // 校验验证码 | ||
| 99 | + if (USER_ERRTIMES.get(userName) != null && USER_ERRTIMES.get(userName) > 1) { | ||
| 100 | + String verCode = (String) session.getAttribute(com.google.code.kaptcha.Constants.KAPTCHA_SESSION_KEY); | ||
| 101 | + if (StringUtils.isBlank(captcha)) { | ||
| 102 | + return put(rs, "msg", "请输入验证码"); | ||
| 103 | + } | ||
| 104 | + if (!verCode.equals(captcha)) { | ||
| 105 | + return put(rs, "msg", "验证码有误,请刷新后重新输入"); | ||
| 106 | + } | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + // 校验密码 | ||
| 110 | + boolean matchStatus = new BCryptPasswordEncoder(4).matches(password, user.getPassword()); | ||
| 111 | + if (null == user || !matchStatus) { | ||
| 112 | + rs.put("msg", "密码有误"); | ||
| 113 | + | ||
| 114 | + Integer errTimes = USER_ERRTIMES.get(userName); | ||
| 115 | + if (null == errTimes) { | ||
| 116 | + errTimes = 0; | ||
| 117 | + } | ||
| 118 | + USER_ERRTIMES.put(userName, ++errTimes); | ||
| 119 | + if (errTimes > 3) { | ||
| 120 | + USER_LOCKTIME.put(userName, System.currentTimeMillis() + 600000); | ||
| 121 | + USER_ERRTIMES.put(userName, 0); | ||
| 122 | + put(rs, "msg", "密码错误4次,账户将被锁定10分钟"); | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + return rs; | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + // 弱密码检查 | ||
| 129 | + Matcher matcher = pattern.matcher(password); | ||
| 130 | + if (!matcher.matches()) { | ||
| 131 | + session.setAttribute(Constants.WEAK_CIPHER, 1); | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + // 登录 | ||
| 135 | + SecurityUtils.login(user, request); | ||
| 136 | + sysUserService.recordLoginDate(userName); | ||
| 137 | + //session里写入用户名,webSocket连接时标识身份用 | ||
| 138 | + session.setAttribute(Constants.SESSION_USERNAME, user.getUserName()); | ||
| 139 | + | ||
| 140 | + //获取公司权限数据 | ||
| 141 | + List<CompanyAuthority> cmyAuths = companyAuthorityService.findByUser(user); | ||
| 142 | + session.setAttribute(Constants.COMPANY_AUTHORITYS, cmyAuths); | ||
| 143 | + | ||
| 144 | + USER_ERRTIMES.remove(userName); | ||
| 145 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 146 | + logger.error("用户:" + user.getUserName() + "登录"); | ||
| 147 | + } catch (Exception e) { | ||
| 148 | + logger.error("", e); | ||
| 149 | + rs.put("msg", "服务器出现异常,请联系管理员"); | ||
| 150 | + } | ||
| 151 | + return rs; | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + @RequestMapping(value = "/change_user", method = RequestMethod.POST) | ||
| 155 | + public Map<String, Object> changeUser(HttpServletRequest request, @RequestParam String userName, | ||
| 156 | + @RequestParam String password) { | ||
| 157 | + | ||
| 158 | + Map<String, Object> rs = new HashMap<>(); | ||
| 159 | + rs.put("status", ResponseCode.ERROR); | ||
| 160 | + try { | ||
| 161 | + HttpSession session = request.getSession(); | ||
| 162 | + | ||
| 163 | + SysUser user = sysUserService.findByUserName(userName); | ||
| 164 | + if (null == user) | ||
| 165 | + return put(rs, "msg", "不存在的用户"); | ||
| 166 | + | ||
| 167 | + if (!user.isEnabled()) | ||
| 168 | + return put(rs, "msg", "该用户已被锁定,请联系管理员"); | ||
| 169 | + | ||
| 170 | + // 校验密码 | ||
| 171 | + boolean matchStatus = new BCryptPasswordEncoder(4).matches(password, user.getPassword()); | ||
| 172 | + if (!matchStatus) | ||
| 173 | + return put(rs, "msg", "密码有误"); | ||
| 174 | + | ||
| 175 | + // 登录 | ||
| 176 | + SecurityUtils.login(user, request); | ||
| 177 | + //session里写入用户名,webSocket连接时标识身份用 | ||
| 178 | + session.setAttribute(Constants.SESSION_USERNAME, user.getUserName()); | ||
| 179 | + | ||
| 180 | + //获取公司权限数据 | ||
| 181 | + List<CompanyAuthority> cmyAuths = companyAuthorityService.findByUser(user); | ||
| 182 | + session.setAttribute(Constants.COMPANY_AUTHORITYS, cmyAuths); | ||
| 183 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 184 | + } catch (Exception e) { | ||
| 185 | + logger.error("", e); | ||
| 186 | + rs.put("msg", "服务器出现异常,请联系管理员"); | ||
| 187 | + } | ||
| 188 | + return rs; | ||
| 189 | + } | ||
| 190 | + | ||
| 191 | + /** | ||
| 192 | + * 返回当前用户的公司权限数据,用于构建页面级联下拉框 | ||
| 193 | + * | ||
| 194 | + * @return | ||
| 195 | + */ | ||
| 196 | + @RequestMapping("companyData") | ||
| 197 | + public List<CompanyData> companyData(HttpServletRequest request) { | ||
| 198 | + List<CompanyData> rs = new ArrayList<>(); | ||
| 199 | + CompanyData companyData; | ||
| 200 | + | ||
| 201 | + ArrayListMultimap<String, CompanyAuthority> map = ArrayListMultimap.create(); | ||
| 202 | + List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) request.getSession().getAttribute(Constants.COMPANY_AUTHORITYS); | ||
| 203 | + | ||
| 204 | + for (CompanyAuthority cAuth : cmyAuths) { | ||
| 205 | + map.put(cAuth.getCompanyCode() + "_" + cAuth.getCompanyName(), cAuth); | ||
| 206 | + } | ||
| 207 | + | ||
| 208 | + Set<String> keys = map.keySet(); | ||
| 209 | + String[] temps; | ||
| 210 | + for (String k : keys) { | ||
| 211 | + temps = k.split("_"); | ||
| 212 | + | ||
| 213 | + companyData = new CompanyData(); | ||
| 214 | + companyData.setCompanyCode(temps[0]); | ||
| 215 | + companyData.setCompanyName(temps[1]); | ||
| 216 | + companyData.setChildren(new ArrayList<CompanyData.ChildrenCompany>()); | ||
| 217 | + | ||
| 218 | + cmyAuths = map.get(k); | ||
| 219 | + for (CompanyAuthority c : cmyAuths) { | ||
| 220 | + companyData.getChildren().add(new CompanyData.ChildrenCompany(c.getSubCompanyCode(), c.getSubCompanyName())); | ||
| 221 | + } | ||
| 222 | + | ||
| 223 | + rs.add(companyData); | ||
| 224 | + } | ||
| 225 | + | ||
| 226 | + return rs; | ||
| 227 | + } | ||
| 228 | + | ||
| 229 | + @RequestMapping(value = "/login/captchaStatus") | ||
| 230 | + public int captchaStatus(String userName) { | ||
| 231 | + Integer size = USER_ERRTIMES.get(userName); | ||
| 232 | + return size == null ? 0 : size; | ||
| 233 | + } | ||
| 234 | + | ||
| 235 | + public Map<String, Object> put(Map<String, Object> rs, String key, Object val) { | ||
| 236 | + rs.put(key, val); | ||
| 237 | + return rs; | ||
| 238 | + } | ||
| 239 | + | ||
| 240 | + /** | ||
| 241 | + * @Title: loginFailure @Description: TODO(查询登录失败的详细信息) @param @param | ||
| 242 | + * request @return String 返回类型 @throws | ||
| 243 | + */ | ||
| 244 | + @RequestMapping("/loginFailure") | ||
| 245 | + public String loginFailure(HttpServletRequest request) { | ||
| 246 | + String msg = ""; | ||
| 247 | + HttpSession session = request.getSession(); | ||
| 248 | + | ||
| 249 | + Object obj = session.getAttribute("SPRING_SECURITY_LAST_EXCEPTION"); | ||
| 250 | + | ||
| 251 | + if (obj instanceof BadCredentialsException) | ||
| 252 | + msg = "登录失败,用户名或密码错误."; | ||
| 253 | + else if (obj instanceof SessionAuthenticationException) | ||
| 254 | + msg = "登录失败,当前策略不允许重复登录."; | ||
| 255 | + session.removeAttribute("SPRING_SECURITY_LAST_EXCEPTION"); | ||
| 256 | + return msg; | ||
| 257 | + } | ||
| 258 | + | ||
| 259 | + @RequestMapping("/currentUser") | ||
| 260 | + public SysUser currentUser() { | ||
| 261 | + return SecurityUtils.getCurrentUser(); | ||
| 262 | + } | ||
| 263 | + | ||
| 264 | + /** | ||
| 265 | + * @param id 用户ID | ||
| 266 | + * @param enabled 状态 | ||
| 267 | + * @return | ||
| 268 | + * @Title changeEnabled | ||
| 269 | + * @Description: TODO(改变用户状态) | ||
| 270 | + */ | ||
| 271 | + @RequestMapping("/changeEnabled") | ||
| 272 | + public int changeEnabled(@RequestParam int id, @RequestParam int enabled) { | ||
| 273 | + return sysUserService.changeEnabled(id, enabled); | ||
| 274 | + } | ||
| 275 | + | ||
| 276 | + /** | ||
| 277 | + * @param oldPWD 原始密码 | ||
| 278 | + * @param newPWD 新密码 | ||
| 279 | + * @param cnewPWD 确认新密码 | ||
| 280 | + * @return | ||
| 281 | + * @Title changePWD | ||
| 282 | + * @Description: TODO(修改密码) | ||
| 283 | + */ | ||
| 284 | + @RequestMapping(value = "/changePWD", method = RequestMethod.POST) | ||
| 285 | + public String changePWD(@RequestParam String oldPWD, @RequestParam String newPWD, @RequestParam String cnewPWD, HttpServletRequest request) { | ||
| 286 | + SysUser sysUser = SecurityUtils.getCurrentUser(); | ||
| 287 | + String msg = ""; | ||
| 288 | + | ||
| 289 | + //解密RSA | ||
| 290 | + try{ | ||
| 291 | + oldPWD = (RSAUtils.decryptBase64(oldPWD)); | ||
| 292 | + newPWD = (RSAUtils.decryptBase64(newPWD)); | ||
| 293 | + cnewPWD = (RSAUtils.decryptBase64(cnewPWD)); | ||
| 294 | + }catch (RuntimeException e) { | ||
| 295 | + return "网络延迟,解密失败,请重新添加!"; | ||
| 296 | + } | ||
| 297 | + if (new BCryptPasswordEncoder(4).matches(oldPWD, sysUser.getPassword())) { | ||
| 298 | + if (oldPWD.equals(newPWD)) { | ||
| 299 | + msg = "新密码不能跟原始密码一样!"; | ||
| 300 | + } else { | ||
| 301 | + if (newPWD.equals(cnewPWD)) { | ||
| 302 | + sysUserService.changePWD(sysUser.getId(), newPWD); | ||
| 303 | + request.getSession().setAttribute(Constants.WEAK_CIPHER, 0); | ||
| 304 | + msg = "修改成功!"; | ||
| 305 | + } else { | ||
| 306 | + msg = "新密码两次输入不一致!"; | ||
| 307 | + } | ||
| 308 | + } | ||
| 309 | + } else { | ||
| 310 | + msg = "原始密码错误!"; | ||
| 311 | + } | ||
| 312 | + return msg; | ||
| 313 | + } | ||
| 314 | + | ||
| 315 | + @RequestMapping(value = "/register", method = RequestMethod.POST) | ||
| 316 | + public Map<String, Object> register(SysUser u) { | ||
| 317 | + return sysUserService.register(u); | ||
| 318 | + } | ||
| 319 | + | ||
| 320 | + // 查询用户下所有下级角色 | ||
| 321 | + @RequestMapping(value = "/all_distinct") | ||
| 322 | + public List<SysUser> findAll_distinct() { | ||
| 323 | + return sysUserService.findAll_distinct(); | ||
| 324 | + } | ||
| 325 | + | ||
| 326 | + // 重置密码 | ||
| 327 | + @RequestMapping(value = "/resetPassword", method = RequestMethod.POST) | ||
| 328 | + public Map<String, Object> resetPassword(@RequestParam Integer id) { | ||
| 329 | + return sysUserService.resetPassword(id); | ||
| 330 | + } | ||
| 331 | + | ||
| 332 | + /** | ||
| 333 | + * 解除临时锁定 | ||
| 334 | + * @param userName | ||
| 335 | + * @return | ||
| 336 | + */ | ||
| 337 | + @RequestMapping(value = "/unlock", method = RequestMethod.POST) | ||
| 338 | + public Map<String, Object> unlock(@RequestParam String userName) { | ||
| 339 | + Map<String, Object> result = new HashMap<>(); | ||
| 340 | + // 获取当前用户 | ||
| 341 | + SysUser user = SecurityUtils.getCurrentUser(); | ||
| 342 | + Iterator<Role> itRole = user.getRoles().iterator(); | ||
| 343 | + Role ro = new Role(); | ||
| 344 | + boolean isSuper = false; | ||
| 345 | + while (itRole.hasNext()) {//判断是否有下一个 | ||
| 346 | + ro = itRole.next(); | ||
| 347 | + if (ro.getLevel() == 1) { | ||
| 348 | + isSuper = true; | ||
| 349 | + } | ||
| 350 | + } | ||
| 351 | + if (isSuper) { | ||
| 352 | + USER_LOCKTIME.remove(userName); | ||
| 353 | + USER_ERRTIMES.remove(userName); | ||
| 354 | + result.put("status", ResponseCode.SUCCESS); | ||
| 355 | + result.put("msg", "用户解锁成功!"); | ||
| 356 | + } else { | ||
| 357 | + result.put("status", ResponseCode.ERROR); | ||
| 358 | + result.put("msg", "您不是管理员无用户解锁权限"); | ||
| 359 | + } | ||
| 360 | + | ||
| 361 | + return result; | ||
| 362 | + } | ||
| 363 | + | ||
| 364 | + /** | ||
| 365 | + * 解除临时锁定 | ||
| 366 | + * @param request | ||
| 367 | + * @return | ||
| 368 | + */ | ||
| 369 | + @RequestMapping(value = "/isWeakCipher", method = RequestMethod.POST) | ||
| 370 | + public Map<String, Object> isWeakCipher(HttpServletRequest request) { | ||
| 371 | + Map<String, Object> result = new HashMap<>(); | ||
| 372 | + result.put("status", ResponseCode.SUCCESS); | ||
| 373 | + result.put("data", request.getSession().getAttribute(Constants.WEAK_CIPHER)); | ||
| 374 | + | ||
| 375 | + return result; | ||
| 376 | + } | ||
| 377 | + | ||
| 378 | +} |
src/main/java/com/bsth/entity/sys/SysUser.java
| 1 | package com.bsth.entity.sys; | 1 | package com.bsth.entity.sys; |
| 2 | 2 | ||
| 3 | +import com.fasterxml.jackson.annotation.JsonIgnore; | ||
| 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | 4 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
| 4 | 5 | ||
| 5 | import javax.persistence.*; | 6 | import javax.persistence.*; |
| @@ -25,13 +26,16 @@ public class SysUser implements Serializable { | @@ -25,13 +26,16 @@ public class SysUser implements Serializable { | ||
| 25 | private String userName; | 26 | private String userName; |
| 26 | 27 | ||
| 27 | private String name; | 28 | private String name; |
| 28 | - | 29 | + |
| 30 | + @JsonIgnore | ||
| 29 | private String password; | 31 | private String password; |
| 30 | 32 | ||
| 31 | @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") | 33 | @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") |
| 32 | private Date createDate; | 34 | private Date createDate; |
| 35 | + | ||
| 36 | + @Column(name = "update_date", columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP") | ||
| 37 | + private Date updateDate; | ||
| 33 | 38 | ||
| 34 | - @Column(name = "last_loginDate", columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP") | ||
| 35 | private Date lastLoginDate; | 39 | private Date lastLoginDate; |
| 36 | 40 | ||
| 37 | private String agencies; | 41 | private String agencies; |
| @@ -74,6 +78,14 @@ public class SysUser implements Serializable { | @@ -74,6 +78,14 @@ public class SysUser implements Serializable { | ||
| 74 | this.createDate = createDate; | 78 | this.createDate = createDate; |
| 75 | } | 79 | } |
| 76 | 80 | ||
| 81 | + public Date getUpdateDate() { | ||
| 82 | + return updateDate; | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + public void setUpdateDate(Date updateDate) { | ||
| 86 | + this.updateDate = updateDate; | ||
| 87 | + } | ||
| 88 | + | ||
| 77 | public Date getLastLoginDate() { | 89 | public Date getLastLoginDate() { |
| 78 | return lastLoginDate; | 90 | return lastLoginDate; |
| 79 | } | 91 | } |
src/main/java/com/bsth/filter/BaseFilter.java
| 1 | -package com.bsth.filter; | ||
| 2 | - | ||
| 3 | -import com.bsth.common.Constants; | ||
| 4 | -import org.springframework.util.AntPathMatcher; | ||
| 5 | -import org.springframework.util.PathMatcher; | ||
| 6 | - | ||
| 7 | -import javax.servlet.*; | ||
| 8 | -import javax.servlet.http.HttpServletRequest; | ||
| 9 | -import javax.servlet.http.HttpServletResponse; | ||
| 10 | -import java.io.IOException; | ||
| 11 | - | ||
| 12 | -public abstract class BaseFilter implements Filter { | ||
| 13 | - | ||
| 14 | - private final PathMatcher pathMatcher = new AntPathMatcher(); | ||
| 15 | - | ||
| 16 | - /** | ||
| 17 | - * 白名单 | ||
| 18 | - */ | ||
| 19 | - private String[] whiteListURLs = { Constants.LOGIN_PAGE,Constants.CAPTCHA, Constants.SERVICE_INTERFACE, | ||
| 20 | - Constants.ASSETS_URL, Constants.FAVICON_URL, Constants.METRONIC_URL, Constants.LOGIN, Constants.LOGIN_FAILURE, Constants.UPSTREAM_URL, Constants.XD_CHILD_PAGES, Constants.XD_REAL_GPS, Constants.UP_RFID_URL, Constants.STATION_AND_SECTION_COUNT, Constants.ACTUATOR_MANAGEMENT_HEALTH, | ||
| 21 | - Constants.VEHICLE_DATA_SYNC_URL }; | ||
| 22 | - | ||
| 23 | - @Override | ||
| 24 | - public void destroy() { | ||
| 25 | - | ||
| 26 | - } | ||
| 27 | - | ||
| 28 | - @Override | ||
| 29 | - public void doFilter(ServletRequest request, ServletResponse response, | ||
| 30 | - FilterChain chain) throws IOException, ServletException { | ||
| 31 | - | ||
| 32 | - HttpServletRequest httpRequest = (HttpServletRequest) request; | ||
| 33 | - HttpServletResponse httpResponse = (HttpServletResponse) response; | ||
| 34 | - | ||
| 35 | - String currentURL = httpRequest.getServletPath(); | ||
| 36 | - | ||
| 37 | - if (isWhiteURL(currentURL)) { | ||
| 38 | - chain.doFilter(request, response); | ||
| 39 | - return; | ||
| 40 | - } | ||
| 41 | - | ||
| 42 | - doFilter(httpRequest, httpResponse, chain); | ||
| 43 | - return; | ||
| 44 | - } | ||
| 45 | - | ||
| 46 | - public void doFilter(HttpServletRequest request, | ||
| 47 | - HttpServletResponse response, FilterChain chain) | ||
| 48 | - throws IOException, ServletException { | ||
| 49 | - chain.doFilter(request, response); | ||
| 50 | - } | ||
| 51 | - | ||
| 52 | - @Override | ||
| 53 | - public void init(FilterConfig arg0) throws ServletException { | ||
| 54 | - | ||
| 55 | - } | ||
| 56 | - | ||
| 57 | - private boolean isWhiteURL(String currentURL) { | ||
| 58 | - for (String whiteURL : whiteListURLs) { | ||
| 59 | - if (pathMatcher.match(whiteURL, currentURL)) { | ||
| 60 | - return true; | ||
| 61 | - } | ||
| 62 | - } | ||
| 63 | - return false; | ||
| 64 | - } | ||
| 65 | -} | 1 | +package com.bsth.filter; |
| 2 | + | ||
| 3 | +import com.bsth.common.Constants; | ||
| 4 | +import org.springframework.util.AntPathMatcher; | ||
| 5 | +import org.springframework.util.PathMatcher; | ||
| 6 | + | ||
| 7 | +import javax.servlet.*; | ||
| 8 | +import javax.servlet.http.HttpServletRequest; | ||
| 9 | +import javax.servlet.http.HttpServletResponse; | ||
| 10 | +import java.io.IOException; | ||
| 11 | + | ||
| 12 | +public abstract class BaseFilter implements Filter { | ||
| 13 | + | ||
| 14 | + private final PathMatcher pathMatcher = new AntPathMatcher(); | ||
| 15 | + | ||
| 16 | + /** | ||
| 17 | + * 白名单 | ||
| 18 | + */ | ||
| 19 | + private String[] whiteListURLs = { Constants.LOGIN_PAGE,Constants.CAPTCHA, Constants.SERVICE_INTERFACE, | ||
| 20 | + Constants.ASSETS_URL, Constants.FAVICON_URL, Constants.METRONIC_URL, Constants.LOGIN, Constants.LOGIN_FAILURE, | ||
| 21 | + Constants.UPSTREAM_URL, Constants.XD_CHILD_PAGES, Constants.XD_REAL_GPS, Constants.UP_RFID_URL, | ||
| 22 | + Constants.STATION_AND_SECTION_COUNT, Constants.ACTUATOR_MANAGEMENT_HEALTH, Constants.VEHICLE_DATA_SYNC_URL, | ||
| 23 | + Constants.FILE_AUTH}; | ||
| 24 | + | ||
| 25 | + @Override | ||
| 26 | + public void destroy() { | ||
| 27 | + | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + @Override | ||
| 31 | + public void doFilter(ServletRequest request, ServletResponse response, | ||
| 32 | + FilterChain chain) throws IOException, ServletException { | ||
| 33 | + | ||
| 34 | + HttpServletRequest httpRequest = (HttpServletRequest) request; | ||
| 35 | + HttpServletResponse httpResponse = (HttpServletResponse) response; | ||
| 36 | + | ||
| 37 | + String currentURL = httpRequest.getServletPath(); | ||
| 38 | + | ||
| 39 | + if (isWhiteURL(currentURL)) { | ||
| 40 | + chain.doFilter(request, response); | ||
| 41 | + return; | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + doFilter(httpRequest, httpResponse, chain); | ||
| 45 | + return; | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + public void doFilter(HttpServletRequest request, | ||
| 49 | + HttpServletResponse response, FilterChain chain) | ||
| 50 | + throws IOException, ServletException { | ||
| 51 | + chain.doFilter(request, response); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + @Override | ||
| 55 | + public void init(FilterConfig arg0) throws ServletException { | ||
| 56 | + | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + private boolean isWhiteURL(String currentURL) { | ||
| 60 | + for (String whiteURL : whiteListURLs) { | ||
| 61 | + if (pathMatcher.match(whiteURL, currentURL)) { | ||
| 62 | + return true; | ||
| 63 | + } | ||
| 64 | + } | ||
| 65 | + return false; | ||
| 66 | + } | ||
| 67 | +} |
src/main/java/com/bsth/repository/sys/SysUserRepository.java
| 1 | -package com.bsth.repository.sys; | ||
| 2 | - | ||
| 3 | -import com.bsth.entity.sys.SysUser; | ||
| 4 | -import com.bsth.repository.BaseRepository; | ||
| 5 | -import org.springframework.data.jpa.repository.EntityGraph; | ||
| 6 | -import org.springframework.data.jpa.repository.Modifying; | ||
| 7 | -import org.springframework.data.jpa.repository.Query; | ||
| 8 | -import org.springframework.stereotype.Repository; | ||
| 9 | -import org.springframework.transaction.annotation.Transactional; | ||
| 10 | - | ||
| 11 | -import java.util.List; | ||
| 12 | - | ||
| 13 | -@Repository | ||
| 14 | -public interface SysUserRepository extends BaseRepository<SysUser, Integer>{ | ||
| 15 | - | ||
| 16 | - SysUser findByUserName(String userName); | ||
| 17 | - | ||
| 18 | - @Transactional | ||
| 19 | - @Modifying | ||
| 20 | - @Query(value="update bsth_c_sys_user set enabled=?2 where id=?1",nativeQuery=true) | ||
| 21 | - int changeEnabled(int id,int enabled); | ||
| 22 | - | ||
| 23 | - @Transactional | ||
| 24 | - @Modifying | ||
| 25 | - @Query(value="update bsth_c_sys_user set password=?2 where id=?1",nativeQuery=true) | ||
| 26 | - int changePWD(int id,String newPWD); | ||
| 27 | - | ||
| 28 | - @EntityGraph(value = "sysUser_role", type = EntityGraph.EntityGraphType.FETCH) | ||
| 29 | - @Query(value = "select DISTINCT u from SysUser u") | ||
| 30 | - List<SysUser> findAll_distinct(); | ||
| 31 | -} | 1 | +package com.bsth.repository.sys; |
| 2 | + | ||
| 3 | +import com.bsth.entity.sys.SysUser; | ||
| 4 | +import com.bsth.repository.BaseRepository; | ||
| 5 | +import org.springframework.data.jpa.repository.EntityGraph; | ||
| 6 | +import org.springframework.data.jpa.repository.Modifying; | ||
| 7 | +import org.springframework.data.jpa.repository.Query; | ||
| 8 | +import org.springframework.stereotype.Repository; | ||
| 9 | +import org.springframework.transaction.annotation.Transactional; | ||
| 10 | + | ||
| 11 | +import java.util.List; | ||
| 12 | + | ||
| 13 | +@Repository | ||
| 14 | +public interface SysUserRepository extends BaseRepository<SysUser, Integer>{ | ||
| 15 | + | ||
| 16 | + SysUser findByUserName(String userName); | ||
| 17 | + | ||
| 18 | + @Transactional | ||
| 19 | + @Modifying | ||
| 20 | + @Query(value="update bsth_c_sys_user set enabled=?2 where id=?1",nativeQuery=true) | ||
| 21 | + int changeEnabled(int id,int enabled); | ||
| 22 | + | ||
| 23 | + @Transactional | ||
| 24 | + @Modifying | ||
| 25 | + @Query(value="update bsth_c_sys_user set password=?2 where id=?1",nativeQuery=true) | ||
| 26 | + int changePWD(int id,String newPWD); | ||
| 27 | + | ||
| 28 | + @EntityGraph(value = "sysUser_role", type = EntityGraph.EntityGraphType.FETCH) | ||
| 29 | + @Query(value = "select DISTINCT u from SysUser u") | ||
| 30 | + List<SysUser> findAll_distinct(); | ||
| 31 | + | ||
| 32 | + @Modifying | ||
| 33 | + @Query(value="update bsth_c_sys_user set last_login_date=now() where user_name=?1",nativeQuery=true) | ||
| 34 | + void recordLoginDate(String userName); | ||
| 35 | +} |
src/main/java/com/bsth/security/WebSecurityConfig.java
| @@ -38,7 +38,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { | @@ -38,7 +38,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { | ||
| 38 | public void configure(WebSecurity web) throws Exception { | 38 | public void configure(WebSecurity web) throws Exception { |
| 39 | // 白名单 | 39 | // 白名单 |
| 40 | web.ignoring().antMatchers(Constants.LOGIN_PAGE, Constants.LOGIN, Constants.ASSETS_URL, Constants.FAVICON_URL, Constants.CAPTCHA, | 40 | web.ignoring().antMatchers(Constants.LOGIN_PAGE, Constants.LOGIN, Constants.ASSETS_URL, Constants.FAVICON_URL, Constants.CAPTCHA, |
| 41 | - Constants.SERVICE_INTERFACE, Constants.METRONIC_URL, Constants.LOGIN_FAILURE, Constants.UPSTREAM_URL, Constants.XD_CHILD_PAGES, Constants.UP_RFID_URL,Constants.STATION_AND_SECTION_COUNT); | 41 | + Constants.SERVICE_INTERFACE, Constants.METRONIC_URL, Constants.LOGIN_FAILURE, Constants.UPSTREAM_URL, Constants.XD_CHILD_PAGES, |
| 42 | + Constants.UP_RFID_URL, Constants.STATION_AND_SECTION_COUNT, Constants.FILE_AUTH); | ||
| 42 | } | 43 | } |
| 43 | 44 | ||
| 44 | @Override | 45 | @Override |
src/main/java/com/bsth/security/filter/LoginInterceptor.java
| @@ -33,8 +33,9 @@ public class LoginInterceptor implements Filter { | @@ -33,8 +33,9 @@ public class LoginInterceptor implements Filter { | ||
| 33 | * 相比于 BaseFilter,此处对线调GPS请求进行了拦截验证 | 33 | * 相比于 BaseFilter,此处对线调GPS请求进行了拦截验证 |
| 34 | */ | 34 | */ |
| 35 | private String[] whiteListURLs = { Constants.LOGIN_PAGE,Constants.CAPTCHA, Constants.SERVICE_INTERFACE, | 35 | private String[] whiteListURLs = { Constants.LOGIN_PAGE,Constants.CAPTCHA, Constants.SERVICE_INTERFACE, |
| 36 | - Constants.ASSETS_URL, Constants.FAVICON_URL, Constants.METRONIC_URL, Constants.LOGIN, Constants.LOGIN_FAILURE, Constants.UPSTREAM_URL, Constants.XD_CHILD_PAGES, Constants.UP_RFID_URL,Constants.STATION_AND_SECTION_COUNT, | ||
| 37 | - Constants.VEHICLE_DATA_SYNC_URL }; | 36 | + Constants.ASSETS_URL, Constants.FAVICON_URL, Constants.METRONIC_URL, Constants.LOGIN, |
| 37 | + Constants.LOGIN_FAILURE, Constants.UPSTREAM_URL, Constants.XD_CHILD_PAGES, Constants.UP_RFID_URL, | ||
| 38 | + Constants.STATION_AND_SECTION_COUNT, Constants.VEHICLE_DATA_SYNC_URL, Constants.FILE_AUTH }; | ||
| 38 | 39 | ||
| 39 | 40 | ||
| 40 | @Override | 41 | @Override |
src/main/java/com/bsth/service/TrafficManageService.java
| 1 | -package com.bsth.service; | ||
| 2 | - | ||
| 3 | -/** | ||
| 4 | - * | ||
| 5 | - * @Interface: LineService(线路service业务层实现接口) | ||
| 6 | - * | ||
| 7 | - * @extends : BaseService | ||
| 8 | - * | ||
| 9 | - * @Description: TODO(线路service业务层实现接口) | ||
| 10 | - * | ||
| 11 | - * @Author bsth@lq | ||
| 12 | - * | ||
| 13 | - * @Date 2016年4月28日 上午9:21:17 | ||
| 14 | - * | ||
| 15 | - * @Version 公交调度系统BS版 0.1 | ||
| 16 | - * | ||
| 17 | - */ | ||
| 18 | -public interface TrafficManageService { | ||
| 19 | - | ||
| 20 | - /** | ||
| 21 | - * 上传线路信息 | ||
| 22 | - * | ||
| 23 | - * @return 调用接口返回信息 | ||
| 24 | - */ | ||
| 25 | - String setXL(String ids); | ||
| 26 | - | ||
| 27 | - /** | ||
| 28 | - * 上传线路信息 | ||
| 29 | - * | ||
| 30 | - * @return 调用接口返回信息 | ||
| 31 | - */ | ||
| 32 | - String setXLByInUse(String ids); | ||
| 33 | - | ||
| 34 | - /** | ||
| 35 | - * 上传车辆信息 | ||
| 36 | - * | ||
| 37 | - * @return 调用接口返回信息 | ||
| 38 | - */ | ||
| 39 | - String setCL(); | ||
| 40 | - | ||
| 41 | - /** | ||
| 42 | - * 上传司机信息 | ||
| 43 | - * @return 调用接口返回信息 | ||
| 44 | - */ | ||
| 45 | - String setSJ(); | ||
| 46 | - | ||
| 47 | - /** | ||
| 48 | - * 上传超速数据 | ||
| 49 | - * | ||
| 50 | - * @return 调用接口返回信息 | ||
| 51 | - */ | ||
| 52 | - String setCS(); | ||
| 53 | - | ||
| 54 | - /** | ||
| 55 | - * 上传线路班次时刻表数据 | ||
| 56 | - * | ||
| 57 | - * @return 调用接口返回信息 | ||
| 58 | - */ | ||
| 59 | - String setSKB(String ids); | ||
| 60 | - | ||
| 61 | - /** | ||
| 62 | - * 线路人员车辆配置信息 | ||
| 63 | - * @return 调用接口返回信息 | ||
| 64 | - */ | ||
| 65 | - String setXLPC(); | ||
| 66 | - | ||
| 67 | - /** | ||
| 68 | - * 线路计划班次表 | ||
| 69 | - * @return 调用接口返回信息 | ||
| 70 | - */ | ||
| 71 | - String setJHBC(); | ||
| 72 | - | ||
| 73 | - String setJHBC(String theDate); | ||
| 74 | - | ||
| 75 | - String setLD(String theDate); | ||
| 76 | - | ||
| 77 | - String setLD(); | ||
| 78 | - | ||
| 79 | - String setLDFile(); | ||
| 80 | - | ||
| 81 | - String setLCYH(); | ||
| 82 | - | ||
| 83 | - String setDDRB(); | ||
| 84 | - | ||
| 85 | - /** | ||
| 86 | - * 下载全量的公交基础数据 | ||
| 87 | - * @return | ||
| 88 | - */ | ||
| 89 | - String getDownLoadAllDataFile(); | ||
| 90 | - | ||
| 91 | - /** | ||
| 92 | - * 下载增量的公交基础数据 | ||
| 93 | - * @return | ||
| 94 | - */ | ||
| 95 | - String getDownLoadIncreaseDataFile(); | ||
| 96 | - | ||
| 97 | - /** | ||
| 98 | - * 指定线路查询方式公交基础数据下载 | ||
| 99 | - * @return | ||
| 100 | - */ | ||
| 101 | - String getDownLoadWarrantsBusLineStation(); | ||
| 102 | -} | 1 | +package com.bsth.service; |
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * | ||
| 5 | + * @Interface: LineService(线路service业务层实现接口) | ||
| 6 | + * | ||
| 7 | + * @extends : BaseService | ||
| 8 | + * | ||
| 9 | + * @Description: TODO(线路service业务层实现接口) | ||
| 10 | + * | ||
| 11 | + * @Author bsth@lq | ||
| 12 | + * | ||
| 13 | + * @Date 2016年4月28日 上午9:21:17 | ||
| 14 | + * | ||
| 15 | + * @Version 公交调度系统BS版 0.1 | ||
| 16 | + * | ||
| 17 | + */ | ||
| 18 | +public interface TrafficManageService { | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * 上传线路信息 | ||
| 22 | + * | ||
| 23 | + * @return 调用接口返回信息 | ||
| 24 | + */ | ||
| 25 | + String setXL(String ids); | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * 上传线路信息 | ||
| 29 | + * | ||
| 30 | + * @return 调用接口返回信息 | ||
| 31 | + */ | ||
| 32 | + String setXLByInUse(String ids); | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * 上传车辆信息 | ||
| 36 | + * | ||
| 37 | + * @return 调用接口返回信息 | ||
| 38 | + */ | ||
| 39 | + String setCL(); | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * 上传司机信息 | ||
| 43 | + * @return 调用接口返回信息 | ||
| 44 | + */ | ||
| 45 | + String setSJ(); | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * 上传超速数据 | ||
| 49 | + * | ||
| 50 | + * @return 调用接口返回信息 | ||
| 51 | + */ | ||
| 52 | + String setCS(); | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 上传线路班次时刻表数据 | ||
| 56 | + * | ||
| 57 | + * @return 调用接口返回信息 | ||
| 58 | + */ | ||
| 59 | + String setSKB(String ids, String qyrqs); | ||
| 60 | + | ||
| 61 | + /** | ||
| 62 | + * 线路人员车辆配置信息 | ||
| 63 | + * @return 调用接口返回信息 | ||
| 64 | + */ | ||
| 65 | + String setXLPC(); | ||
| 66 | + | ||
| 67 | + /** | ||
| 68 | + * 线路计划班次表 | ||
| 69 | + * @return 调用接口返回信息 | ||
| 70 | + */ | ||
| 71 | + String setJHBC(); | ||
| 72 | + | ||
| 73 | + String setJHBC(String theDate); | ||
| 74 | + | ||
| 75 | + String setLD(String theDate); | ||
| 76 | + | ||
| 77 | + String setLD(); | ||
| 78 | + | ||
| 79 | + String setLDFile(); | ||
| 80 | + | ||
| 81 | + String setLCYH(); | ||
| 82 | + | ||
| 83 | + String setDDRB(); | ||
| 84 | + | ||
| 85 | + /** | ||
| 86 | + * 下载全量的公交基础数据 | ||
| 87 | + * @return | ||
| 88 | + */ | ||
| 89 | + String getDownLoadAllDataFile(); | ||
| 90 | + | ||
| 91 | + /** | ||
| 92 | + * 下载增量的公交基础数据 | ||
| 93 | + * @return | ||
| 94 | + */ | ||
| 95 | + String getDownLoadIncreaseDataFile(); | ||
| 96 | + | ||
| 97 | + /** | ||
| 98 | + * 指定线路查询方式公交基础数据下载 | ||
| 99 | + * @return | ||
| 100 | + */ | ||
| 101 | + String getDownLoadWarrantsBusLineStation(); | ||
| 102 | +} |
src/main/java/com/bsth/service/impl/TrafficManageServiceImpl.java
| @@ -19,7 +19,6 @@ import com.bsth.repository.traffic.SKBUploadLoggerRepository; | @@ -19,7 +19,6 @@ import com.bsth.repository.traffic.SKBUploadLoggerRepository; | ||
| 19 | import com.bsth.security.util.SecurityUtils; | 19 | import com.bsth.security.util.SecurityUtils; |
| 20 | import com.bsth.service.TrafficManageService; | 20 | import com.bsth.service.TrafficManageService; |
| 21 | import com.bsth.service.traffic.YgcBasicDataService; | 21 | import com.bsth.service.traffic.YgcBasicDataService; |
| 22 | -import com.bsth.util.IpUtils; | ||
| 23 | import com.bsth.util.TimeUtils; | 22 | import com.bsth.util.TimeUtils; |
| 24 | import com.bsth.util.db.DBUtils_MS; | 23 | import com.bsth.util.db.DBUtils_MS; |
| 25 | import com.bsth.webService.trafficManage.org.tempuri.Results; | 24 | import com.bsth.webService.trafficManage.org.tempuri.Results; |
| @@ -529,7 +528,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -529,7 +528,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 529 | try { | 528 | try { |
| 530 | //发送邮件 | 529 | //发送邮件 |
| 531 | EmailBean mail = new EmailBean(); | 530 | EmailBean mail = new EmailBean(); |
| 532 | - mail.setSubject(IpUtils.getLocalIpAddress() +":路单日志数据"+date); | 531 | + mail.setSubject(InetAddress.getLocalHost().getHostAddress()+":路单日志数据"+date); |
| 533 | mail.setContent("总数:" + (listGroup == null ? 0 : listGroup.size()) + "<br/>成功数:" + scount + "<br/>跳过数:" + ccount + "<br/>耗时:" + (System.currentTimeMillis() - start)); | 532 | mail.setContent("总数:" + (listGroup == null ? 0 : listGroup.size()) + "<br/>成功数:" + scount + "<br/>跳过数:" + ccount + "<br/>耗时:" + (System.currentTimeMillis() - start)); |
| 534 | sendEmailController.sendMail(emailSendToAddress, mail); | 533 | sendEmailController.sendMail(emailSendToAddress, mail); |
| 535 | logger.info("setLD-sendMail:邮件发送成功!"); | 534 | logger.info("setLD-sendMail:邮件发送成功!"); |
| @@ -1474,8 +1473,6 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -1474,8 +1473,6 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 1474 | company = "浦东南汇公交公司"; | 1473 | company = "浦东南汇公交公司"; |
| 1475 | }else if(company.equals("青浦公交")){ | 1474 | }else if(company.equals("青浦公交")){ |
| 1476 | company = "浦东青浦公交公司"; | 1475 | company = "浦东青浦公交公司"; |
| 1477 | - }else if(company.equals("临港公交")){ | ||
| 1478 | - company = "临港公交公司"; | ||
| 1479 | } | 1476 | } |
| 1480 | } | 1477 | } |
| 1481 | /** | 1478 | /** |
src/main/java/com/bsth/service/schedule/impl/SchedulePlanServiceImpl.java
| @@ -205,7 +205,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im | @@ -205,7 +205,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im | ||
| 205 | 205 | ||
| 206 | session.fireAllRules(); | 206 | session.fireAllRules(); |
| 207 | 207 | ||
| 208 | - session.dispose();; | 208 | + session.dispose(); |
| 209 | 209 | ||
| 210 | return result; | 210 | return result; |
| 211 | } | 211 | } |
src/main/java/com/bsth/service/sys/SysUserService.java
| 1 | -package com.bsth.service.sys; | ||
| 2 | - | ||
| 3 | -import com.bsth.entity.sys.SysUser; | ||
| 4 | -import com.bsth.service.BaseService; | ||
| 5 | -import org.springframework.web.bind.annotation.RequestParam; | ||
| 6 | - | ||
| 7 | -import java.util.List; | ||
| 8 | -import java.util.Map; | ||
| 9 | - | ||
| 10 | -public interface SysUserService extends BaseService<SysUser, Integer>{ | ||
| 11 | - | ||
| 12 | - SysUser findByUserName(String name); | ||
| 13 | - | ||
| 14 | - int changeEnabled(int id,int enabled); | ||
| 15 | - | ||
| 16 | - int changePWD(int id,String newPWD); | ||
| 17 | - | ||
| 18 | - Map<String,Object> register(SysUser u); | ||
| 19 | - | ||
| 20 | - List<SysUser> findAll_distinct(); | ||
| 21 | - | ||
| 22 | - Map<String, Object> resetPassword(@RequestParam Integer id); | ||
| 23 | -} | 1 | +package com.bsth.service.sys; |
| 2 | + | ||
| 3 | +import com.bsth.entity.sys.SysUser; | ||
| 4 | +import com.bsth.service.BaseService; | ||
| 5 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 6 | + | ||
| 7 | +import java.util.List; | ||
| 8 | +import java.util.Map; | ||
| 9 | + | ||
| 10 | +public interface SysUserService extends BaseService<SysUser, Integer>{ | ||
| 11 | + | ||
| 12 | + SysUser findByUserName(String name); | ||
| 13 | + | ||
| 14 | + int changeEnabled(int id,int enabled); | ||
| 15 | + | ||
| 16 | + int changePWD(int id,String newPWD); | ||
| 17 | + | ||
| 18 | + Map<String,Object> register(SysUser u); | ||
| 19 | + | ||
| 20 | + List<SysUser> findAll_distinct(); | ||
| 21 | + | ||
| 22 | + Map<String, Object> resetPassword(@RequestParam Integer id); | ||
| 23 | + | ||
| 24 | + void recordLoginDate(String userName); | ||
| 25 | +} |
src/main/java/com/bsth/service/sys/impl/PwdGenerator.java
0 → 100644
| 1 | +package com.bsth.service.sys.impl; | ||
| 2 | + | ||
| 3 | +import java.util.Random; | ||
| 4 | + | ||
| 5 | +public class PwdGenerator { | ||
| 6 | + private static final String SPECIAL_CHARS = "!@#$%^&*_=+-/"; | ||
| 7 | + | ||
| 8 | + /** | ||
| 9 | + * 查找一个char数组中还没有填充字符的位置 | ||
| 10 | + */ | ||
| 11 | + private static int nextIndex(char[] chars, Random rnd) { | ||
| 12 | + int index = rnd.nextInt(chars.length); | ||
| 13 | + while (chars[index] != 0) { | ||
| 14 | + index = rnd.nextInt(chars.length); | ||
| 15 | + } | ||
| 16 | + return index; | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * 返回一个随机的特殊字符 | ||
| 21 | + */ | ||
| 22 | + private static char nextSpecialChar(Random rnd) { | ||
| 23 | + return SPECIAL_CHARS.charAt(rnd.nextInt(SPECIAL_CHARS.length())); | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 返回一个随机的大写字母 | ||
| 28 | + */ | ||
| 29 | + private static char nextUpperLetter(Random rnd) { | ||
| 30 | + return (char) ('A' + rnd.nextInt(26)); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * 返回一个随机的小写字母 | ||
| 35 | + */ | ||
| 36 | + private static char nextLowerLetter(Random rnd) { | ||
| 37 | + return (char) ('a' + rnd.nextInt(26)); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * 返回一个随机的数字 | ||
| 42 | + */ | ||
| 43 | + private static char nextNumLetter(Random rnd) { | ||
| 44 | + return (char) ('0' + rnd.nextInt(10)); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * 返回一个随机的字符 | ||
| 49 | + */ | ||
| 50 | + private static char nextChar(Random rnd) { | ||
| 51 | + switch (rnd.nextInt(4)) { | ||
| 52 | + case 0: | ||
| 53 | + return (char) ('a' + rnd.nextInt(26)); | ||
| 54 | + case 1: | ||
| 55 | + return (char) ('A' + rnd.nextInt(26)); | ||
| 56 | + case 2: | ||
| 57 | + return (char) ('0' + rnd.nextInt(10)); | ||
| 58 | + default: | ||
| 59 | + return SPECIAL_CHARS.charAt(rnd.nextInt(SPECIAL_CHARS.length())); | ||
| 60 | + } | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + /** | ||
| 64 | + * 生成指定位数的随机数 | ||
| 65 | + */ | ||
| 66 | + public static String randomPassword(int length) { | ||
| 67 | + if(length < 3){ | ||
| 68 | + return ""; | ||
| 69 | + } | ||
| 70 | + char[] chars = new char[length]; | ||
| 71 | + Random rnd = new Random(); | ||
| 72 | + | ||
| 73 | + //1. 至少生成一个大写字母、小写字母、特殊字符、数字 | ||
| 74 | + chars[nextIndex(chars, rnd)] = nextUpperLetter(rnd); | ||
| 75 | + chars[nextIndex(chars, rnd)] = nextLowerLetter(rnd); | ||
| 76 | + chars[nextIndex(chars, rnd)] = nextNumLetter(rnd); | ||
| 77 | + | ||
| 78 | + //2. 填补其他位置的字符 | ||
| 79 | + for (int i = 0; i < length; i++) { | ||
| 80 | + if (chars[i] == 0) { | ||
| 81 | + chars[i] = nextChar(rnd); | ||
| 82 | + } | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + //3. 返回结果 | ||
| 86 | + return new String(chars); | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + | ||
| 90 | + /** | ||
| 91 | + * 测试代码 | ||
| 92 | + */ | ||
| 93 | + public static void main(String[] args) { | ||
| 94 | + for (int i = 0; i < 10; i++) { | ||
| 95 | + System.out.println(randomPassword(16)); | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | +} |
src/main/java/com/bsth/service/sys/impl/SysUserServiceImpl.java
| @@ -2,6 +2,8 @@ package com.bsth.service.sys.impl; | @@ -2,6 +2,8 @@ package com.bsth.service.sys.impl; | ||
| 2 | 2 | ||
| 3 | import com.bsth.common.ResponseCode; | 3 | import com.bsth.common.ResponseCode; |
| 4 | import com.bsth.controller.sys.util.RSAUtils; | 4 | import com.bsth.controller.sys.util.RSAUtils; |
| 5 | +import com.bsth.email.SendEmailController; | ||
| 6 | +import com.bsth.email.entity.EmailBean; | ||
| 5 | import com.bsth.entity.sys.Role; | 7 | import com.bsth.entity.sys.Role; |
| 6 | import com.bsth.entity.sys.SysUser; | 8 | import com.bsth.entity.sys.SysUser; |
| 7 | import com.bsth.repository.sys.SysUserRepository; | 9 | import com.bsth.repository.sys.SysUserRepository; |
| @@ -9,6 +11,8 @@ import com.bsth.security.util.SecurityUtils; | @@ -9,6 +11,8 @@ import com.bsth.security.util.SecurityUtils; | ||
| 9 | import com.bsth.service.impl.BaseServiceImpl; | 11 | import com.bsth.service.impl.BaseServiceImpl; |
| 10 | import com.bsth.service.sys.RoleService; | 12 | import com.bsth.service.sys.RoleService; |
| 11 | import com.bsth.service.sys.SysUserService; | 13 | import com.bsth.service.sys.SysUserService; |
| 14 | +import com.bsth.util.IpUtils; | ||
| 15 | +import com.bsth.util.MailUtils; | ||
| 12 | import com.google.gson.Gson; | 16 | import com.google.gson.Gson; |
| 13 | import com.google.gson.reflect.TypeToken; | 17 | import com.google.gson.reflect.TypeToken; |
| 14 | import org.slf4j.Logger; | 18 | import org.slf4j.Logger; |
| @@ -16,6 +20,7 @@ import org.slf4j.LoggerFactory; | @@ -16,6 +20,7 @@ import org.slf4j.LoggerFactory; | ||
| 16 | import org.springframework.beans.factory.annotation.Autowired; | 20 | import org.springframework.beans.factory.annotation.Autowired; |
| 17 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | 21 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
| 18 | import org.springframework.stereotype.Service; | 22 | import org.springframework.stereotype.Service; |
| 23 | +import org.springframework.transaction.annotation.Transactional; | ||
| 19 | import org.springframework.web.bind.annotation.RequestParam; | 24 | import org.springframework.web.bind.annotation.RequestParam; |
| 20 | 25 | ||
| 21 | import java.util.ArrayList; | 26 | import java.util.ArrayList; |
| @@ -33,6 +38,10 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUser, Integer> implem | @@ -33,6 +38,10 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUser, Integer> implem | ||
| 33 | @Autowired | 38 | @Autowired |
| 34 | RoleService roleService; | 39 | RoleService roleService; |
| 35 | 40 | ||
| 41 | + // 发送邮件 | ||
| 42 | + @Autowired | ||
| 43 | + private MailUtils mailUtils; | ||
| 44 | + | ||
| 36 | Logger logger = LoggerFactory.getLogger(this.getClass()); | 45 | Logger logger = LoggerFactory.getLogger(this.getClass()); |
| 37 | 46 | ||
| 38 | @Override | 47 | @Override |
| @@ -166,12 +175,19 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUser, Integer> implem | @@ -166,12 +175,19 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUser, Integer> implem | ||
| 166 | Legality = true; | 175 | Legality = true; |
| 167 | } | 176 | } |
| 168 | if(Legality){ | 177 | if(Legality){ |
| 169 | - sysUserRepository.changePWD(id,new BCryptPasswordEncoder(4).encode("123456")); | 178 | + String pwd = PwdGenerator.randomPassword(16); |
| 179 | + sysUserRepository.changePWD(id,new BCryptPasswordEncoder(4).encode(pwd)); | ||
| 180 | + //发送邮件 | ||
| 181 | + EmailBean mail = new EmailBean(); | ||
| 182 | + mail.setSubject(IpUtils.getLocalIpAddress() +":密码重置"); | ||
| 183 | + mail.setContent(pwd); | ||
| 184 | + mailUtils.sendMail(mail); | ||
| 185 | + logger.info("setLD-sendMail:邮件发送成功!"); | ||
| 170 | rs.put("status", ResponseCode.SUCCESS); | 186 | rs.put("status", ResponseCode.SUCCESS); |
| 171 | rs.put("msg", "密码重置成功!"); | 187 | rs.put("msg", "密码重置成功!"); |
| 172 | }else { | 188 | }else { |
| 173 | rs.put("status", ResponseCode.ERROR); | 189 | rs.put("status", ResponseCode.ERROR); |
| 174 | - rs.put("msg", "您不是超级管理员无权限重置其他用户密码"); | 190 | + rs.put("msg", "您不是管理员无权限重置其他用户密码"); |
| 175 | } | 191 | } |
| 176 | }catch (Exception e){ | 192 | }catch (Exception e){ |
| 177 | logger.error("", e); | 193 | logger.error("", e); |
| @@ -180,4 +196,10 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUser, Integer> implem | @@ -180,4 +196,10 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUser, Integer> implem | ||
| 180 | } | 196 | } |
| 181 | return rs; | 197 | return rs; |
| 182 | } | 198 | } |
| 199 | + | ||
| 200 | + @Override | ||
| 201 | + @Transactional(rollbackFor = Exception.class) | ||
| 202 | + public void recordLoginDate(String userName) { | ||
| 203 | + sysUserRepository.recordLoginDate(userName); | ||
| 204 | + } | ||
| 183 | } | 205 | } |
src/main/java/com/bsth/util/MailUtils.java
0 → 100644
| 1 | +package com.bsth.util; | ||
| 2 | + | ||
| 3 | +import com.bsth.email.SimpleMailSender; | ||
| 4 | +import com.bsth.email.entity.EmailBean; | ||
| 5 | +import org.springframework.beans.factory.annotation.Value; | ||
| 6 | +import org.springframework.stereotype.Component; | ||
| 7 | + | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * @author Hill | ||
| 12 | + */ | ||
| 13 | +@Component | ||
| 14 | +public class MailUtils { | ||
| 15 | + | ||
| 16 | + @Value("${admin.mail}") | ||
| 17 | + private String emailSendToAddress; | ||
| 18 | + | ||
| 19 | + private Tools tools = new Tools("mailbox.properties"); | ||
| 20 | + | ||
| 21 | + private SimpleMailSender sms = new SimpleMailSender(tools.getValue("username"),tools.getValue("password")); | ||
| 22 | + | ||
| 23 | + public String getEmailSendToAddress() { | ||
| 24 | + return emailSendToAddress; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + public void setEmailSendToAddress(String emailSendToAddress) { | ||
| 28 | + this.emailSendToAddress = emailSendToAddress; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * recipients | ||
| 33 | + * 收件人集合 | ||
| 34 | |||
| 35 | + * 邮件 | ||
| 36 | + */ | ||
| 37 | + public int sendMail(List<String> recipients, EmailBean mail){ | ||
| 38 | + try { | ||
| 39 | + for (String recipient : recipients) { | ||
| 40 | + sms.send(recipient, mail.getSubject(),mail.getContent()); | ||
| 41 | + } | ||
| 42 | + } catch (Exception e) { | ||
| 43 | + e.printStackTrace(); | ||
| 44 | + return -1; | ||
| 45 | + } | ||
| 46 | + return 1; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + /** | ||
| 50 | + * recipient | ||
| 51 | + * 收件人 | ||
| 52 | |||
| 53 | + * 邮件 | ||
| 54 | + */ | ||
| 55 | + public int sendMail(String recipient,EmailBean mail){ | ||
| 56 | + try { | ||
| 57 | + sms.send(recipient, mail.getSubject(),mail.getContent()); | ||
| 58 | + } catch (Exception e) { | ||
| 59 | + e.printStackTrace(); | ||
| 60 | + return -1; | ||
| 61 | + } | ||
| 62 | + return 1; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + public int sendMail(EmailBean mail){ | ||
| 66 | + return sendMail(emailSendToAddress, mail); | ||
| 67 | + } | ||
| 68 | +} |
src/main/resources/application-dev.properties
| @@ -52,4 +52,6 @@ ms.fl.generate=true | @@ -52,4 +52,6 @@ ms.fl.generate=true | ||
| 52 | ## dsm ack interface | 52 | ## dsm ack interface |
| 53 | dsm.ack.url= http://211.95.61.66:9008/modules/dsmCheckTheRecord/addDsm? | 53 | dsm.ack.url= http://211.95.61.66:9008/modules/dsmCheckTheRecord/addDsm? |
| 54 | ## cp ack interface | 54 | ## cp ack interface |
| 55 | -cp.ack.url= http://114.80.178.12:8778/prod-api/serverApi/instructionsIssue/confirm/ | ||
| 56 | \ No newline at end of file | 55 | \ No newline at end of file |
| 56 | +cp.ack.url= http://114.80.178.12:8778/prod-api/serverApi/instructionsIssue/confirm/ | ||
| 57 | +## admin mail | ||
| 58 | +admin.mail= 3090342880@qq.com | ||
| 57 | \ No newline at end of file | 59 | \ No newline at end of file |
src/main/resources/application-prod.properties
| @@ -54,4 +54,6 @@ ms.fl.generate=true | @@ -54,4 +54,6 @@ ms.fl.generate=true | ||
| 54 | ## dsm ack interface | 54 | ## dsm ack interface |
| 55 | dsm.ack.url= http://211.95.61.66:9008/modules/dsmCheckTheRecord/addDsm? | 55 | dsm.ack.url= http://211.95.61.66:9008/modules/dsmCheckTheRecord/addDsm? |
| 56 | ## cp ack interface | 56 | ## cp ack interface |
| 57 | -cp.ack.url= http://114.80.178.12:8778/prod-api/serverApi/instructionsIssue/confirm/ | ||
| 58 | \ No newline at end of file | 57 | \ No newline at end of file |
| 58 | +cp.ack.url= http://114.80.178.12:8778/prod-api/serverApi/instructionsIssue/confirm/ | ||
| 59 | +## admin mail | ||
| 60 | +admin.mail= 3090342880@qq.com | ||
| 59 | \ No newline at end of file | 61 | \ No newline at end of file |
src/main/resources/application-test.properties
| @@ -54,4 +54,6 @@ ms.fl.generate=false | @@ -54,4 +54,6 @@ ms.fl.generate=false | ||
| 54 | ## dsm ack interface | 54 | ## dsm ack interface |
| 55 | dsm.ack.url= http://211.95.61.66:9008/modules/dsmCheckTheRecord/addDsm? | 55 | dsm.ack.url= http://211.95.61.66:9008/modules/dsmCheckTheRecord/addDsm? |
| 56 | ## cp ack interface | 56 | ## cp ack interface |
| 57 | -cp.ack.url= http://114.80.178.12:8778/prod-api/serverApi/instructionsIssue/confirm/ | ||
| 58 | \ No newline at end of file | 57 | \ No newline at end of file |
| 58 | +cp.ack.url= http://114.80.178.12:8778/prod-api/serverApi/instructionsIssue/confirm/ | ||
| 59 | +## admin mail | ||
| 60 | +admin.mail= 3090342880@qq.com | ||
| 59 | \ No newline at end of file | 61 | \ No newline at end of file |
src/main/resources/static/assets/css/TrafficControl.css
| 1 | -.maplibTc { | ||
| 2 | - font-size: 12px; | ||
| 3 | - width: 253px; | ||
| 4 | - padding: 8px 5px 8px 8px; | ||
| 5 | - background: #3B3F51; | ||
| 6 | - position: absolute; | ||
| 7 | - color: white; | ||
| 8 | - box-shadow: 0 8px 17px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 | ||
| 9 | - rgba(0, 0, 0, 0.19); | ||
| 10 | - top: 63px; | ||
| 11 | -} | ||
| 12 | - | ||
| 13 | -.maplibTc a { | ||
| 14 | - text-decoration: none; | ||
| 15 | -} | ||
| 16 | - | ||
| 17 | -.maplibTcColor { | ||
| 18 | - background: url("../img/tools_menu.png") no-repeat scroll 128px -86px | ||
| 19 | - transparent; | ||
| 20 | - font-weight: bold; | ||
| 21 | - margin-bottom: 9px; | ||
| 22 | - height: 18px; | ||
| 23 | -} | ||
| 24 | - | ||
| 25 | -.maplibTcUpdate { | ||
| 26 | - float: left; | ||
| 27 | - width: 13px; | ||
| 28 | - height: 14px; | ||
| 29 | - background: url(../img/tools_menu.png) no-repeat -12px -19px; | ||
| 30 | - margin-left: 5px; | ||
| 31 | - cursor: pointer; | ||
| 32 | - margin-top: 2px; | ||
| 33 | -} | ||
| 34 | - | ||
| 35 | -.maplibTcView { | ||
| 36 | - float: right; | ||
| 37 | - color: #26c281; | ||
| 38 | - text-decoration: none; | ||
| 39 | - line-height: 15px; | ||
| 40 | - *line-height: 18px | ||
| 41 | -} | ||
| 42 | - | ||
| 43 | -a.maplibTcView:hover { | ||
| 44 | - color: #C6DDD3; | ||
| 45 | -} | ||
| 46 | - | ||
| 47 | -a.maplibTcView:focus { | ||
| 48 | - color: #26c281; | ||
| 49 | -} | ||
| 50 | - | ||
| 51 | -.maplibTcCurTime { | ||
| 52 | - float: left; | ||
| 53 | - color: #ddd; | ||
| 54 | -} | ||
| 55 | - | ||
| 56 | -.maplibTcTime { | ||
| 57 | - height: 20px; | ||
| 58 | - padding: 5px 3px 0 0; | ||
| 59 | -} | ||
| 60 | - | ||
| 61 | -.maplibTcWeekDay { | ||
| 62 | - height: 22px; | ||
| 63 | - color: #6688CA; | ||
| 64 | - padding: 3px 0; | ||
| 65 | -} | ||
| 66 | - | ||
| 67 | -.maplibTcWeekDay a { | ||
| 68 | - color: #6688CA; | ||
| 69 | - padding: 3px 2px; | ||
| 70 | -} | ||
| 71 | - | ||
| 72 | -.maplibTcWeekDay ul { | ||
| 73 | - float: left; | ||
| 74 | - margin: 0; | ||
| 75 | - padding: 0; | ||
| 76 | -} | ||
| 77 | - | ||
| 78 | -.maplibTcWeekDay span { | ||
| 79 | - float: left; | ||
| 80 | - line-height: 23px; | ||
| 81 | -} | ||
| 82 | - | ||
| 83 | -.maplibTcWeekDay li { | ||
| 84 | - float: left; | ||
| 85 | - padding: 0 6px; | ||
| 86 | - list-style: none; | ||
| 87 | - line-height: 23px; | ||
| 88 | -} | ||
| 89 | - | ||
| 90 | -.maplibTcRule { | ||
| 91 | - background: url("../img/bar.png") no-repeat scroll 0 10px transparent; | ||
| 92 | - width: 195px; | ||
| 93 | - float: left; | ||
| 94 | - margin-left: 20px; | ||
| 95 | - *margin-left: 10px; | ||
| 96 | -} | ||
| 97 | - | ||
| 98 | -.maplibTcRuleTxt { | ||
| 99 | - float: left; | ||
| 100 | - line-height: 44px; | ||
| 101 | -} | ||
| 102 | - | ||
| 103 | -.maplibTcClear { | ||
| 104 | - clear: both; | ||
| 105 | -} | ||
| 106 | - | ||
| 107 | -.maplibTcTimeBox { | ||
| 108 | - color: #6688CA; | ||
| 109 | - margin-left: 137.5px; | ||
| 110 | - font-size: 11px; | ||
| 111 | - overflow: hidden; | ||
| 112 | -} | ||
| 113 | - | ||
| 114 | -.maplibTcTimeline { | ||
| 115 | - height: 34px; | ||
| 116 | -} | ||
| 117 | - | ||
| 118 | -.maplibTcTimelinePrev { | ||
| 119 | - overflow: hidden; | ||
| 120 | - width: 9px; | ||
| 121 | - height: 9px; | ||
| 122 | - cursor: pointer; | ||
| 123 | - float: left; | ||
| 124 | - margin-top: 3px | ||
| 125 | -} | ||
| 126 | - | ||
| 127 | -.maplibTcTimelineNext { | ||
| 128 | - overflow: hidden; | ||
| 129 | - width: 11px; | ||
| 130 | - *width: 10px; | ||
| 131 | - height: 9px; | ||
| 132 | - cursor: pointer; | ||
| 133 | - float: right; | ||
| 134 | - margin-top: 3px | ||
| 135 | -} | ||
| 136 | - | ||
| 137 | -.maplibTcTimeMove { | ||
| 138 | - width: 9px; | ||
| 139 | - height: 18px; | ||
| 140 | - background: url("../img/tools_menu.png") no-repeat scroll 0pt -32px | ||
| 141 | - transparent; | ||
| 142 | - float: left; | ||
| 143 | - cursor: pointer; | ||
| 144 | - margin-left: 137.5px; | ||
| 145 | - margin-top: 0px; | ||
| 146 | -} | ||
| 147 | - | ||
| 148 | -.maplibTcHide { | ||
| 149 | - display: none; | ||
| 150 | -} | ||
| 151 | - | ||
| 152 | -.maplibTcBtn_deskTop { | ||
| 153 | - background: url(http://api.map.baidu.com/images/bgs.gif) no-repeat | ||
| 154 | - scroll 0px -271px transparent; | ||
| 155 | - cursor: pointer; | ||
| 156 | - height: 22px; | ||
| 157 | - width: 73px; | ||
| 158 | - z-index: 10; | ||
| 159 | - position: absolute; | ||
| 160 | -} | ||
| 161 | - | ||
| 162 | -.maplibTcBtn_mobile { | ||
| 163 | - background: url(http://api.map.baidu.com/images/traffic_bgs.png) | ||
| 164 | - rgba(255, 255, 255, 0.8) no-repeat scroll -30px 0px; | ||
| 165 | - border: 1px solid #AFAFAF; | ||
| 166 | - background-size: 60px 30px; | ||
| 167 | - cursor: pointer; | ||
| 168 | - height: 30px; | ||
| 169 | - width: 30px; | ||
| 170 | - z-index: 10; | ||
| 171 | - position: absolute; | ||
| 172 | -} | ||
| 173 | - | ||
| 174 | -.maplibTcBtn_deskTop { | ||
| 175 | - background-position: 0px -249px | ||
| 176 | -} | ||
| 177 | - | ||
| 178 | -.maplibTcBtnOff_mobile { | ||
| 179 | - background-position: 0px 0px; | ||
| 180 | -} | ||
| 181 | - | ||
| 182 | -.maplibTcColon { | ||
| 183 | - float: left; | ||
| 184 | -} | ||
| 185 | - | ||
| 186 | -.maplibTcOn { | ||
| 187 | - background: #E6EFF8; | ||
| 188 | -} | ||
| 189 | - | ||
| 190 | -.maplibTcClose { | ||
| 191 | - background: url("../img/tools_menu.png") no-repeat scroll 2px -19px | ||
| 192 | - transparent; | ||
| 193 | - border: 0 none; | ||
| 194 | - cursor: pointer; | ||
| 195 | - height: 12px; | ||
| 196 | - position: absolute; | ||
| 197 | - right: 7px; | ||
| 198 | - top: 9px; | ||
| 199 | - width: 15px; | ||
| 200 | -} | ||
| 201 | - | ||
| 202 | -/*s--------------交通流量-----------------*/ | ||
| 203 | -.maplibTfctr { | ||
| 204 | - min-width: 9em; | ||
| 205 | - height: 2.2em; | ||
| 206 | - display: -webkit-box; | ||
| 207 | - -webkit-box-align: center; | ||
| 208 | - -webkit-border-radius: 0.3em; | ||
| 209 | - border: .1em solid #989898; | ||
| 210 | - -webkit-box-sizing: border-box; | ||
| 211 | - background-color: #fff; | ||
| 212 | - font-size: 14px; | ||
| 213 | -} | ||
| 214 | - | ||
| 215 | -.maplibTfctrHide { | ||
| 216 | - display: none; | ||
| 217 | -} | ||
| 218 | - | ||
| 219 | -.maplibTfctr_c { | ||
| 220 | - -webkit-box-flex: 1; | ||
| 221 | -} | ||
| 222 | - | ||
| 223 | -.maplibTfctr_status { | ||
| 224 | - width: 4em; | ||
| 225 | - margin-right: .45em; | ||
| 226 | -} | ||
| 227 | - | ||
| 228 | -.maplibTfctr_status span { | ||
| 229 | - display: inline-block; | ||
| 230 | - margin-left: .3em; | ||
| 231 | - font-size: 14px; | ||
| 232 | -} | ||
| 233 | - | ||
| 234 | -.maplibTfctr div,.maplibTfctr span { | ||
| 235 | - -webkit-box-sizing: border-box; | ||
| 236 | -} | ||
| 237 | - | ||
| 238 | -.maplibTfctr_l { | ||
| 239 | - margin: 0 .15em; | ||
| 240 | -} | ||
| 241 | - | ||
| 242 | -.maplibY { | ||
| 243 | - background: #ffae00; | ||
| 244 | -} | ||
| 245 | - | ||
| 246 | -.maplibR { | ||
| 247 | - background: #ff0000; | ||
| 248 | -} | ||
| 249 | - | ||
| 250 | -.maplibG { | ||
| 251 | - background: #1fba00; | ||
| 252 | -} | 1 | +.maplibTc { |
| 2 | + font-size: 12px; | ||
| 3 | + width: 253px; | ||
| 4 | + padding: 8px 5px 8px 8px; | ||
| 5 | + background: #3B3F51; | ||
| 6 | + position: absolute; | ||
| 7 | + color: white; | ||
| 8 | + box-shadow: 0 8px 17px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 | ||
| 9 | + rgba(0, 0, 0, 0.19); | ||
| 10 | + top: 63px; | ||
| 11 | +} | ||
| 12 | + | ||
| 13 | +.maplibTc a { | ||
| 14 | + text-decoration: none; | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +.maplibTcColor { | ||
| 18 | + background: url("../img/tools_menu.png") no-repeat scroll 128px -86px | ||
| 19 | + transparent; | ||
| 20 | + font-weight: bold; | ||
| 21 | + margin-bottom: 9px; | ||
| 22 | + height: 18px; | ||
| 23 | +} | ||
| 24 | + | ||
| 25 | +.maplibTcUpdate { | ||
| 26 | + float: left; | ||
| 27 | + width: 13px; | ||
| 28 | + height: 14px; | ||
| 29 | + background: url(../img/tools_menu.png) no-repeat -12px -19px; | ||
| 30 | + margin-left: 5px; | ||
| 31 | + cursor: pointer; | ||
| 32 | + margin-top: 2px; | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +.maplibTcView { | ||
| 36 | + float: right; | ||
| 37 | + color: #26c281; | ||
| 38 | + text-decoration: none; | ||
| 39 | + line-height: 15px; | ||
| 40 | + *line-height: 18px | ||
| 41 | +} | ||
| 42 | + | ||
| 43 | +a.maplibTcView:hover { | ||
| 44 | + color: #C6DDD3; | ||
| 45 | +} | ||
| 46 | + | ||
| 47 | +a.maplibTcView:focus { | ||
| 48 | + color: #26c281; | ||
| 49 | +} | ||
| 50 | + | ||
| 51 | +.maplibTcCurTime { | ||
| 52 | + float: left; | ||
| 53 | + color: #ddd; | ||
| 54 | +} | ||
| 55 | + | ||
| 56 | +.maplibTcTime { | ||
| 57 | + height: 20px; | ||
| 58 | + padding: 5px 3px 0 0; | ||
| 59 | +} | ||
| 60 | + | ||
| 61 | +.maplibTcWeekDay { | ||
| 62 | + height: 22px; | ||
| 63 | + color: #6688CA; | ||
| 64 | + padding: 3px 0; | ||
| 65 | +} | ||
| 66 | + | ||
| 67 | +.maplibTcWeekDay a { | ||
| 68 | + color: #6688CA; | ||
| 69 | + padding: 3px 2px; | ||
| 70 | +} | ||
| 71 | + | ||
| 72 | +.maplibTcWeekDay ul { | ||
| 73 | + float: left; | ||
| 74 | + margin: 0; | ||
| 75 | + padding: 0; | ||
| 76 | +} | ||
| 77 | + | ||
| 78 | +.maplibTcWeekDay span { | ||
| 79 | + float: left; | ||
| 80 | + line-height: 23px; | ||
| 81 | +} | ||
| 82 | + | ||
| 83 | +.maplibTcWeekDay li { | ||
| 84 | + float: left; | ||
| 85 | + padding: 0 6px; | ||
| 86 | + list-style: none; | ||
| 87 | + line-height: 23px; | ||
| 88 | +} | ||
| 89 | + | ||
| 90 | +.maplibTcRule { | ||
| 91 | + background: url("../img/bar.png") no-repeat scroll 0 10px transparent; | ||
| 92 | + width: 195px; | ||
| 93 | + float: left; | ||
| 94 | + margin-left: 20px; | ||
| 95 | + *margin-left: 10px; | ||
| 96 | +} | ||
| 97 | + | ||
| 98 | +.maplibTcRuleTxt { | ||
| 99 | + float: left; | ||
| 100 | + line-height: 44px; | ||
| 101 | +} | ||
| 102 | + | ||
| 103 | +.maplibTcClear { | ||
| 104 | + clear: both; | ||
| 105 | +} | ||
| 106 | + | ||
| 107 | +.maplibTcTimeBox { | ||
| 108 | + color: #6688CA; | ||
| 109 | + margin-left: 137.5px; | ||
| 110 | + font-size: 11px; | ||
| 111 | + overflow: hidden; | ||
| 112 | +} | ||
| 113 | + | ||
| 114 | +.maplibTcTimeline { | ||
| 115 | + height: 34px; | ||
| 116 | +} | ||
| 117 | + | ||
| 118 | +.maplibTcTimelinePrev { | ||
| 119 | + overflow: hidden; | ||
| 120 | + width: 9px; | ||
| 121 | + height: 9px; | ||
| 122 | + cursor: pointer; | ||
| 123 | + float: left; | ||
| 124 | + margin-top: 3px | ||
| 125 | +} | ||
| 126 | + | ||
| 127 | +.maplibTcTimelineNext { | ||
| 128 | + overflow: hidden; | ||
| 129 | + width: 11px; | ||
| 130 | + *width: 10px; | ||
| 131 | + height: 9px; | ||
| 132 | + cursor: pointer; | ||
| 133 | + float: right; | ||
| 134 | + margin-top: 3px | ||
| 135 | +} | ||
| 136 | + | ||
| 137 | +.maplibTcTimeMove { | ||
| 138 | + width: 9px; | ||
| 139 | + height: 18px; | ||
| 140 | + background: url("../img/tools_menu.png") no-repeat scroll 0pt -32px | ||
| 141 | + transparent; | ||
| 142 | + float: left; | ||
| 143 | + cursor: pointer; | ||
| 144 | + margin-left: 137.5px; | ||
| 145 | + margin-top: 0px; | ||
| 146 | +} | ||
| 147 | + | ||
| 148 | +.maplibTcHide { | ||
| 149 | + display: none; | ||
| 150 | +} | ||
| 151 | + | ||
| 152 | +.maplibTcBtn_deskTop { | ||
| 153 | + background: url(//api.map.baidu.com/images/bgs.gif) no-repeat | ||
| 154 | + scroll 0px -271px transparent; | ||
| 155 | + cursor: pointer; | ||
| 156 | + height: 22px; | ||
| 157 | + width: 73px; | ||
| 158 | + z-index: 10; | ||
| 159 | + position: absolute; | ||
| 160 | +} | ||
| 161 | + | ||
| 162 | +.maplibTcBtn_mobile { | ||
| 163 | + background: url(//api.map.baidu.com/images/traffic_bgs.png) | ||
| 164 | + rgba(255, 255, 255, 0.8) no-repeat scroll -30px 0px; | ||
| 165 | + border: 1px solid #AFAFAF; | ||
| 166 | + background-size: 60px 30px; | ||
| 167 | + cursor: pointer; | ||
| 168 | + height: 30px; | ||
| 169 | + width: 30px; | ||
| 170 | + z-index: 10; | ||
| 171 | + position: absolute; | ||
| 172 | +} | ||
| 173 | + | ||
| 174 | +.maplibTcBtn_deskTop { | ||
| 175 | + background-position: 0px -249px | ||
| 176 | +} | ||
| 177 | + | ||
| 178 | +.maplibTcBtnOff_mobile { | ||
| 179 | + background-position: 0px 0px; | ||
| 180 | +} | ||
| 181 | + | ||
| 182 | +.maplibTcColon { | ||
| 183 | + float: left; | ||
| 184 | +} | ||
| 185 | + | ||
| 186 | +.maplibTcOn { | ||
| 187 | + background: #E6EFF8; | ||
| 188 | +} | ||
| 189 | + | ||
| 190 | +.maplibTcClose { | ||
| 191 | + background: url("../img/tools_menu.png") no-repeat scroll 2px -19px | ||
| 192 | + transparent; | ||
| 193 | + border: 0 none; | ||
| 194 | + cursor: pointer; | ||
| 195 | + height: 12px; | ||
| 196 | + position: absolute; | ||
| 197 | + right: 7px; | ||
| 198 | + top: 9px; | ||
| 199 | + width: 15px; | ||
| 200 | +} | ||
| 201 | + | ||
| 202 | +/*s--------------交通流量-----------------*/ | ||
| 203 | +.maplibTfctr { | ||
| 204 | + min-width: 9em; | ||
| 205 | + height: 2.2em; | ||
| 206 | + display: -webkit-box; | ||
| 207 | + -webkit-box-align: center; | ||
| 208 | + -webkit-border-radius: 0.3em; | ||
| 209 | + border: .1em solid #989898; | ||
| 210 | + -webkit-box-sizing: border-box; | ||
| 211 | + background-color: #fff; | ||
| 212 | + font-size: 14px; | ||
| 213 | +} | ||
| 214 | + | ||
| 215 | +.maplibTfctrHide { | ||
| 216 | + display: none; | ||
| 217 | +} | ||
| 218 | + | ||
| 219 | +.maplibTfctr_c { | ||
| 220 | + -webkit-box-flex: 1; | ||
| 221 | +} | ||
| 222 | + | ||
| 223 | +.maplibTfctr_status { | ||
| 224 | + width: 4em; | ||
| 225 | + margin-right: .45em; | ||
| 226 | +} | ||
| 227 | + | ||
| 228 | +.maplibTfctr_status span { | ||
| 229 | + display: inline-block; | ||
| 230 | + margin-left: .3em; | ||
| 231 | + font-size: 14px; | ||
| 232 | +} | ||
| 233 | + | ||
| 234 | +.maplibTfctr div,.maplibTfctr span { | ||
| 235 | + -webkit-box-sizing: border-box; | ||
| 236 | +} | ||
| 237 | + | ||
| 238 | +.maplibTfctr_l { | ||
| 239 | + margin: 0 .15em; | ||
| 240 | +} | ||
| 241 | + | ||
| 242 | +.maplibY { | ||
| 243 | + background: #ffae00; | ||
| 244 | +} | ||
| 245 | + | ||
| 246 | +.maplibR { | ||
| 247 | + background: #ff0000; | ||
| 248 | +} | ||
| 249 | + | ||
| 250 | +.maplibG { | ||
| 251 | + background: #1fba00; | ||
| 252 | +} | ||
| 253 | /*e--------------交通流量-----------------*/ | 253 | /*e--------------交通流量-----------------*/ |
| 254 | \ No newline at end of file | 254 | \ No newline at end of file |
src/main/resources/static/assets/js/baidu/TextIconOverlay.js
| 1 | -/** | ||
| 2 | - * @fileoverview 此类表示地图上的一个覆盖物,该覆盖物由文字和图标组成,从Overlay继承。 | ||
| 3 | - * 主入口类是<a href="symbols/BMapLib.TextIconOverlay.html">TextIconOverlay</a>, | ||
| 4 | - * 基于Baidu Map API 1.2。 | ||
| 5 | - * | ||
| 6 | - * @author Baidu Map Api Group | ||
| 7 | - * @version 1.2 | ||
| 8 | - */ | ||
| 9 | - | ||
| 10 | - | ||
| 11 | - /** | ||
| 12 | - * @namespace BMap的所有library类均放在BMapLib命名空间下 | ||
| 13 | - */ | ||
| 14 | -var BMapLib = window.BMapLib = BMapLib || {}; | ||
| 15 | - | ||
| 16 | -(function () { | ||
| 17 | - | ||
| 18 | - /** | ||
| 19 | - * 声明baidu包 | ||
| 20 | - */ | ||
| 21 | - var T, | ||
| 22 | - baidu = T = baidu || {version: "1.3.8"}; | ||
| 23 | - | ||
| 24 | - (function (){ | ||
| 25 | - //提出guid,防止在与老版本Tangram混用时 | ||
| 26 | - //在下一行错误的修改window[undefined] | ||
| 27 | - baidu.guid = "$BAIDU$"; | ||
| 28 | - | ||
| 29 | - //Tangram可能被放在闭包中 | ||
| 30 | - //一些页面级别唯一的属性,需要挂载在window[baidu.guid]上 | ||
| 31 | - window[baidu.guid] = window[baidu.guid] || {}; | ||
| 32 | - | ||
| 33 | - /** | ||
| 34 | - * @ignore | ||
| 35 | - * @namespace baidu.dom 操作dom的方法。 | ||
| 36 | - */ | ||
| 37 | - baidu.dom = baidu.dom || {}; | ||
| 38 | - | ||
| 39 | - | ||
| 40 | - /** | ||
| 41 | - * 从文档中获取指定的DOM元素 | ||
| 42 | - * @name baidu.dom.g | ||
| 43 | - * @function | ||
| 44 | - * @grammar baidu.dom.g(id) | ||
| 45 | - * @param {string|HTMLElement} id 元素的id或DOM元素 | ||
| 46 | - * @shortcut g,T.G | ||
| 47 | - * @meta standard | ||
| 48 | - * @see baidu.dom.q | ||
| 49 | - * | ||
| 50 | - * @returns {HTMLElement|null} 获取的元素,查找不到时返回null,如果参数不合法,直接返回参数 | ||
| 51 | - */ | ||
| 52 | - baidu.dom.g = function (id) { | ||
| 53 | - if ('string' == typeof id || id instanceof String) { | ||
| 54 | - return document.getElementById(id); | ||
| 55 | - } else if (id && id.nodeName && (id.nodeType == 1 || id.nodeType == 9)) { | ||
| 56 | - return id; | ||
| 57 | - } | ||
| 58 | - return null; | ||
| 59 | - }; | ||
| 60 | - | ||
| 61 | - // 声明快捷方法 | ||
| 62 | - baidu.g = baidu.G = baidu.dom.g; | ||
| 63 | - | ||
| 64 | - /** | ||
| 65 | - * 获取目标元素所属的document对象 | ||
| 66 | - * @name baidu.dom.getDocument | ||
| 67 | - * @function | ||
| 68 | - * @grammar baidu.dom.getDocument(element) | ||
| 69 | - * @param {HTMLElement|string} element 目标元素或目标元素的id | ||
| 70 | - * @meta standard | ||
| 71 | - * @see baidu.dom.getWindow | ||
| 72 | - * | ||
| 73 | - * @returns {HTMLDocument} 目标元素所属的document对象 | ||
| 74 | - */ | ||
| 75 | - baidu.dom.getDocument = function (element) { | ||
| 76 | - element = baidu.dom.g(element); | ||
| 77 | - return element.nodeType == 9 ? element : element.ownerDocument || element.document; | ||
| 78 | - }; | ||
| 79 | - | ||
| 80 | - /** | ||
| 81 | - * @ignore | ||
| 82 | - * @namespace baidu.lang 对语言层面的封装,包括类型判断、模块扩展、继承基类以及对象自定义事件的支持。 | ||
| 83 | - */ | ||
| 84 | - baidu.lang = baidu.lang || {}; | ||
| 85 | - | ||
| 86 | - /** | ||
| 87 | - * 判断目标参数是否string类型或String对象 | ||
| 88 | - * @name baidu.lang.isString | ||
| 89 | - * @function | ||
| 90 | - * @grammar baidu.lang.isString(source) | ||
| 91 | - * @param {Any} source 目标参数 | ||
| 92 | - * @shortcut isString | ||
| 93 | - * @meta standard | ||
| 94 | - * @see baidu.lang.isObject,baidu.lang.isNumber,baidu.lang.isArray,baidu.lang.isElement,baidu.lang.isBoolean,baidu.lang.isDate | ||
| 95 | - * | ||
| 96 | - * @returns {boolean} 类型判断结果 | ||
| 97 | - */ | ||
| 98 | - baidu.lang.isString = function (source) { | ||
| 99 | - return '[object String]' == Object.prototype.toString.call(source); | ||
| 100 | - }; | ||
| 101 | - | ||
| 102 | - // 声明快捷方法 | ||
| 103 | - baidu.isString = baidu.lang.isString; | ||
| 104 | - | ||
| 105 | - /** | ||
| 106 | - * 从文档中获取指定的DOM元素 | ||
| 107 | - * **内部方法** | ||
| 108 | - * | ||
| 109 | - * @param {string|HTMLElement} id 元素的id或DOM元素 | ||
| 110 | - * @meta standard | ||
| 111 | - * @return {HTMLElement} DOM元素,如果不存在,返回null,如果参数不合法,直接返回参数 | ||
| 112 | - */ | ||
| 113 | - baidu.dom._g = function (id) { | ||
| 114 | - if (baidu.lang.isString(id)) { | ||
| 115 | - return document.getElementById(id); | ||
| 116 | - } | ||
| 117 | - return id; | ||
| 118 | - }; | ||
| 119 | - | ||
| 120 | - // 声明快捷方法 | ||
| 121 | - baidu._g = baidu.dom._g; | ||
| 122 | - | ||
| 123 | - /** | ||
| 124 | - * @ignore | ||
| 125 | - * @namespace baidu.browser 判断浏览器类型和特性的属性。 | ||
| 126 | - */ | ||
| 127 | - baidu.browser = baidu.browser || {}; | ||
| 128 | - | ||
| 129 | - if (/msie (\d+\.\d)/i.test(navigator.userAgent)) { | ||
| 130 | - //IE 8下,以documentMode为准 | ||
| 131 | - //在百度模板中,可能会有$,防止冲突,将$1 写成 \x241 | ||
| 132 | - /** | ||
| 133 | - * 判断是否为ie浏览器 | ||
| 134 | - * @property ie ie版本号 | ||
| 135 | - * @grammar baidu.browser.ie | ||
| 136 | - * @meta standard | ||
| 137 | - * @shortcut ie | ||
| 138 | - * @see baidu.browser.firefox,baidu.browser.safari,baidu.browser.opera,baidu.browser.chrome,baidu.browser.maxthon | ||
| 139 | - */ | ||
| 140 | - baidu.browser.ie = baidu.ie = document.documentMode || + RegExp['\x241']; | ||
| 141 | - } | ||
| 142 | - | ||
| 143 | - /** | ||
| 144 | - * 获取目标元素的computed style值。如果元素的样式值不能被浏览器计算,则会返回空字符串(IE) | ||
| 145 | - * | ||
| 146 | - * @author berg | ||
| 147 | - * @name baidu.dom.getComputedStyle | ||
| 148 | - * @function | ||
| 149 | - * @grammar baidu.dom.getComputedStyle(element, key) | ||
| 150 | - * @param {HTMLElement|string} element 目标元素或目标元素的id | ||
| 151 | - * @param {string} key 要获取的样式名 | ||
| 152 | - * | ||
| 153 | - * @see baidu.dom.getStyle | ||
| 154 | - * | ||
| 155 | - * @returns {string} 目标元素的computed style值 | ||
| 156 | - */ | ||
| 157 | - | ||
| 158 | - baidu.dom.getComputedStyle = function(element, key){ | ||
| 159 | - element = baidu.dom._g(element); | ||
| 160 | - var doc = baidu.dom.getDocument(element), | ||
| 161 | - styles; | ||
| 162 | - if (doc.defaultView && doc.defaultView.getComputedStyle) { | ||
| 163 | - styles = doc.defaultView.getComputedStyle(element, null); | ||
| 164 | - if (styles) { | ||
| 165 | - return styles[key] || styles.getPropertyValue(key); | ||
| 166 | - } | ||
| 167 | - } | ||
| 168 | - return ''; | ||
| 169 | - }; | ||
| 170 | - | ||
| 171 | - /** | ||
| 172 | - * 提供给setStyle与getStyle使用 | ||
| 173 | - */ | ||
| 174 | - baidu.dom._styleFixer = baidu.dom._styleFixer || {}; | ||
| 175 | - | ||
| 176 | - /** | ||
| 177 | - * 提供给setStyle与getStyle使用 | ||
| 178 | - */ | ||
| 179 | - baidu.dom._styleFilter = baidu.dom._styleFilter || []; | ||
| 180 | - | ||
| 181 | - /** | ||
| 182 | - * 为获取和设置样式的过滤器 | ||
| 183 | - * @private | ||
| 184 | - * @meta standard | ||
| 185 | - */ | ||
| 186 | - baidu.dom._styleFilter.filter = function (key, value, method) { | ||
| 187 | - for (var i = 0, filters = baidu.dom._styleFilter, filter; filter = filters[i]; i++) { | ||
| 188 | - if (filter = filter[method]) { | ||
| 189 | - value = filter(key, value); | ||
| 190 | - } | ||
| 191 | - } | ||
| 192 | - return value; | ||
| 193 | - }; | ||
| 194 | - | ||
| 195 | - /** | ||
| 196 | - * @ignore | ||
| 197 | - * @namespace baidu.string 操作字符串的方法。 | ||
| 198 | - */ | ||
| 199 | - baidu.string = baidu.string || {}; | ||
| 200 | - | ||
| 201 | - /** | ||
| 202 | - * 将目标字符串进行驼峰化处理 | ||
| 203 | - * @name baidu.string.toCamelCase | ||
| 204 | - * @function | ||
| 205 | - * @grammar baidu.string.toCamelCase(source) | ||
| 206 | - * @param {string} source 目标字符串 | ||
| 207 | - * @remark | ||
| 208 | - * 支持单词以“-_”分隔 | ||
| 209 | - * @meta standard | ||
| 210 | - * | ||
| 211 | - * @returns {string} 驼峰化处理后的字符串 | ||
| 212 | - */ | ||
| 213 | - baidu.string.toCamelCase = function (source) { | ||
| 214 | - //提前判断,提高getStyle等的效率 thanks xianwei | ||
| 215 | - if (source.indexOf('-') < 0 && source.indexOf('_') < 0) { | ||
| 216 | - return source; | ||
| 217 | - } | ||
| 218 | - return source.replace(/[-_][^-_]/g, function (match) { | ||
| 219 | - return match.charAt(1).toUpperCase(); | ||
| 220 | - }); | ||
| 221 | - }; | ||
| 222 | - | ||
| 223 | - /** | ||
| 224 | - * 获取目标元素的样式值 | ||
| 225 | - * @name baidu.dom.getStyle | ||
| 226 | - * @function | ||
| 227 | - * @grammar baidu.dom.getStyle(element, key) | ||
| 228 | - * @param {HTMLElement|string} element 目标元素或目标元素的id | ||
| 229 | - * @param {string} key 要获取的样式名 | ||
| 230 | - * @remark | ||
| 231 | - * | ||
| 232 | - * 为了精简代码,本模块默认不对任何浏览器返回值进行归一化处理(如使用getStyle时,不同浏览器下可能返回rgb颜色或hex颜色),也不会修复浏览器的bug和差异性(如设置IE的float属性叫styleFloat,firefox则是cssFloat)。<br /> | ||
| 233 | - * baidu.dom._styleFixer和baidu.dom._styleFilter可以为本模块提供支持。<br /> | ||
| 234 | - * 其中_styleFilter能对颜色和px进行归一化处理,_styleFixer能对display,float,opacity,textOverflow的浏览器兼容性bug进行处理。 | ||
| 235 | - * @shortcut getStyle | ||
| 236 | - * @meta standard | ||
| 237 | - * @see baidu.dom.setStyle,baidu.dom.setStyles, baidu.dom.getComputedStyle | ||
| 238 | - * | ||
| 239 | - * @returns {string} 目标元素的样式值 | ||
| 240 | - */ | ||
| 241 | - baidu.dom.getStyle = function (element, key) { | ||
| 242 | - var dom = baidu.dom; | ||
| 243 | - | ||
| 244 | - element = dom.g(element); | ||
| 245 | - key = baidu.string.toCamelCase(key); | ||
| 246 | - //computed style, then cascaded style, then explicitly set style. | ||
| 247 | - var value = element.style[key] || | ||
| 248 | - (element.currentStyle ? element.currentStyle[key] : "") || | ||
| 249 | - dom.getComputedStyle(element, key); | ||
| 250 | - | ||
| 251 | - // 在取不到值的时候,用fixer进行修正 | ||
| 252 | - if (!value) { | ||
| 253 | - var fixer = dom._styleFixer[key]; | ||
| 254 | - if(fixer){ | ||
| 255 | - value = fixer.get ? fixer.get(element) : baidu.dom.getStyle(element, fixer); | ||
| 256 | - } | ||
| 257 | - } | ||
| 258 | - | ||
| 259 | - /* 检查结果过滤器 */ | ||
| 260 | - if (fixer = dom._styleFilter) { | ||
| 261 | - value = fixer.filter(key, value, 'get'); | ||
| 262 | - } | ||
| 263 | - | ||
| 264 | - return value; | ||
| 265 | - }; | ||
| 266 | - | ||
| 267 | - // 声明快捷方法 | ||
| 268 | - baidu.getStyle = baidu.dom.getStyle; | ||
| 269 | - | ||
| 270 | - | ||
| 271 | - if (/opera\/(\d+\.\d)/i.test(navigator.userAgent)) { | ||
| 272 | - /** | ||
| 273 | - * 判断是否为opera浏览器 | ||
| 274 | - * @property opera opera版本号 | ||
| 275 | - * @grammar baidu.browser.opera | ||
| 276 | - * @meta standard | ||
| 277 | - * @see baidu.browser.ie,baidu.browser.firefox,baidu.browser.safari,baidu.browser.chrome | ||
| 278 | - */ | ||
| 279 | - baidu.browser.opera = + RegExp['\x241']; | ||
| 280 | - } | ||
| 281 | - | ||
| 282 | - /** | ||
| 283 | - * 判断是否为webkit内核 | ||
| 284 | - * @property isWebkit | ||
| 285 | - * @grammar baidu.browser.isWebkit | ||
| 286 | - * @meta standard | ||
| 287 | - * @see baidu.browser.isGecko | ||
| 288 | - */ | ||
| 289 | - baidu.browser.isWebkit = /webkit/i.test(navigator.userAgent); | ||
| 290 | - | ||
| 291 | - /** | ||
| 292 | - * 判断是否为gecko内核 | ||
| 293 | - * @property isGecko | ||
| 294 | - * @grammar baidu.browser.isGecko | ||
| 295 | - * @meta standard | ||
| 296 | - * @see baidu.browser.isWebkit | ||
| 297 | - */ | ||
| 298 | - baidu.browser.isGecko = /gecko/i.test(navigator.userAgent) && !/like gecko/i.test(navigator.userAgent); | ||
| 299 | - | ||
| 300 | - /** | ||
| 301 | - * 判断是否严格标准的渲染模式 | ||
| 302 | - * @property isStrict | ||
| 303 | - * @grammar baidu.browser.isStrict | ||
| 304 | - * @meta standard | ||
| 305 | - */ | ||
| 306 | - baidu.browser.isStrict = document.compatMode == "CSS1Compat"; | ||
| 307 | - | ||
| 308 | - /** | ||
| 309 | - * 获取目标元素相对于整个文档左上角的位置 | ||
| 310 | - * @name baidu.dom.getPosition | ||
| 311 | - * @function | ||
| 312 | - * @grammar baidu.dom.getPosition(element) | ||
| 313 | - * @param {HTMLElement|string} element 目标元素或目标元素的id | ||
| 314 | - * @meta standard | ||
| 315 | - * | ||
| 316 | - * @returns {Object} 目标元素的位置,键值为top和left的Object。 | ||
| 317 | - */ | ||
| 318 | - baidu.dom.getPosition = function (element) { | ||
| 319 | - element = baidu.dom.g(element); | ||
| 320 | - var doc = baidu.dom.getDocument(element), | ||
| 321 | - browser = baidu.browser, | ||
| 322 | - getStyle = baidu.dom.getStyle, | ||
| 323 | - // Gecko 1.9版本以下用getBoxObjectFor计算位置 | ||
| 324 | - // 但是某些情况下是有bug的 | ||
| 325 | - // 对于这些有bug的情况 | ||
| 326 | - // 使用递归查找的方式 | ||
| 327 | - BUGGY_GECKO_BOX_OBJECT = browser.isGecko > 0 && | ||
| 328 | - doc.getBoxObjectFor && | ||
| 329 | - getStyle(element, 'position') == 'absolute' && | ||
| 330 | - (element.style.top === '' || element.style.left === ''), | ||
| 331 | - pos = {"left":0,"top":0}, | ||
| 332 | - viewport = (browser.ie && !browser.isStrict) ? doc.body : doc.documentElement, | ||
| 333 | - parent, | ||
| 334 | - box; | ||
| 335 | - | ||
| 336 | - if(element == viewport){ | ||
| 337 | - return pos; | ||
| 338 | - } | ||
| 339 | - | ||
| 340 | - if(element.getBoundingClientRect){ // IE and Gecko 1.9+ | ||
| 341 | - | ||
| 342 | - //当HTML或者BODY有border width时, 原生的getBoundingClientRect返回值是不符合预期的 | ||
| 343 | - //考虑到通常情况下 HTML和BODY的border只会设成0px,所以忽略该问题. | ||
| 344 | - box = element.getBoundingClientRect(); | ||
| 345 | - | ||
| 346 | - pos.left = Math.floor(box.left) + Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft); | ||
| 347 | - pos.top = Math.floor(box.top) + Math.max(doc.documentElement.scrollTop, doc.body.scrollTop); | ||
| 348 | - | ||
| 349 | - // IE会给HTML元素添加一个border,默认是medium(2px) | ||
| 350 | - // 但是在IE 6 7 的怪异模式下,可以被html { border: 0; } 这条css规则覆盖 | ||
| 351 | - // 在IE7的标准模式下,border永远是2px,这个值通过clientLeft 和 clientTop取得 | ||
| 352 | - // 但是。。。在IE 6 7的怪异模式,如果用户使用css覆盖了默认的medium | ||
| 353 | - // clientTop和clientLeft不会更新 | ||
| 354 | - pos.left -= doc.documentElement.clientLeft; | ||
| 355 | - pos.top -= doc.documentElement.clientTop; | ||
| 356 | - | ||
| 357 | - var htmlDom = doc.body, | ||
| 358 | - // 在这里,不使用element.style.borderLeftWidth,只有computedStyle是可信的 | ||
| 359 | - htmlBorderLeftWidth = parseInt(getStyle(htmlDom, 'borderLeftWidth')), | ||
| 360 | - htmlBorderTopWidth = parseInt(getStyle(htmlDom, 'borderTopWidth')); | ||
| 361 | - if(browser.ie && !browser.isStrict){ | ||
| 362 | - pos.left -= isNaN(htmlBorderLeftWidth) ? 2 : htmlBorderLeftWidth; | ||
| 363 | - pos.top -= isNaN(htmlBorderTopWidth) ? 2 : htmlBorderTopWidth; | ||
| 364 | - } | ||
| 365 | - } else { | ||
| 366 | - // safari/opera/firefox | ||
| 367 | - parent = element; | ||
| 368 | - | ||
| 369 | - do { | ||
| 370 | - pos.left += parent.offsetLeft; | ||
| 371 | - pos.top += parent.offsetTop; | ||
| 372 | - | ||
| 373 | - // safari里面,如果遍历到了一个fixed的元素,后面的offset都不准了 | ||
| 374 | - if (browser.isWebkit > 0 && getStyle(parent, 'position') == 'fixed') { | ||
| 375 | - pos.left += doc.body.scrollLeft; | ||
| 376 | - pos.top += doc.body.scrollTop; | ||
| 377 | - break; | ||
| 378 | - } | ||
| 379 | - | ||
| 380 | - parent = parent.offsetParent; | ||
| 381 | - } while (parent && parent != element); | ||
| 382 | - | ||
| 383 | - // 对body offsetTop的修正 | ||
| 384 | - if(browser.opera > 0 || (browser.isWebkit > 0 && getStyle(element, 'position') == 'absolute')){ | ||
| 385 | - pos.top -= doc.body.offsetTop; | ||
| 386 | - } | ||
| 387 | - | ||
| 388 | - // 计算除了body的scroll | ||
| 389 | - parent = element.offsetParent; | ||
| 390 | - while (parent && parent != doc.body) { | ||
| 391 | - pos.left -= parent.scrollLeft; | ||
| 392 | - // see https://bugs.opera.com/show_bug.cgi?id=249965 | ||
| 393 | - if (!browser.opera || parent.tagName != 'TR') { | ||
| 394 | - pos.top -= parent.scrollTop; | ||
| 395 | - } | ||
| 396 | - parent = parent.offsetParent; | ||
| 397 | - } | ||
| 398 | - } | ||
| 399 | - | ||
| 400 | - return pos; | ||
| 401 | - }; | ||
| 402 | - | ||
| 403 | - /** | ||
| 404 | - * @ignore | ||
| 405 | - * @namespace baidu.event 屏蔽浏览器差异性的事件封装。 | ||
| 406 | - * @property target 事件的触发元素 | ||
| 407 | - * @property pageX 鼠标事件的鼠标x坐标 | ||
| 408 | - * @property pageY 鼠标事件的鼠标y坐标 | ||
| 409 | - * @property keyCode 键盘事件的键值 | ||
| 410 | - */ | ||
| 411 | - baidu.event = baidu.event || {}; | ||
| 412 | - | ||
| 413 | - /** | ||
| 414 | - * 事件监听器的存储表 | ||
| 415 | - * @private | ||
| 416 | - * @meta standard | ||
| 417 | - */ | ||
| 418 | - baidu.event._listeners = baidu.event._listeners || []; | ||
| 419 | - | ||
| 420 | - /** | ||
| 421 | - * 为目标元素添加事件监听器 | ||
| 422 | - * @name baidu.event.on | ||
| 423 | - * @function | ||
| 424 | - * @grammar baidu.event.on(element, type, listener) | ||
| 425 | - * @param {HTMLElement|string|window} element 目标元素或目标元素id | ||
| 426 | - * @param {string} type 事件类型 | ||
| 427 | - * @param {Function} listener 需要添加的监听器 | ||
| 428 | - * @remark | ||
| 429 | - * | ||
| 430 | - 1. 不支持跨浏览器的鼠标滚轮事件监听器添加<br> | ||
| 431 | - 2. 改方法不为监听器灌入事件对象,以防止跨iframe事件挂载的事件对象获取失败 | ||
| 432 | - | ||
| 433 | - * @shortcut on | ||
| 434 | - * @meta standard | ||
| 435 | - * @see baidu.event.un | ||
| 436 | - * | ||
| 437 | - * @returns {HTMLElement|window} 目标元素 | ||
| 438 | - */ | ||
| 439 | - baidu.event.on = function (element, type, listener) { | ||
| 440 | - type = type.replace(/^on/i, ''); | ||
| 441 | - element = baidu.dom._g(element); | ||
| 442 | - | ||
| 443 | - var realListener = function (ev) { | ||
| 444 | - // 1. 这里不支持EventArgument, 原因是跨frame的事件挂载 | ||
| 445 | - // 2. element是为了修正this | ||
| 446 | - listener.call(element, ev); | ||
| 447 | - }, | ||
| 448 | - lis = baidu.event._listeners, | ||
| 449 | - filter = baidu.event._eventFilter, | ||
| 450 | - afterFilter, | ||
| 451 | - realType = type; | ||
| 452 | - type = type.toLowerCase(); | ||
| 453 | - // filter过滤 | ||
| 454 | - if(filter && filter[type]){ | ||
| 455 | - afterFilter = filter[type](element, type, realListener); | ||
| 456 | - realType = afterFilter.type; | ||
| 457 | - realListener = afterFilter.listener; | ||
| 458 | - } | ||
| 459 | - | ||
| 460 | - // 事件监听器挂载 | ||
| 461 | - if (element.addEventListener) { | ||
| 462 | - element.addEventListener(realType, realListener, false); | ||
| 463 | - } else if (element.attachEvent) { | ||
| 464 | - element.attachEvent('on' + realType, realListener); | ||
| 465 | - } | ||
| 466 | - | ||
| 467 | - // 将监听器存储到数组中 | ||
| 468 | - lis[lis.length] = [element, type, listener, realListener, realType]; | ||
| 469 | - return element; | ||
| 470 | - }; | ||
| 471 | - | ||
| 472 | - // 声明快捷方法 | ||
| 473 | - baidu.on = baidu.event.on; | ||
| 474 | - | ||
| 475 | - /** | ||
| 476 | - * 返回一个当前页面的唯一标识字符串。 | ||
| 477 | - * @name baidu.lang.guid | ||
| 478 | - * @function | ||
| 479 | - * @grammar baidu.lang.guid() | ||
| 480 | - * @version 1.1.1 | ||
| 481 | - * @meta standard | ||
| 482 | - * | ||
| 483 | - * @returns {String} 当前页面的唯一标识字符串 | ||
| 484 | - */ | ||
| 485 | - | ||
| 486 | - (function(){ | ||
| 487 | - //不直接使用window,可以提高3倍左右性能 | ||
| 488 | - var guid = window[baidu.guid]; | ||
| 489 | - | ||
| 490 | - baidu.lang.guid = function() { | ||
| 491 | - return "TANGRAM__" + (guid._counter ++).toString(36); | ||
| 492 | - }; | ||
| 493 | - | ||
| 494 | - guid._counter = guid._counter || 1; | ||
| 495 | - })(); | ||
| 496 | - | ||
| 497 | - /** | ||
| 498 | - * 所有类的实例的容器 | ||
| 499 | - * key为每个实例的guid | ||
| 500 | - * @meta standard | ||
| 501 | - */ | ||
| 502 | - | ||
| 503 | - window[baidu.guid]._instances = window[baidu.guid]._instances || {}; | ||
| 504 | - | ||
| 505 | - /** | ||
| 506 | - * 判断目标参数是否为function或Function实例 | ||
| 507 | - * @name baidu.lang.isFunction | ||
| 508 | - * @function | ||
| 509 | - * @grammar baidu.lang.isFunction(source) | ||
| 510 | - * @param {Any} source 目标参数 | ||
| 511 | - * @version 1.2 | ||
| 512 | - * @see baidu.lang.isString,baidu.lang.isObject,baidu.lang.isNumber,baidu.lang.isArray,baidu.lang.isElement,baidu.lang.isBoolean,baidu.lang.isDate | ||
| 513 | - * @meta standard | ||
| 514 | - * @returns {boolean} 类型判断结果 | ||
| 515 | - */ | ||
| 516 | - baidu.lang.isFunction = function (source) { | ||
| 517 | - // chrome下,'function' == typeof /a/ 为true. | ||
| 518 | - return '[object Function]' == Object.prototype.toString.call(source); | ||
| 519 | - }; | ||
| 520 | - | ||
| 521 | - /** | ||
| 522 | - * | ||
| 523 | - * @ignore | ||
| 524 | - * @class Tangram继承机制提供的一个基类,用户可以通过继承baidu.lang.Class来获取它的属性及方法。 | ||
| 525 | - * @name baidu.lang.Class | ||
| 526 | - * @grammar baidu.lang.Class(guid) | ||
| 527 | - * @param {string} guid 对象的唯一标识 | ||
| 528 | - * @meta standard | ||
| 529 | - * @remark baidu.lang.Class和它的子类的实例均包含一个全局唯一的标识guid。guid是在构造函数中生成的,因此,继承自baidu.lang.Class的类应该直接或者间接调用它的构造函数。<br>baidu.lang.Class的构造函数中产生guid的方式可以保证guid的唯一性,及每个实例都有一个全局唯一的guid。 | ||
| 530 | - * @meta standard | ||
| 531 | - * @see baidu.lang.inherits,baidu.lang.Event | ||
| 532 | - */ | ||
| 533 | - baidu.lang.Class = function(guid) { | ||
| 534 | - this.guid = guid || baidu.lang.guid(); | ||
| 535 | - window[baidu.guid]._instances[this.guid] = this; | ||
| 536 | - }; | ||
| 537 | - window[baidu.guid]._instances = window[baidu.guid]._instances || {}; | ||
| 538 | - | ||
| 539 | - /** | ||
| 540 | - * 释放对象所持有的资源,主要是自定义事件。 | ||
| 541 | - * @name dispose | ||
| 542 | - * @grammar obj.dispose() | ||
| 543 | - */ | ||
| 544 | - baidu.lang.Class.prototype.dispose = function(){ | ||
| 545 | - delete window[baidu.guid]._instances[this.guid]; | ||
| 546 | - | ||
| 547 | - for(var property in this){ | ||
| 548 | - if (!baidu.lang.isFunction(this[property])) { | ||
| 549 | - delete this[property]; | ||
| 550 | - } | ||
| 551 | - } | ||
| 552 | - this.disposed = true; | ||
| 553 | - }; | ||
| 554 | - | ||
| 555 | - /** | ||
| 556 | - * 重载了默认的toString方法,使得返回信息更加准确一些。 | ||
| 557 | - * @return {string} 对象的String表示形式 | ||
| 558 | - */ | ||
| 559 | - baidu.lang.Class.prototype.toString = function(){ | ||
| 560 | - return "[object " + (this._className || "Object" ) + "]"; | ||
| 561 | - }; | ||
| 562 | - | ||
| 563 | - /** | ||
| 564 | - * @ignore | ||
| 565 | - * @class 自定义的事件对象。 | ||
| 566 | - * @name baidu.lang.Event | ||
| 567 | - * @grammar baidu.lang.Event(type[, target]) | ||
| 568 | - * @param {string} type 事件类型名称。为了方便区分事件和一个普通的方法,事件类型名称必须以"on"(小写)开头。 | ||
| 569 | - * @param {Object} [target]触发事件的对象 | ||
| 570 | - * @meta standard | ||
| 571 | - * @remark 引入该模块,会自动为Class引入3个事件扩展方法:addEventListener、removeEventListener和dispatchEvent。 | ||
| 572 | - * @meta standard | ||
| 573 | - * @see baidu.lang.Class | ||
| 574 | - */ | ||
| 575 | - baidu.lang.Event = function (type, target) { | ||
| 576 | - this.type = type; | ||
| 577 | - this.returnValue = true; | ||
| 578 | - this.target = target || null; | ||
| 579 | - this.currentTarget = null; | ||
| 580 | - }; | ||
| 581 | - | ||
| 582 | - /** | ||
| 583 | - * 注册对象的事件监听器。引入baidu.lang.Event后,Class的子类实例才会获得该方法。 | ||
| 584 | - * @grammar obj.addEventListener(type, handlers[, key]) | ||
| 585 | - * @param {string} type 自定义事件的名称 | ||
| 586 | - * @param {Function} handler 自定义事件被触发时应该调用的回调函数 | ||
| 587 | - * @param {string} [key] 为事件监听函数指定的名称,可在移除时使用。如果不提供,方法会默认为它生成一个全局唯一的key。 | ||
| 588 | - * @remark 事件类型区分大小写。如果自定义事件名称不是以小写"on"开头,该方法会给它加上"on"再进行判断,即"click"和"onclick"会被认为是同一种事件。 | ||
| 589 | - */ | ||
| 590 | - baidu.lang.Class.prototype.addEventListener = function (type, handler, key) { | ||
| 591 | - if (!baidu.lang.isFunction(handler)) { | ||
| 592 | - return; | ||
| 593 | - } | ||
| 594 | - | ||
| 595 | - !this.__listeners && (this.__listeners = {}); | ||
| 596 | - | ||
| 597 | - var t = this.__listeners, id; | ||
| 598 | - if (typeof key == "string" && key) { | ||
| 599 | - if (/[^\w\-]/.test(key)) { | ||
| 600 | - throw("nonstandard key:" + key); | ||
| 601 | - } else { | ||
| 602 | - handler.hashCode = key; | ||
| 603 | - id = key; | ||
| 604 | - } | ||
| 605 | - } | ||
| 606 | - type.indexOf("on") != 0 && (type = "on" + type); | ||
| 607 | - | ||
| 608 | - typeof t[type] != "object" && (t[type] = {}); | ||
| 609 | - id = id || baidu.lang.guid(); | ||
| 610 | - handler.hashCode = id; | ||
| 611 | - t[type][id] = handler; | ||
| 612 | - }; | ||
| 613 | - | ||
| 614 | - /** | ||
| 615 | - * 移除对象的事件监听器。引入baidu.lang.Event后,Class的子类实例才会获得该方法。 | ||
| 616 | - * @grammar obj.removeEventListener(type, handlers) | ||
| 617 | - * @param {string} type 事件类型 | ||
| 618 | - * @param {Function|string} handler 要移除的事件监听函数或者监听函数的key | ||
| 619 | - * @remark 如果第二个参数handler没有被绑定到对应的自定义事件中,什么也不做。 | ||
| 620 | - */ | ||
| 621 | - baidu.lang.Class.prototype.removeEventListener = function (type, handler) { | ||
| 622 | - if (typeof handler != "undefined") { | ||
| 623 | - if ( (baidu.lang.isFunction(handler) && ! (handler = handler.hashCode)) | ||
| 624 | - || (! baidu.lang.isString(handler)) | ||
| 625 | - ){ | ||
| 626 | - return; | ||
| 627 | - } | ||
| 628 | - } | ||
| 629 | - | ||
| 630 | - !this.__listeners && (this.__listeners = {}); | ||
| 631 | - | ||
| 632 | - type.indexOf("on") != 0 && (type = "on" + type); | ||
| 633 | - | ||
| 634 | - var t = this.__listeners; | ||
| 635 | - if (!t[type]) { | ||
| 636 | - return; | ||
| 637 | - } | ||
| 638 | - if (typeof handler != "undefined") { | ||
| 639 | - t[type][handler] && delete t[type][handler]; | ||
| 640 | - } else { | ||
| 641 | - for(var guid in t[type]){ | ||
| 642 | - delete t[type][guid]; | ||
| 643 | - } | ||
| 644 | - } | ||
| 645 | - }; | ||
| 646 | - | ||
| 647 | - /** | ||
| 648 | - * 派发自定义事件,使得绑定到自定义事件上面的函数都会被执行。引入baidu.lang.Event后,Class的子类实例才会获得该方法。 | ||
| 649 | - * @grammar obj.dispatchEvent(event, options) | ||
| 650 | - * @param {baidu.lang.Event|String} event Event对象,或事件名称(1.1.1起支持) | ||
| 651 | - * @param {Object} options 扩展参数,所含属性键值会扩展到Event对象上(1.2起支持) | ||
| 652 | - * @remark 处理会调用通过addEventListenr绑定的自定义事件回调函数之外,还会调用直接绑定到对象上面的自定义事件。例如:<br> | ||
| 653 | - myobj.onMyEvent = function(){}<br> | ||
| 654 | - myobj.addEventListener("onMyEvent", function(){}); | ||
| 655 | - */ | ||
| 656 | - baidu.lang.Class.prototype.dispatchEvent = function (event, options) { | ||
| 657 | - if (baidu.lang.isString(event)) { | ||
| 658 | - event = new baidu.lang.Event(event); | ||
| 659 | - } | ||
| 660 | - !this.__listeners && (this.__listeners = {}); | ||
| 661 | - | ||
| 662 | - // 20100603 添加本方法的第二个参数,将 options extend到event中去传递 | ||
| 663 | - options = options || {}; | ||
| 664 | - for (var i in options) { | ||
| 665 | - event[i] = options[i]; | ||
| 666 | - } | ||
| 667 | - | ||
| 668 | - var i, t = this.__listeners, p = event.type; | ||
| 669 | - event.target = event.target || this; | ||
| 670 | - event.currentTarget = this; | ||
| 671 | - | ||
| 672 | - p.indexOf("on") != 0 && (p = "on" + p); | ||
| 673 | - | ||
| 674 | - baidu.lang.isFunction(this[p]) && this[p].apply(this, arguments); | ||
| 675 | - | ||
| 676 | - if (typeof t[p] == "object") { | ||
| 677 | - for (i in t[p]) { | ||
| 678 | - t[p][i].apply(this, arguments); | ||
| 679 | - } | ||
| 680 | - } | ||
| 681 | - return event.returnValue; | ||
| 682 | - }; | ||
| 683 | - | ||
| 684 | - | ||
| 685 | - baidu.lang.inherits = function (subClass, superClass, className) { | ||
| 686 | - var key, proto, | ||
| 687 | - selfProps = subClass.prototype, | ||
| 688 | - clazz = new Function(); | ||
| 689 | - | ||
| 690 | - clazz.prototype = superClass.prototype; | ||
| 691 | - proto = subClass.prototype = new clazz(); | ||
| 692 | - for (key in selfProps) { | ||
| 693 | - proto[key] = selfProps[key]; | ||
| 694 | - } | ||
| 695 | - subClass.prototype.constructor = subClass; | ||
| 696 | - subClass.superClass = superClass.prototype; | ||
| 697 | - | ||
| 698 | - // 类名标识,兼容Class的toString,基本没用 | ||
| 699 | - if ("string" == typeof className) { | ||
| 700 | - proto._className = className; | ||
| 701 | - } | ||
| 702 | - }; | ||
| 703 | - // 声明快捷方法 | ||
| 704 | - baidu.inherits = baidu.lang.inherits; | ||
| 705 | - })(); | ||
| 706 | - | ||
| 707 | - | ||
| 708 | - /** | ||
| 709 | - | ||
| 710 | - * 图片的路径 | ||
| 711 | - | ||
| 712 | - * @private | ||
| 713 | - * @type {String} | ||
| 714 | - | ||
| 715 | - */ | ||
| 716 | - var _IMAGE_PATH = 'http://api.map.baidu.com/library/TextIconOverlay/1.2/src/images/m'; | ||
| 717 | - | ||
| 718 | - /** | ||
| 719 | - | ||
| 720 | - * 图片的后缀名 | ||
| 721 | - | ||
| 722 | - * @private | ||
| 723 | - * @type {String} | ||
| 724 | - | ||
| 725 | - */ | ||
| 726 | - var _IMAGE_EXTENSION = 'png'; | ||
| 727 | - | ||
| 728 | - /** | ||
| 729 | - *@exports TextIconOverlay as BMapLib.TextIconOverlay | ||
| 730 | - */ | ||
| 731 | - var TextIconOverlay = | ||
| 732 | - /** | ||
| 733 | - * TextIconOverlay | ||
| 734 | - * @class 此类表示地图上的一个覆盖物,该覆盖物由文字和图标组成,从Overlay继承。文字通常是数字(0-9)或字母(A-Z ),而文字与图标之间有一定的映射关系。 | ||
| 735 | - *该覆盖物适用于以下类似的场景:需要在地图上添加一系列覆盖物,这些覆盖物之间用不同的图标和文字来区分,文字可能表示了该覆盖物的某一属性值,根据该文字和一定的映射关系,自动匹配相应颜色和大小的图标。 | ||
| 736 | - * | ||
| 737 | - *@constructor | ||
| 738 | - *@param {Point} position 表示一个经纬度坐标位置。 | ||
| 739 | - *@param {String} text 表示该覆盖物显示的文字信息。 | ||
| 740 | - *@param {Json Object} options 可选参数,可选项包括:<br /> | ||
| 741 | - *"<b>styles</b>":{Array<IconStyle>} 一组图标风格。单个图表风格包括以下几个属性:<br /> | ||
| 742 | - * url {String} 图片的url地址。(必选)<br /> | ||
| 743 | - * size {Size} 图片的大小。(必选)<br /> | ||
| 744 | - * anchor {Size} 图标定位在地图上的位置相对于图标左上角的偏移值,默认偏移值为图标的中心位置。(可选)<br /> | ||
| 745 | - * offset {Size} 图片相对于可视区域的偏移值,此功能的作用等同于CSS中的background-position属性。(可选)<br /> | ||
| 746 | - * textSize {Number} 文字的大小。(可选,默认10)<br /> | ||
| 747 | - * textColor {String} 文字的颜色。(可选,默认black)<br /> | ||
| 748 | - */ | ||
| 749 | - BMapLib.TextIconOverlay = function(position, text, options){ | ||
| 750 | - this._position = position; | ||
| 751 | - this._text = text; | ||
| 752 | - this._options = options || {}; | ||
| 753 | - this._styles = this._options['styles'] || []; | ||
| 754 | - (!this._styles.length) && this._setupDefaultStyles(); | ||
| 755 | - }; | ||
| 756 | - | ||
| 757 | - T.lang.inherits(TextIconOverlay, BMap.Overlay, "TextIconOverlay"); | ||
| 758 | - | ||
| 759 | - TextIconOverlay.prototype._setupDefaultStyles = function(){ | ||
| 760 | - var sizes = [53, 56, 66, 78, 90]; | ||
| 761 | - for(var i = 0, size; size = sizes[i]; i++){ | ||
| 762 | - this._styles.push({ | ||
| 763 | - url:_IMAGE_PATH + i + '.' + _IMAGE_EXTENSION, | ||
| 764 | - size: new BMap.Size(size, size) | ||
| 765 | - }); | ||
| 766 | - }//for循环的简洁写法 | ||
| 767 | - }; | ||
| 768 | - | ||
| 769 | - /** | ||
| 770 | - *继承Overlay的intialize方法,自定义覆盖物时必须。 | ||
| 771 | - *@param {Map} map BMap.Map的实例化对象。 | ||
| 772 | - *@return {HTMLElement} 返回覆盖物对应的HTML元素。 | ||
| 773 | - */ | ||
| 774 | - TextIconOverlay.prototype.initialize = function(map){ | ||
| 775 | - this._map = map; | ||
| 776 | - | ||
| 777 | - this._domElement = document.createElement('div'); | ||
| 778 | - this._updateCss(); | ||
| 779 | - this._updateText(); | ||
| 780 | - this._updatePosition(); | ||
| 781 | - | ||
| 782 | - this._bind(); | ||
| 783 | - | ||
| 784 | - this._map.getPanes().markerMouseTarget.appendChild(this._domElement); | ||
| 785 | - return this._domElement; | ||
| 786 | - }; | ||
| 787 | - | ||
| 788 | - /** | ||
| 789 | - *继承Overlay的draw方法,自定义覆盖物时必须。 | ||
| 790 | - *@return 无返回值。 | ||
| 791 | - */ | ||
| 792 | - TextIconOverlay.prototype.draw = function(){ | ||
| 793 | - this._map && this._updatePosition(); | ||
| 794 | - }; | ||
| 795 | - | ||
| 796 | - /** | ||
| 797 | - *获取该覆盖物上的文字。 | ||
| 798 | - *@return {String} 该覆盖物上的文字。 | ||
| 799 | - */ | ||
| 800 | - TextIconOverlay.prototype.getText = function(){ | ||
| 801 | - return this._text; | ||
| 802 | - }; | ||
| 803 | - | ||
| 804 | - /** | ||
| 805 | - *设置该覆盖物上的文字。 | ||
| 806 | - *@param {String} text 要设置的文字,通常是字母A-Z或数字0-9。 | ||
| 807 | - *@return 无返回值。 | ||
| 808 | - */ | ||
| 809 | - TextIconOverlay.prototype.setText = function(text){ | ||
| 810 | - if(text && (!this._text || (this._text.toString() != text.toString()))){ | ||
| 811 | - this._text = text; | ||
| 812 | - this._updateText(); | ||
| 813 | - this._updateCss(); | ||
| 814 | - this._updatePosition(); | ||
| 815 | - } | ||
| 816 | - }; | ||
| 817 | - | ||
| 818 | - /** | ||
| 819 | - *获取该覆盖物的位置。 | ||
| 820 | - *@return {Point} 该覆盖物的经纬度坐标。 | ||
| 821 | - */ | ||
| 822 | - TextIconOverlay.prototype.getPosition = function () { | ||
| 823 | - return this._position; | ||
| 824 | - }; | ||
| 825 | - | ||
| 826 | - /** | ||
| 827 | - *设置该覆盖物的位置。 | ||
| 828 | - *@param {Point} position 要设置的经纬度坐标。 | ||
| 829 | - *@return 无返回值。 | ||
| 830 | - */ | ||
| 831 | - TextIconOverlay.prototype.setPosition = function (position) { | ||
| 832 | - if(position && (!this._position || !this._position.equals(position))){ | ||
| 833 | - this._position = position; | ||
| 834 | - this._updatePosition(); | ||
| 835 | - } | ||
| 836 | - }; | ||
| 837 | - | ||
| 838 | - /** | ||
| 839 | - *由文字信息获取风格数组的对应索引值。 | ||
| 840 | - *内部默认的对应函数为文字转换为数字除以10的结果,比如文字8返回索引0,文字25返回索引2. | ||
| 841 | - *如果需要自定义映射关系,请覆盖该函数。 | ||
| 842 | - *@param {String} text 文字。 | ||
| 843 | - *@param {Array<IconStyle>} styles 一组图标风格。 | ||
| 844 | - *@return {Number} 对应的索引值。 | ||
| 845 | - */ | ||
| 846 | - TextIconOverlay.prototype.getStyleByText = function(text, styles){ | ||
| 847 | - var count = parseInt(text); | ||
| 848 | - var index = parseInt(count / 10); | ||
| 849 | - index = Math.max(0, index); | ||
| 850 | - index = Math.min(index, styles.length - 1); | ||
| 851 | - return styles[index]; | ||
| 852 | - } | ||
| 853 | - | ||
| 854 | - /** | ||
| 855 | - *更新相应的CSS。 | ||
| 856 | - *@return 无返回值。 | ||
| 857 | - */ | ||
| 858 | - TextIconOverlay.prototype._updateCss = function(){ | ||
| 859 | - var style = this.getStyleByText(this._text, this._styles); | ||
| 860 | - this._domElement.style.cssText = this._buildCssText(style); | ||
| 861 | - }; | ||
| 862 | - | ||
| 863 | - /** | ||
| 864 | - *更新覆盖物的显示文字。 | ||
| 865 | - *@return 无返回值。 | ||
| 866 | - */ | ||
| 867 | - TextIconOverlay.prototype._updateText = function(){ | ||
| 868 | - if (this._domElement) { | ||
| 869 | - this._domElement.innerHTML = this._text; | ||
| 870 | - } | ||
| 871 | - }; | ||
| 872 | - | ||
| 873 | - /** | ||
| 874 | - *调整覆盖物在地图上的位置更新覆盖物的显示文字。 | ||
| 875 | - *@return 无返回值。 | ||
| 876 | - */ | ||
| 877 | - TextIconOverlay.prototype._updatePosition = function(){ | ||
| 878 | - if (this._domElement && this._position) { | ||
| 879 | - var style = this._domElement.style; | ||
| 880 | - var pixelPosition= this._map.pointToOverlayPixel(this._position); | ||
| 881 | - pixelPosition.x -= Math.ceil(parseInt(style.width) / 2); | ||
| 882 | - pixelPosition.y -= Math.ceil(parseInt(style.height) / 2); | ||
| 883 | - style.left = pixelPosition.x + "px"; | ||
| 884 | - style.top = pixelPosition.y + "px"; | ||
| 885 | - } | ||
| 886 | - }; | ||
| 887 | - | ||
| 888 | - /** | ||
| 889 | - * 为该覆盖物的HTML元素构建CSS | ||
| 890 | - * @param {IconStyle} 一个图标的风格。 | ||
| 891 | - * @return {String} 构建完成的CSSTEXT。 | ||
| 892 | - */ | ||
| 893 | - TextIconOverlay.prototype._buildCssText = function(style) { | ||
| 894 | - //根据style来确定一些默认值 | ||
| 895 | - var url = style['url']; | ||
| 896 | - var size = style['size']; | ||
| 897 | - var anchor = style['anchor']; | ||
| 898 | - var offset = style['offset']; | ||
| 899 | - var textColor = style['textColor'] || 'black'; | ||
| 900 | - var textSize = style['textSize'] || 10; | ||
| 901 | - | ||
| 902 | - var csstext = []; | ||
| 903 | - if (T.browser["ie"] < 7) { | ||
| 904 | - csstext.push('filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(' + | ||
| 905 | - 'sizingMethod=scale,src="' + url + '");'); | ||
| 906 | - } else { | ||
| 907 | - csstext.push('background-image:url(' + url + ');'); | ||
| 908 | - var backgroundPosition = '0 0'; | ||
| 909 | - (offset instanceof BMap.Size) && (backgroundPosition = offset.width + 'px' + ' ' + offset.height + 'px'); | ||
| 910 | - csstext.push('background-position:' + backgroundPosition + ';'); | ||
| 911 | - } | ||
| 912 | - | ||
| 913 | - if (size instanceof BMap.Size){ | ||
| 914 | - if (anchor instanceof BMap.Size) { | ||
| 915 | - if (anchor.height > 0 && anchor.height < size.height) { | ||
| 916 | - csstext.push('height:' + (size.height - anchor.height) + 'px; padding-top:' + anchor.height + 'px;'); | ||
| 917 | - } | ||
| 918 | - if(anchor.width > 0 && anchor.width < size.width){ | ||
| 919 | - csstext.push('width:' + (size.width - anchor.width) + 'px; padding-left:' + anchor.width + 'px;'); | ||
| 920 | - } | ||
| 921 | - } else { | ||
| 922 | - csstext.push('height:' + size.height + 'px; line-height:' + size.height + 'px;'); | ||
| 923 | - csstext.push('width:' + size.width + 'px; text-align:center;'); | ||
| 924 | - } | ||
| 925 | - } | ||
| 926 | - | ||
| 927 | - csstext.push('cursor:pointer; color:' + textColor + '; position:absolute; font-size:' + | ||
| 928 | - textSize + 'px; font-family:Arial,sans-serif; font-weight:bold'); | ||
| 929 | - return csstext.join(''); | ||
| 930 | - }; | ||
| 931 | - | ||
| 932 | - | ||
| 933 | - /** | ||
| 934 | - | ||
| 935 | - * 当鼠标点击该覆盖物时会触发该事件 | ||
| 936 | - | ||
| 937 | - * @name TextIconOverlay#click | ||
| 938 | - | ||
| 939 | - * @event | ||
| 940 | - | ||
| 941 | - * @param {Event Object} e 回调函数会返回event参数,包括以下返回值: | ||
| 942 | - | ||
| 943 | - * <br />"<b>type</b> : {String} 事件类型 | ||
| 944 | - | ||
| 945 | - * <br />"<b>target</b>:{BMapLib.TextIconOverlay} 事件目标 | ||
| 946 | - | ||
| 947 | - * | ||
| 948 | - | ||
| 949 | - */ | ||
| 950 | - | ||
| 951 | - /** | ||
| 952 | - | ||
| 953 | - * 当鼠标进入该覆盖物区域时会触发该事件 | ||
| 954 | - | ||
| 955 | - * @name TextIconOverlay#mouseover | ||
| 956 | - | ||
| 957 | - * @event | ||
| 958 | - * @param {Event Object} e 回调函数会返回event参数,包括以下返回值: | ||
| 959 | - | ||
| 960 | - * <br />"<b>type</b> : {String} 事件类型 | ||
| 961 | - | ||
| 962 | - * <br />"<b>target</b>:{BMapLib.TextIconOverlay} 事件目标 | ||
| 963 | - | ||
| 964 | - * <br />"<b>point</b> : {BMap.Point} 最新添加上的节点BMap.Point对象 | ||
| 965 | - | ||
| 966 | - * <br />"<b>pixel</b>:{BMap.pixel} 最新添加上的节点BMap.Pixel对象 | ||
| 967 | - | ||
| 968 | - * | ||
| 969 | - | ||
| 970 | - * @example <b>参考示例:</b><br /> | ||
| 971 | - | ||
| 972 | - * myTextIconOverlay.addEventListener("mouseover", function(e) { alert(e.point); }); | ||
| 973 | - | ||
| 974 | - */ | ||
| 975 | - | ||
| 976 | - /** | ||
| 977 | - | ||
| 978 | - * 当鼠标离开该覆盖物区域时会触发该事件 | ||
| 979 | - | ||
| 980 | - * @name TextIconOverlay#mouseout | ||
| 981 | - | ||
| 982 | - * @event | ||
| 983 | - | ||
| 984 | - * @param {Event Object} e 回调函数会返回event参数,包括以下返回值: | ||
| 985 | - | ||
| 986 | - * <br />"<b>type</b> : {String} 事件类型 | ||
| 987 | - | ||
| 988 | - * <br />"<b>target</b>:{BMapLib.TextIconOverlay} 事件目标 | ||
| 989 | - | ||
| 990 | - * <br />"<b>point</b> : {BMap.Point} 最新添加上的节点BMap.Point对象 | ||
| 991 | - | ||
| 992 | - * <br />"<b>pixel</b>:{BMap.pixel} 最新添加上的节点BMap.Pixel对象 | ||
| 993 | - | ||
| 994 | - * | ||
| 995 | - | ||
| 996 | - * @example <b>参考示例:</b><br /> | ||
| 997 | - | ||
| 998 | - * myTextIconOverlay.addEventListener("mouseout", function(e) { alert(e.point); }); | ||
| 999 | - | ||
| 1000 | - */ | ||
| 1001 | - | ||
| 1002 | - | ||
| 1003 | - /** | ||
| 1004 | - * 为该覆盖物绑定一系列事件 | ||
| 1005 | - * 当前支持click mouseover mouseout | ||
| 1006 | - * @return 无返回值。 | ||
| 1007 | - */ | ||
| 1008 | - TextIconOverlay.prototype._bind = function(){ | ||
| 1009 | - if (!this._domElement){ | ||
| 1010 | - return; | ||
| 1011 | - } | ||
| 1012 | - | ||
| 1013 | - var me = this; | ||
| 1014 | - var map = this._map; | ||
| 1015 | - | ||
| 1016 | - var BaseEvent = T.lang.Event; | ||
| 1017 | - function eventExtend(e, be){ | ||
| 1018 | - var elem = e.srcElement || e.target; | ||
| 1019 | - var x = e.clientX || e.pageX; | ||
| 1020 | - var y = e.clientY || e.pageY; | ||
| 1021 | - if (e && be && x && y && elem){ | ||
| 1022 | - var offset = T.dom.getPosition(map.getContainer()); | ||
| 1023 | - be.pixel = new BMap.Pixel(x - offset.left, y - offset.top); | ||
| 1024 | - be.point = map.pixelToPoint(be.pixel); | ||
| 1025 | - } | ||
| 1026 | - return be; | ||
| 1027 | - }//给事件参数增加pixel和point两个值 | ||
| 1028 | - | ||
| 1029 | - T.event.on(this._domElement,"mouseover", function(e){ | ||
| 1030 | - me.dispatchEvent(eventExtend(e, new BaseEvent("onmouseover"))); | ||
| 1031 | - }); | ||
| 1032 | - T.event.on(this._domElement,"mouseout", function(e){ | ||
| 1033 | - me.dispatchEvent(eventExtend(e, new BaseEvent("onmouseout"))); | ||
| 1034 | - }); | ||
| 1035 | - T.event.on(this._domElement,"click", function(e){ | ||
| 1036 | - me.dispatchEvent(eventExtend(e, new BaseEvent("onclick"))); | ||
| 1037 | - }); | ||
| 1038 | - }; | ||
| 1039 | - | 1 | +/** |
| 2 | + * @fileoverview 此类表示地图上的一个覆盖物,该覆盖物由文字和图标组成,从Overlay继承。 | ||
| 3 | + * 主入口类是<a href="symbols/BMapLib.TextIconOverlay.html">TextIconOverlay</a>, | ||
| 4 | + * 基于Baidu Map API 1.2。 | ||
| 5 | + * | ||
| 6 | + * @author Baidu Map Api Group | ||
| 7 | + * @version 1.2 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | + | ||
| 11 | + /** | ||
| 12 | + * @namespace BMap的所有library类均放在BMapLib命名空间下 | ||
| 13 | + */ | ||
| 14 | +var BMapLib = window.BMapLib = BMapLib || {}; | ||
| 15 | + | ||
| 16 | +(function () { | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * 声明baidu包 | ||
| 20 | + */ | ||
| 21 | + var T, | ||
| 22 | + baidu = T = baidu || {version: "1.3.8"}; | ||
| 23 | + | ||
| 24 | + (function (){ | ||
| 25 | + //提出guid,防止在与老版本Tangram混用时 | ||
| 26 | + //在下一行错误的修改window[undefined] | ||
| 27 | + baidu.guid = "$BAIDU$"; | ||
| 28 | + | ||
| 29 | + //Tangram可能被放在闭包中 | ||
| 30 | + //一些页面级别唯一的属性,需要挂载在window[baidu.guid]上 | ||
| 31 | + window[baidu.guid] = window[baidu.guid] || {}; | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * @ignore | ||
| 35 | + * @namespace baidu.dom 操作dom的方法。 | ||
| 36 | + */ | ||
| 37 | + baidu.dom = baidu.dom || {}; | ||
| 38 | + | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * 从文档中获取指定的DOM元素 | ||
| 42 | + * @name baidu.dom.g | ||
| 43 | + * @function | ||
| 44 | + * @grammar baidu.dom.g(id) | ||
| 45 | + * @param {string|HTMLElement} id 元素的id或DOM元素 | ||
| 46 | + * @shortcut g,T.G | ||
| 47 | + * @meta standard | ||
| 48 | + * @see baidu.dom.q | ||
| 49 | + * | ||
| 50 | + * @returns {HTMLElement|null} 获取的元素,查找不到时返回null,如果参数不合法,直接返回参数 | ||
| 51 | + */ | ||
| 52 | + baidu.dom.g = function (id) { | ||
| 53 | + if ('string' == typeof id || id instanceof String) { | ||
| 54 | + return document.getElementById(id); | ||
| 55 | + } else if (id && id.nodeName && (id.nodeType == 1 || id.nodeType == 9)) { | ||
| 56 | + return id; | ||
| 57 | + } | ||
| 58 | + return null; | ||
| 59 | + }; | ||
| 60 | + | ||
| 61 | + // 声明快捷方法 | ||
| 62 | + baidu.g = baidu.G = baidu.dom.g; | ||
| 63 | + | ||
| 64 | + /** | ||
| 65 | + * 获取目标元素所属的document对象 | ||
| 66 | + * @name baidu.dom.getDocument | ||
| 67 | + * @function | ||
| 68 | + * @grammar baidu.dom.getDocument(element) | ||
| 69 | + * @param {HTMLElement|string} element 目标元素或目标元素的id | ||
| 70 | + * @meta standard | ||
| 71 | + * @see baidu.dom.getWindow | ||
| 72 | + * | ||
| 73 | + * @returns {HTMLDocument} 目标元素所属的document对象 | ||
| 74 | + */ | ||
| 75 | + baidu.dom.getDocument = function (element) { | ||
| 76 | + element = baidu.dom.g(element); | ||
| 77 | + return element.nodeType == 9 ? element : element.ownerDocument || element.document; | ||
| 78 | + }; | ||
| 79 | + | ||
| 80 | + /** | ||
| 81 | + * @ignore | ||
| 82 | + * @namespace baidu.lang 对语言层面的封装,包括类型判断、模块扩展、继承基类以及对象自定义事件的支持。 | ||
| 83 | + */ | ||
| 84 | + baidu.lang = baidu.lang || {}; | ||
| 85 | + | ||
| 86 | + /** | ||
| 87 | + * 判断目标参数是否string类型或String对象 | ||
| 88 | + * @name baidu.lang.isString | ||
| 89 | + * @function | ||
| 90 | + * @grammar baidu.lang.isString(source) | ||
| 91 | + * @param {Any} source 目标参数 | ||
| 92 | + * @shortcut isString | ||
| 93 | + * @meta standard | ||
| 94 | + * @see baidu.lang.isObject,baidu.lang.isNumber,baidu.lang.isArray,baidu.lang.isElement,baidu.lang.isBoolean,baidu.lang.isDate | ||
| 95 | + * | ||
| 96 | + * @returns {boolean} 类型判断结果 | ||
| 97 | + */ | ||
| 98 | + baidu.lang.isString = function (source) { | ||
| 99 | + return '[object String]' == Object.prototype.toString.call(source); | ||
| 100 | + }; | ||
| 101 | + | ||
| 102 | + // 声明快捷方法 | ||
| 103 | + baidu.isString = baidu.lang.isString; | ||
| 104 | + | ||
| 105 | + /** | ||
| 106 | + * 从文档中获取指定的DOM元素 | ||
| 107 | + * **内部方法** | ||
| 108 | + * | ||
| 109 | + * @param {string|HTMLElement} id 元素的id或DOM元素 | ||
| 110 | + * @meta standard | ||
| 111 | + * @return {HTMLElement} DOM元素,如果不存在,返回null,如果参数不合法,直接返回参数 | ||
| 112 | + */ | ||
| 113 | + baidu.dom._g = function (id) { | ||
| 114 | + if (baidu.lang.isString(id)) { | ||
| 115 | + return document.getElementById(id); | ||
| 116 | + } | ||
| 117 | + return id; | ||
| 118 | + }; | ||
| 119 | + | ||
| 120 | + // 声明快捷方法 | ||
| 121 | + baidu._g = baidu.dom._g; | ||
| 122 | + | ||
| 123 | + /** | ||
| 124 | + * @ignore | ||
| 125 | + * @namespace baidu.browser 判断浏览器类型和特性的属性。 | ||
| 126 | + */ | ||
| 127 | + baidu.browser = baidu.browser || {}; | ||
| 128 | + | ||
| 129 | + if (/msie (\d+\.\d)/i.test(navigator.userAgent)) { | ||
| 130 | + //IE 8下,以documentMode为准 | ||
| 131 | + //在百度模板中,可能会有$,防止冲突,将$1 写成 \x241 | ||
| 132 | + /** | ||
| 133 | + * 判断是否为ie浏览器 | ||
| 134 | + * @property ie ie版本号 | ||
| 135 | + * @grammar baidu.browser.ie | ||
| 136 | + * @meta standard | ||
| 137 | + * @shortcut ie | ||
| 138 | + * @see baidu.browser.firefox,baidu.browser.safari,baidu.browser.opera,baidu.browser.chrome,baidu.browser.maxthon | ||
| 139 | + */ | ||
| 140 | + baidu.browser.ie = baidu.ie = document.documentMode || + RegExp['\x241']; | ||
| 141 | + } | ||
| 142 | + | ||
| 143 | + /** | ||
| 144 | + * 获取目标元素的computed style值。如果元素的样式值不能被浏览器计算,则会返回空字符串(IE) | ||
| 145 | + * | ||
| 146 | + * @author berg | ||
| 147 | + * @name baidu.dom.getComputedStyle | ||
| 148 | + * @function | ||
| 149 | + * @grammar baidu.dom.getComputedStyle(element, key) | ||
| 150 | + * @param {HTMLElement|string} element 目标元素或目标元素的id | ||
| 151 | + * @param {string} key 要获取的样式名 | ||
| 152 | + * | ||
| 153 | + * @see baidu.dom.getStyle | ||
| 154 | + * | ||
| 155 | + * @returns {string} 目标元素的computed style值 | ||
| 156 | + */ | ||
| 157 | + | ||
| 158 | + baidu.dom.getComputedStyle = function(element, key){ | ||
| 159 | + element = baidu.dom._g(element); | ||
| 160 | + var doc = baidu.dom.getDocument(element), | ||
| 161 | + styles; | ||
| 162 | + if (doc.defaultView && doc.defaultView.getComputedStyle) { | ||
| 163 | + styles = doc.defaultView.getComputedStyle(element, null); | ||
| 164 | + if (styles) { | ||
| 165 | + return styles[key] || styles.getPropertyValue(key); | ||
| 166 | + } | ||
| 167 | + } | ||
| 168 | + return ''; | ||
| 169 | + }; | ||
| 170 | + | ||
| 171 | + /** | ||
| 172 | + * 提供给setStyle与getStyle使用 | ||
| 173 | + */ | ||
| 174 | + baidu.dom._styleFixer = baidu.dom._styleFixer || {}; | ||
| 175 | + | ||
| 176 | + /** | ||
| 177 | + * 提供给setStyle与getStyle使用 | ||
| 178 | + */ | ||
| 179 | + baidu.dom._styleFilter = baidu.dom._styleFilter || []; | ||
| 180 | + | ||
| 181 | + /** | ||
| 182 | + * 为获取和设置样式的过滤器 | ||
| 183 | + * @private | ||
| 184 | + * @meta standard | ||
| 185 | + */ | ||
| 186 | + baidu.dom._styleFilter.filter = function (key, value, method) { | ||
| 187 | + for (var i = 0, filters = baidu.dom._styleFilter, filter; filter = filters[i]; i++) { | ||
| 188 | + if (filter = filter[method]) { | ||
| 189 | + value = filter(key, value); | ||
| 190 | + } | ||
| 191 | + } | ||
| 192 | + return value; | ||
| 193 | + }; | ||
| 194 | + | ||
| 195 | + /** | ||
| 196 | + * @ignore | ||
| 197 | + * @namespace baidu.string 操作字符串的方法。 | ||
| 198 | + */ | ||
| 199 | + baidu.string = baidu.string || {}; | ||
| 200 | + | ||
| 201 | + /** | ||
| 202 | + * 将目标字符串进行驼峰化处理 | ||
| 203 | + * @name baidu.string.toCamelCase | ||
| 204 | + * @function | ||
| 205 | + * @grammar baidu.string.toCamelCase(source) | ||
| 206 | + * @param {string} source 目标字符串 | ||
| 207 | + * @remark | ||
| 208 | + * 支持单词以“-_”分隔 | ||
| 209 | + * @meta standard | ||
| 210 | + * | ||
| 211 | + * @returns {string} 驼峰化处理后的字符串 | ||
| 212 | + */ | ||
| 213 | + baidu.string.toCamelCase = function (source) { | ||
| 214 | + //提前判断,提高getStyle等的效率 thanks xianwei | ||
| 215 | + if (source.indexOf('-') < 0 && source.indexOf('_') < 0) { | ||
| 216 | + return source; | ||
| 217 | + } | ||
| 218 | + return source.replace(/[-_][^-_]/g, function (match) { | ||
| 219 | + return match.charAt(1).toUpperCase(); | ||
| 220 | + }); | ||
| 221 | + }; | ||
| 222 | + | ||
| 223 | + /** | ||
| 224 | + * 获取目标元素的样式值 | ||
| 225 | + * @name baidu.dom.getStyle | ||
| 226 | + * @function | ||
| 227 | + * @grammar baidu.dom.getStyle(element, key) | ||
| 228 | + * @param {HTMLElement|string} element 目标元素或目标元素的id | ||
| 229 | + * @param {string} key 要获取的样式名 | ||
| 230 | + * @remark | ||
| 231 | + * | ||
| 232 | + * 为了精简代码,本模块默认不对任何浏览器返回值进行归一化处理(如使用getStyle时,不同浏览器下可能返回rgb颜色或hex颜色),也不会修复浏览器的bug和差异性(如设置IE的float属性叫styleFloat,firefox则是cssFloat)。<br /> | ||
| 233 | + * baidu.dom._styleFixer和baidu.dom._styleFilter可以为本模块提供支持。<br /> | ||
| 234 | + * 其中_styleFilter能对颜色和px进行归一化处理,_styleFixer能对display,float,opacity,textOverflow的浏览器兼容性bug进行处理。 | ||
| 235 | + * @shortcut getStyle | ||
| 236 | + * @meta standard | ||
| 237 | + * @see baidu.dom.setStyle,baidu.dom.setStyles, baidu.dom.getComputedStyle | ||
| 238 | + * | ||
| 239 | + * @returns {string} 目标元素的样式值 | ||
| 240 | + */ | ||
| 241 | + baidu.dom.getStyle = function (element, key) { | ||
| 242 | + var dom = baidu.dom; | ||
| 243 | + | ||
| 244 | + element = dom.g(element); | ||
| 245 | + key = baidu.string.toCamelCase(key); | ||
| 246 | + //computed style, then cascaded style, then explicitly set style. | ||
| 247 | + var value = element.style[key] || | ||
| 248 | + (element.currentStyle ? element.currentStyle[key] : "") || | ||
| 249 | + dom.getComputedStyle(element, key); | ||
| 250 | + | ||
| 251 | + // 在取不到值的时候,用fixer进行修正 | ||
| 252 | + if (!value) { | ||
| 253 | + var fixer = dom._styleFixer[key]; | ||
| 254 | + if(fixer){ | ||
| 255 | + value = fixer.get ? fixer.get(element) : baidu.dom.getStyle(element, fixer); | ||
| 256 | + } | ||
| 257 | + } | ||
| 258 | + | ||
| 259 | + /* 检查结果过滤器 */ | ||
| 260 | + if (fixer = dom._styleFilter) { | ||
| 261 | + value = fixer.filter(key, value, 'get'); | ||
| 262 | + } | ||
| 263 | + | ||
| 264 | + return value; | ||
| 265 | + }; | ||
| 266 | + | ||
| 267 | + // 声明快捷方法 | ||
| 268 | + baidu.getStyle = baidu.dom.getStyle; | ||
| 269 | + | ||
| 270 | + | ||
| 271 | + if (/opera\/(\d+\.\d)/i.test(navigator.userAgent)) { | ||
| 272 | + /** | ||
| 273 | + * 判断是否为opera浏览器 | ||
| 274 | + * @property opera opera版本号 | ||
| 275 | + * @grammar baidu.browser.opera | ||
| 276 | + * @meta standard | ||
| 277 | + * @see baidu.browser.ie,baidu.browser.firefox,baidu.browser.safari,baidu.browser.chrome | ||
| 278 | + */ | ||
| 279 | + baidu.browser.opera = + RegExp['\x241']; | ||
| 280 | + } | ||
| 281 | + | ||
| 282 | + /** | ||
| 283 | + * 判断是否为webkit内核 | ||
| 284 | + * @property isWebkit | ||
| 285 | + * @grammar baidu.browser.isWebkit | ||
| 286 | + * @meta standard | ||
| 287 | + * @see baidu.browser.isGecko | ||
| 288 | + */ | ||
| 289 | + baidu.browser.isWebkit = /webkit/i.test(navigator.userAgent); | ||
| 290 | + | ||
| 291 | + /** | ||
| 292 | + * 判断是否为gecko内核 | ||
| 293 | + * @property isGecko | ||
| 294 | + * @grammar baidu.browser.isGecko | ||
| 295 | + * @meta standard | ||
| 296 | + * @see baidu.browser.isWebkit | ||
| 297 | + */ | ||
| 298 | + baidu.browser.isGecko = /gecko/i.test(navigator.userAgent) && !/like gecko/i.test(navigator.userAgent); | ||
| 299 | + | ||
| 300 | + /** | ||
| 301 | + * 判断是否严格标准的渲染模式 | ||
| 302 | + * @property isStrict | ||
| 303 | + * @grammar baidu.browser.isStrict | ||
| 304 | + * @meta standard | ||
| 305 | + */ | ||
| 306 | + baidu.browser.isStrict = document.compatMode == "CSS1Compat"; | ||
| 307 | + | ||
| 308 | + /** | ||
| 309 | + * 获取目标元素相对于整个文档左上角的位置 | ||
| 310 | + * @name baidu.dom.getPosition | ||
| 311 | + * @function | ||
| 312 | + * @grammar baidu.dom.getPosition(element) | ||
| 313 | + * @param {HTMLElement|string} element 目标元素或目标元素的id | ||
| 314 | + * @meta standard | ||
| 315 | + * | ||
| 316 | + * @returns {Object} 目标元素的位置,键值为top和left的Object。 | ||
| 317 | + */ | ||
| 318 | + baidu.dom.getPosition = function (element) { | ||
| 319 | + element = baidu.dom.g(element); | ||
| 320 | + var doc = baidu.dom.getDocument(element), | ||
| 321 | + browser = baidu.browser, | ||
| 322 | + getStyle = baidu.dom.getStyle, | ||
| 323 | + // Gecko 1.9版本以下用getBoxObjectFor计算位置 | ||
| 324 | + // 但是某些情况下是有bug的 | ||
| 325 | + // 对于这些有bug的情况 | ||
| 326 | + // 使用递归查找的方式 | ||
| 327 | + BUGGY_GECKO_BOX_OBJECT = browser.isGecko > 0 && | ||
| 328 | + doc.getBoxObjectFor && | ||
| 329 | + getStyle(element, 'position') == 'absolute' && | ||
| 330 | + (element.style.top === '' || element.style.left === ''), | ||
| 331 | + pos = {"left":0,"top":0}, | ||
| 332 | + viewport = (browser.ie && !browser.isStrict) ? doc.body : doc.documentElement, | ||
| 333 | + parent, | ||
| 334 | + box; | ||
| 335 | + | ||
| 336 | + if(element == viewport){ | ||
| 337 | + return pos; | ||
| 338 | + } | ||
| 339 | + | ||
| 340 | + if(element.getBoundingClientRect){ // IE and Gecko 1.9+ | ||
| 341 | + | ||
| 342 | + //当HTML或者BODY有border width时, 原生的getBoundingClientRect返回值是不符合预期的 | ||
| 343 | + //考虑到通常情况下 HTML和BODY的border只会设成0px,所以忽略该问题. | ||
| 344 | + box = element.getBoundingClientRect(); | ||
| 345 | + | ||
| 346 | + pos.left = Math.floor(box.left) + Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft); | ||
| 347 | + pos.top = Math.floor(box.top) + Math.max(doc.documentElement.scrollTop, doc.body.scrollTop); | ||
| 348 | + | ||
| 349 | + // IE会给HTML元素添加一个border,默认是medium(2px) | ||
| 350 | + // 但是在IE 6 7 的怪异模式下,可以被html { border: 0; } 这条css规则覆盖 | ||
| 351 | + // 在IE7的标准模式下,border永远是2px,这个值通过clientLeft 和 clientTop取得 | ||
| 352 | + // 但是。。。在IE 6 7的怪异模式,如果用户使用css覆盖了默认的medium | ||
| 353 | + // clientTop和clientLeft不会更新 | ||
| 354 | + pos.left -= doc.documentElement.clientLeft; | ||
| 355 | + pos.top -= doc.documentElement.clientTop; | ||
| 356 | + | ||
| 357 | + var htmlDom = doc.body, | ||
| 358 | + // 在这里,不使用element.style.borderLeftWidth,只有computedStyle是可信的 | ||
| 359 | + htmlBorderLeftWidth = parseInt(getStyle(htmlDom, 'borderLeftWidth')), | ||
| 360 | + htmlBorderTopWidth = parseInt(getStyle(htmlDom, 'borderTopWidth')); | ||
| 361 | + if(browser.ie && !browser.isStrict){ | ||
| 362 | + pos.left -= isNaN(htmlBorderLeftWidth) ? 2 : htmlBorderLeftWidth; | ||
| 363 | + pos.top -= isNaN(htmlBorderTopWidth) ? 2 : htmlBorderTopWidth; | ||
| 364 | + } | ||
| 365 | + } else { | ||
| 366 | + // safari/opera/firefox | ||
| 367 | + parent = element; | ||
| 368 | + | ||
| 369 | + do { | ||
| 370 | + pos.left += parent.offsetLeft; | ||
| 371 | + pos.top += parent.offsetTop; | ||
| 372 | + | ||
| 373 | + // safari里面,如果遍历到了一个fixed的元素,后面的offset都不准了 | ||
| 374 | + if (browser.isWebkit > 0 && getStyle(parent, 'position') == 'fixed') { | ||
| 375 | + pos.left += doc.body.scrollLeft; | ||
| 376 | + pos.top += doc.body.scrollTop; | ||
| 377 | + break; | ||
| 378 | + } | ||
| 379 | + | ||
| 380 | + parent = parent.offsetParent; | ||
| 381 | + } while (parent && parent != element); | ||
| 382 | + | ||
| 383 | + // 对body offsetTop的修正 | ||
| 384 | + if(browser.opera > 0 || (browser.isWebkit > 0 && getStyle(element, 'position') == 'absolute')){ | ||
| 385 | + pos.top -= doc.body.offsetTop; | ||
| 386 | + } | ||
| 387 | + | ||
| 388 | + // 计算除了body的scroll | ||
| 389 | + parent = element.offsetParent; | ||
| 390 | + while (parent && parent != doc.body) { | ||
| 391 | + pos.left -= parent.scrollLeft; | ||
| 392 | + // see https://bugs.opera.com/show_bug.cgi?id=249965 | ||
| 393 | + if (!browser.opera || parent.tagName != 'TR') { | ||
| 394 | + pos.top -= parent.scrollTop; | ||
| 395 | + } | ||
| 396 | + parent = parent.offsetParent; | ||
| 397 | + } | ||
| 398 | + } | ||
| 399 | + | ||
| 400 | + return pos; | ||
| 401 | + }; | ||
| 402 | + | ||
| 403 | + /** | ||
| 404 | + * @ignore | ||
| 405 | + * @namespace baidu.event 屏蔽浏览器差异性的事件封装。 | ||
| 406 | + * @property target 事件的触发元素 | ||
| 407 | + * @property pageX 鼠标事件的鼠标x坐标 | ||
| 408 | + * @property pageY 鼠标事件的鼠标y坐标 | ||
| 409 | + * @property keyCode 键盘事件的键值 | ||
| 410 | + */ | ||
| 411 | + baidu.event = baidu.event || {}; | ||
| 412 | + | ||
| 413 | + /** | ||
| 414 | + * 事件监听器的存储表 | ||
| 415 | + * @private | ||
| 416 | + * @meta standard | ||
| 417 | + */ | ||
| 418 | + baidu.event._listeners = baidu.event._listeners || []; | ||
| 419 | + | ||
| 420 | + /** | ||
| 421 | + * 为目标元素添加事件监听器 | ||
| 422 | + * @name baidu.event.on | ||
| 423 | + * @function | ||
| 424 | + * @grammar baidu.event.on(element, type, listener) | ||
| 425 | + * @param {HTMLElement|string|window} element 目标元素或目标元素id | ||
| 426 | + * @param {string} type 事件类型 | ||
| 427 | + * @param {Function} listener 需要添加的监听器 | ||
| 428 | + * @remark | ||
| 429 | + * | ||
| 430 | + 1. 不支持跨浏览器的鼠标滚轮事件监听器添加<br> | ||
| 431 | + 2. 改方法不为监听器灌入事件对象,以防止跨iframe事件挂载的事件对象获取失败 | ||
| 432 | + | ||
| 433 | + * @shortcut on | ||
| 434 | + * @meta standard | ||
| 435 | + * @see baidu.event.un | ||
| 436 | + * | ||
| 437 | + * @returns {HTMLElement|window} 目标元素 | ||
| 438 | + */ | ||
| 439 | + baidu.event.on = function (element, type, listener) { | ||
| 440 | + type = type.replace(/^on/i, ''); | ||
| 441 | + element = baidu.dom._g(element); | ||
| 442 | + | ||
| 443 | + var realListener = function (ev) { | ||
| 444 | + // 1. 这里不支持EventArgument, 原因是跨frame的事件挂载 | ||
| 445 | + // 2. element是为了修正this | ||
| 446 | + listener.call(element, ev); | ||
| 447 | + }, | ||
| 448 | + lis = baidu.event._listeners, | ||
| 449 | + filter = baidu.event._eventFilter, | ||
| 450 | + afterFilter, | ||
| 451 | + realType = type; | ||
| 452 | + type = type.toLowerCase(); | ||
| 453 | + // filter过滤 | ||
| 454 | + if(filter && filter[type]){ | ||
| 455 | + afterFilter = filter[type](element, type, realListener); | ||
| 456 | + realType = afterFilter.type; | ||
| 457 | + realListener = afterFilter.listener; | ||
| 458 | + } | ||
| 459 | + | ||
| 460 | + // 事件监听器挂载 | ||
| 461 | + if (element.addEventListener) { | ||
| 462 | + element.addEventListener(realType, realListener, false); | ||
| 463 | + } else if (element.attachEvent) { | ||
| 464 | + element.attachEvent('on' + realType, realListener); | ||
| 465 | + } | ||
| 466 | + | ||
| 467 | + // 将监听器存储到数组中 | ||
| 468 | + lis[lis.length] = [element, type, listener, realListener, realType]; | ||
| 469 | + return element; | ||
| 470 | + }; | ||
| 471 | + | ||
| 472 | + // 声明快捷方法 | ||
| 473 | + baidu.on = baidu.event.on; | ||
| 474 | + | ||
| 475 | + /** | ||
| 476 | + * 返回一个当前页面的唯一标识字符串。 | ||
| 477 | + * @name baidu.lang.guid | ||
| 478 | + * @function | ||
| 479 | + * @grammar baidu.lang.guid() | ||
| 480 | + * @version 1.1.1 | ||
| 481 | + * @meta standard | ||
| 482 | + * | ||
| 483 | + * @returns {String} 当前页面的唯一标识字符串 | ||
| 484 | + */ | ||
| 485 | + | ||
| 486 | + (function(){ | ||
| 487 | + //不直接使用window,可以提高3倍左右性能 | ||
| 488 | + var guid = window[baidu.guid]; | ||
| 489 | + | ||
| 490 | + baidu.lang.guid = function() { | ||
| 491 | + return "TANGRAM__" + (guid._counter ++).toString(36); | ||
| 492 | + }; | ||
| 493 | + | ||
| 494 | + guid._counter = guid._counter || 1; | ||
| 495 | + })(); | ||
| 496 | + | ||
| 497 | + /** | ||
| 498 | + * 所有类的实例的容器 | ||
| 499 | + * key为每个实例的guid | ||
| 500 | + * @meta standard | ||
| 501 | + */ | ||
| 502 | + | ||
| 503 | + window[baidu.guid]._instances = window[baidu.guid]._instances || {}; | ||
| 504 | + | ||
| 505 | + /** | ||
| 506 | + * 判断目标参数是否为function或Function实例 | ||
| 507 | + * @name baidu.lang.isFunction | ||
| 508 | + * @function | ||
| 509 | + * @grammar baidu.lang.isFunction(source) | ||
| 510 | + * @param {Any} source 目标参数 | ||
| 511 | + * @version 1.2 | ||
| 512 | + * @see baidu.lang.isString,baidu.lang.isObject,baidu.lang.isNumber,baidu.lang.isArray,baidu.lang.isElement,baidu.lang.isBoolean,baidu.lang.isDate | ||
| 513 | + * @meta standard | ||
| 514 | + * @returns {boolean} 类型判断结果 | ||
| 515 | + */ | ||
| 516 | + baidu.lang.isFunction = function (source) { | ||
| 517 | + // chrome下,'function' == typeof /a/ 为true. | ||
| 518 | + return '[object Function]' == Object.prototype.toString.call(source); | ||
| 519 | + }; | ||
| 520 | + | ||
| 521 | + /** | ||
| 522 | + * | ||
| 523 | + * @ignore | ||
| 524 | + * @class Tangram继承机制提供的一个基类,用户可以通过继承baidu.lang.Class来获取它的属性及方法。 | ||
| 525 | + * @name baidu.lang.Class | ||
| 526 | + * @grammar baidu.lang.Class(guid) | ||
| 527 | + * @param {string} guid 对象的唯一标识 | ||
| 528 | + * @meta standard | ||
| 529 | + * @remark baidu.lang.Class和它的子类的实例均包含一个全局唯一的标识guid。guid是在构造函数中生成的,因此,继承自baidu.lang.Class的类应该直接或者间接调用它的构造函数。<br>baidu.lang.Class的构造函数中产生guid的方式可以保证guid的唯一性,及每个实例都有一个全局唯一的guid。 | ||
| 530 | + * @meta standard | ||
| 531 | + * @see baidu.lang.inherits,baidu.lang.Event | ||
| 532 | + */ | ||
| 533 | + baidu.lang.Class = function(guid) { | ||
| 534 | + this.guid = guid || baidu.lang.guid(); | ||
| 535 | + window[baidu.guid]._instances[this.guid] = this; | ||
| 536 | + }; | ||
| 537 | + window[baidu.guid]._instances = window[baidu.guid]._instances || {}; | ||
| 538 | + | ||
| 539 | + /** | ||
| 540 | + * 释放对象所持有的资源,主要是自定义事件。 | ||
| 541 | + * @name dispose | ||
| 542 | + * @grammar obj.dispose() | ||
| 543 | + */ | ||
| 544 | + baidu.lang.Class.prototype.dispose = function(){ | ||
| 545 | + delete window[baidu.guid]._instances[this.guid]; | ||
| 546 | + | ||
| 547 | + for(var property in this){ | ||
| 548 | + if (!baidu.lang.isFunction(this[property])) { | ||
| 549 | + delete this[property]; | ||
| 550 | + } | ||
| 551 | + } | ||
| 552 | + this.disposed = true; | ||
| 553 | + }; | ||
| 554 | + | ||
| 555 | + /** | ||
| 556 | + * 重载了默认的toString方法,使得返回信息更加准确一些。 | ||
| 557 | + * @return {string} 对象的String表示形式 | ||
| 558 | + */ | ||
| 559 | + baidu.lang.Class.prototype.toString = function(){ | ||
| 560 | + return "[object " + (this._className || "Object" ) + "]"; | ||
| 561 | + }; | ||
| 562 | + | ||
| 563 | + /** | ||
| 564 | + * @ignore | ||
| 565 | + * @class 自定义的事件对象。 | ||
| 566 | + * @name baidu.lang.Event | ||
| 567 | + * @grammar baidu.lang.Event(type[, target]) | ||
| 568 | + * @param {string} type 事件类型名称。为了方便区分事件和一个普通的方法,事件类型名称必须以"on"(小写)开头。 | ||
| 569 | + * @param {Object} [target]触发事件的对象 | ||
| 570 | + * @meta standard | ||
| 571 | + * @remark 引入该模块,会自动为Class引入3个事件扩展方法:addEventListener、removeEventListener和dispatchEvent。 | ||
| 572 | + * @meta standard | ||
| 573 | + * @see baidu.lang.Class | ||
| 574 | + */ | ||
| 575 | + baidu.lang.Event = function (type, target) { | ||
| 576 | + this.type = type; | ||
| 577 | + this.returnValue = true; | ||
| 578 | + this.target = target || null; | ||
| 579 | + this.currentTarget = null; | ||
| 580 | + }; | ||
| 581 | + | ||
| 582 | + /** | ||
| 583 | + * 注册对象的事件监听器。引入baidu.lang.Event后,Class的子类实例才会获得该方法。 | ||
| 584 | + * @grammar obj.addEventListener(type, handlers[, key]) | ||
| 585 | + * @param {string} type 自定义事件的名称 | ||
| 586 | + * @param {Function} handler 自定义事件被触发时应该调用的回调函数 | ||
| 587 | + * @param {string} [key] 为事件监听函数指定的名称,可在移除时使用。如果不提供,方法会默认为它生成一个全局唯一的key。 | ||
| 588 | + * @remark 事件类型区分大小写。如果自定义事件名称不是以小写"on"开头,该方法会给它加上"on"再进行判断,即"click"和"onclick"会被认为是同一种事件。 | ||
| 589 | + */ | ||
| 590 | + baidu.lang.Class.prototype.addEventListener = function (type, handler, key) { | ||
| 591 | + if (!baidu.lang.isFunction(handler)) { | ||
| 592 | + return; | ||
| 593 | + } | ||
| 594 | + | ||
| 595 | + !this.__listeners && (this.__listeners = {}); | ||
| 596 | + | ||
| 597 | + var t = this.__listeners, id; | ||
| 598 | + if (typeof key == "string" && key) { | ||
| 599 | + if (/[^\w\-]/.test(key)) { | ||
| 600 | + throw("nonstandard key:" + key); | ||
| 601 | + } else { | ||
| 602 | + handler.hashCode = key; | ||
| 603 | + id = key; | ||
| 604 | + } | ||
| 605 | + } | ||
| 606 | + type.indexOf("on") != 0 && (type = "on" + type); | ||
| 607 | + | ||
| 608 | + typeof t[type] != "object" && (t[type] = {}); | ||
| 609 | + id = id || baidu.lang.guid(); | ||
| 610 | + handler.hashCode = id; | ||
| 611 | + t[type][id] = handler; | ||
| 612 | + }; | ||
| 613 | + | ||
| 614 | + /** | ||
| 615 | + * 移除对象的事件监听器。引入baidu.lang.Event后,Class的子类实例才会获得该方法。 | ||
| 616 | + * @grammar obj.removeEventListener(type, handlers) | ||
| 617 | + * @param {string} type 事件类型 | ||
| 618 | + * @param {Function|string} handler 要移除的事件监听函数或者监听函数的key | ||
| 619 | + * @remark 如果第二个参数handler没有被绑定到对应的自定义事件中,什么也不做。 | ||
| 620 | + */ | ||
| 621 | + baidu.lang.Class.prototype.removeEventListener = function (type, handler) { | ||
| 622 | + if (typeof handler != "undefined") { | ||
| 623 | + if ( (baidu.lang.isFunction(handler) && ! (handler = handler.hashCode)) | ||
| 624 | + || (! baidu.lang.isString(handler)) | ||
| 625 | + ){ | ||
| 626 | + return; | ||
| 627 | + } | ||
| 628 | + } | ||
| 629 | + | ||
| 630 | + !this.__listeners && (this.__listeners = {}); | ||
| 631 | + | ||
| 632 | + type.indexOf("on") != 0 && (type = "on" + type); | ||
| 633 | + | ||
| 634 | + var t = this.__listeners; | ||
| 635 | + if (!t[type]) { | ||
| 636 | + return; | ||
| 637 | + } | ||
| 638 | + if (typeof handler != "undefined") { | ||
| 639 | + t[type][handler] && delete t[type][handler]; | ||
| 640 | + } else { | ||
| 641 | + for(var guid in t[type]){ | ||
| 642 | + delete t[type][guid]; | ||
| 643 | + } | ||
| 644 | + } | ||
| 645 | + }; | ||
| 646 | + | ||
| 647 | + /** | ||
| 648 | + * 派发自定义事件,使得绑定到自定义事件上面的函数都会被执行。引入baidu.lang.Event后,Class的子类实例才会获得该方法。 | ||
| 649 | + * @grammar obj.dispatchEvent(event, options) | ||
| 650 | + * @param {baidu.lang.Event|String} event Event对象,或事件名称(1.1.1起支持) | ||
| 651 | + * @param {Object} options 扩展参数,所含属性键值会扩展到Event对象上(1.2起支持) | ||
| 652 | + * @remark 处理会调用通过addEventListenr绑定的自定义事件回调函数之外,还会调用直接绑定到对象上面的自定义事件。例如:<br> | ||
| 653 | + myobj.onMyEvent = function(){}<br> | ||
| 654 | + myobj.addEventListener("onMyEvent", function(){}); | ||
| 655 | + */ | ||
| 656 | + baidu.lang.Class.prototype.dispatchEvent = function (event, options) { | ||
| 657 | + if (baidu.lang.isString(event)) { | ||
| 658 | + event = new baidu.lang.Event(event); | ||
| 659 | + } | ||
| 660 | + !this.__listeners && (this.__listeners = {}); | ||
| 661 | + | ||
| 662 | + // 20100603 添加本方法的第二个参数,将 options extend到event中去传递 | ||
| 663 | + options = options || {}; | ||
| 664 | + for (var i in options) { | ||
| 665 | + event[i] = options[i]; | ||
| 666 | + } | ||
| 667 | + | ||
| 668 | + var i, t = this.__listeners, p = event.type; | ||
| 669 | + event.target = event.target || this; | ||
| 670 | + event.currentTarget = this; | ||
| 671 | + | ||
| 672 | + p.indexOf("on") != 0 && (p = "on" + p); | ||
| 673 | + | ||
| 674 | + baidu.lang.isFunction(this[p]) && this[p].apply(this, arguments); | ||
| 675 | + | ||
| 676 | + if (typeof t[p] == "object") { | ||
| 677 | + for (i in t[p]) { | ||
| 678 | + t[p][i].apply(this, arguments); | ||
| 679 | + } | ||
| 680 | + } | ||
| 681 | + return event.returnValue; | ||
| 682 | + }; | ||
| 683 | + | ||
| 684 | + | ||
| 685 | + baidu.lang.inherits = function (subClass, superClass, className) { | ||
| 686 | + var key, proto, | ||
| 687 | + selfProps = subClass.prototype, | ||
| 688 | + clazz = new Function(); | ||
| 689 | + | ||
| 690 | + clazz.prototype = superClass.prototype; | ||
| 691 | + proto = subClass.prototype = new clazz(); | ||
| 692 | + for (key in selfProps) { | ||
| 693 | + proto[key] = selfProps[key]; | ||
| 694 | + } | ||
| 695 | + subClass.prototype.constructor = subClass; | ||
| 696 | + subClass.superClass = superClass.prototype; | ||
| 697 | + | ||
| 698 | + // 类名标识,兼容Class的toString,基本没用 | ||
| 699 | + if ("string" == typeof className) { | ||
| 700 | + proto._className = className; | ||
| 701 | + } | ||
| 702 | + }; | ||
| 703 | + // 声明快捷方法 | ||
| 704 | + baidu.inherits = baidu.lang.inherits; | ||
| 705 | + })(); | ||
| 706 | + | ||
| 707 | + | ||
| 708 | + /** | ||
| 709 | + | ||
| 710 | + * 图片的路径 | ||
| 711 | + | ||
| 712 | + * @private | ||
| 713 | + * @type {String} | ||
| 714 | + | ||
| 715 | + */ | ||
| 716 | + var _IMAGE_PATH = '//api.map.baidu.com/library/TextIconOverlay/1.2/src/images/m'; | ||
| 717 | + | ||
| 718 | + /** | ||
| 719 | + | ||
| 720 | + * 图片的后缀名 | ||
| 721 | + | ||
| 722 | + * @private | ||
| 723 | + * @type {String} | ||
| 724 | + | ||
| 725 | + */ | ||
| 726 | + var _IMAGE_EXTENSION = 'png'; | ||
| 727 | + | ||
| 728 | + /** | ||
| 729 | + *@exports TextIconOverlay as BMapLib.TextIconOverlay | ||
| 730 | + */ | ||
| 731 | + var TextIconOverlay = | ||
| 732 | + /** | ||
| 733 | + * TextIconOverlay | ||
| 734 | + * @class 此类表示地图上的一个覆盖物,该覆盖物由文字和图标组成,从Overlay继承。文字通常是数字(0-9)或字母(A-Z ),而文字与图标之间有一定的映射关系。 | ||
| 735 | + *该覆盖物适用于以下类似的场景:需要在地图上添加一系列覆盖物,这些覆盖物之间用不同的图标和文字来区分,文字可能表示了该覆盖物的某一属性值,根据该文字和一定的映射关系,自动匹配相应颜色和大小的图标。 | ||
| 736 | + * | ||
| 737 | + *@constructor | ||
| 738 | + *@param {Point} position 表示一个经纬度坐标位置。 | ||
| 739 | + *@param {String} text 表示该覆盖物显示的文字信息。 | ||
| 740 | + *@param {Json Object} options 可选参数,可选项包括:<br /> | ||
| 741 | + *"<b>styles</b>":{Array<IconStyle>} 一组图标风格。单个图表风格包括以下几个属性:<br /> | ||
| 742 | + * url {String} 图片的url地址。(必选)<br /> | ||
| 743 | + * size {Size} 图片的大小。(必选)<br /> | ||
| 744 | + * anchor {Size} 图标定位在地图上的位置相对于图标左上角的偏移值,默认偏移值为图标的中心位置。(可选)<br /> | ||
| 745 | + * offset {Size} 图片相对于可视区域的偏移值,此功能的作用等同于CSS中的background-position属性。(可选)<br /> | ||
| 746 | + * textSize {Number} 文字的大小。(可选,默认10)<br /> | ||
| 747 | + * textColor {String} 文字的颜色。(可选,默认black)<br /> | ||
| 748 | + */ | ||
| 749 | + BMapLib.TextIconOverlay = function(position, text, options){ | ||
| 750 | + this._position = position; | ||
| 751 | + this._text = text; | ||
| 752 | + this._options = options || {}; | ||
| 753 | + this._styles = this._options['styles'] || []; | ||
| 754 | + (!this._styles.length) && this._setupDefaultStyles(); | ||
| 755 | + }; | ||
| 756 | + | ||
| 757 | + T.lang.inherits(TextIconOverlay, BMap.Overlay, "TextIconOverlay"); | ||
| 758 | + | ||
| 759 | + TextIconOverlay.prototype._setupDefaultStyles = function(){ | ||
| 760 | + var sizes = [53, 56, 66, 78, 90]; | ||
| 761 | + for(var i = 0, size; size = sizes[i]; i++){ | ||
| 762 | + this._styles.push({ | ||
| 763 | + url:_IMAGE_PATH + i + '.' + _IMAGE_EXTENSION, | ||
| 764 | + size: new BMap.Size(size, size) | ||
| 765 | + }); | ||
| 766 | + }//for循环的简洁写法 | ||
| 767 | + }; | ||
| 768 | + | ||
| 769 | + /** | ||
| 770 | + *继承Overlay的intialize方法,自定义覆盖物时必须。 | ||
| 771 | + *@param {Map} map BMap.Map的实例化对象。 | ||
| 772 | + *@return {HTMLElement} 返回覆盖物对应的HTML元素。 | ||
| 773 | + */ | ||
| 774 | + TextIconOverlay.prototype.initialize = function(map){ | ||
| 775 | + this._map = map; | ||
| 776 | + | ||
| 777 | + this._domElement = document.createElement('div'); | ||
| 778 | + this._updateCss(); | ||
| 779 | + this._updateText(); | ||
| 780 | + this._updatePosition(); | ||
| 781 | + | ||
| 782 | + this._bind(); | ||
| 783 | + | ||
| 784 | + this._map.getPanes().markerMouseTarget.appendChild(this._domElement); | ||
| 785 | + return this._domElement; | ||
| 786 | + }; | ||
| 787 | + | ||
| 788 | + /** | ||
| 789 | + *继承Overlay的draw方法,自定义覆盖物时必须。 | ||
| 790 | + *@return 无返回值。 | ||
| 791 | + */ | ||
| 792 | + TextIconOverlay.prototype.draw = function(){ | ||
| 793 | + this._map && this._updatePosition(); | ||
| 794 | + }; | ||
| 795 | + | ||
| 796 | + /** | ||
| 797 | + *获取该覆盖物上的文字。 | ||
| 798 | + *@return {String} 该覆盖物上的文字。 | ||
| 799 | + */ | ||
| 800 | + TextIconOverlay.prototype.getText = function(){ | ||
| 801 | + return this._text; | ||
| 802 | + }; | ||
| 803 | + | ||
| 804 | + /** | ||
| 805 | + *设置该覆盖物上的文字。 | ||
| 806 | + *@param {String} text 要设置的文字,通常是字母A-Z或数字0-9。 | ||
| 807 | + *@return 无返回值。 | ||
| 808 | + */ | ||
| 809 | + TextIconOverlay.prototype.setText = function(text){ | ||
| 810 | + if(text && (!this._text || (this._text.toString() != text.toString()))){ | ||
| 811 | + this._text = text; | ||
| 812 | + this._updateText(); | ||
| 813 | + this._updateCss(); | ||
| 814 | + this._updatePosition(); | ||
| 815 | + } | ||
| 816 | + }; | ||
| 817 | + | ||
| 818 | + /** | ||
| 819 | + *获取该覆盖物的位置。 | ||
| 820 | + *@return {Point} 该覆盖物的经纬度坐标。 | ||
| 821 | + */ | ||
| 822 | + TextIconOverlay.prototype.getPosition = function () { | ||
| 823 | + return this._position; | ||
| 824 | + }; | ||
| 825 | + | ||
| 826 | + /** | ||
| 827 | + *设置该覆盖物的位置。 | ||
| 828 | + *@param {Point} position 要设置的经纬度坐标。 | ||
| 829 | + *@return 无返回值。 | ||
| 830 | + */ | ||
| 831 | + TextIconOverlay.prototype.setPosition = function (position) { | ||
| 832 | + if(position && (!this._position || !this._position.equals(position))){ | ||
| 833 | + this._position = position; | ||
| 834 | + this._updatePosition(); | ||
| 835 | + } | ||
| 836 | + }; | ||
| 837 | + | ||
| 838 | + /** | ||
| 839 | + *由文字信息获取风格数组的对应索引值。 | ||
| 840 | + *内部默认的对应函数为文字转换为数字除以10的结果,比如文字8返回索引0,文字25返回索引2. | ||
| 841 | + *如果需要自定义映射关系,请覆盖该函数。 | ||
| 842 | + *@param {String} text 文字。 | ||
| 843 | + *@param {Array<IconStyle>} styles 一组图标风格。 | ||
| 844 | + *@return {Number} 对应的索引值。 | ||
| 845 | + */ | ||
| 846 | + TextIconOverlay.prototype.getStyleByText = function(text, styles){ | ||
| 847 | + var count = parseInt(text); | ||
| 848 | + var index = parseInt(count / 10); | ||
| 849 | + index = Math.max(0, index); | ||
| 850 | + index = Math.min(index, styles.length - 1); | ||
| 851 | + return styles[index]; | ||
| 852 | + } | ||
| 853 | + | ||
| 854 | + /** | ||
| 855 | + *更新相应的CSS。 | ||
| 856 | + *@return 无返回值。 | ||
| 857 | + */ | ||
| 858 | + TextIconOverlay.prototype._updateCss = function(){ | ||
| 859 | + var style = this.getStyleByText(this._text, this._styles); | ||
| 860 | + this._domElement.style.cssText = this._buildCssText(style); | ||
| 861 | + }; | ||
| 862 | + | ||
| 863 | + /** | ||
| 864 | + *更新覆盖物的显示文字。 | ||
| 865 | + *@return 无返回值。 | ||
| 866 | + */ | ||
| 867 | + TextIconOverlay.prototype._updateText = function(){ | ||
| 868 | + if (this._domElement) { | ||
| 869 | + this._domElement.innerHTML = this._text; | ||
| 870 | + } | ||
| 871 | + }; | ||
| 872 | + | ||
| 873 | + /** | ||
| 874 | + *调整覆盖物在地图上的位置更新覆盖物的显示文字。 | ||
| 875 | + *@return 无返回值。 | ||
| 876 | + */ | ||
| 877 | + TextIconOverlay.prototype._updatePosition = function(){ | ||
| 878 | + if (this._domElement && this._position) { | ||
| 879 | + var style = this._domElement.style; | ||
| 880 | + var pixelPosition= this._map.pointToOverlayPixel(this._position); | ||
| 881 | + pixelPosition.x -= Math.ceil(parseInt(style.width) / 2); | ||
| 882 | + pixelPosition.y -= Math.ceil(parseInt(style.height) / 2); | ||
| 883 | + style.left = pixelPosition.x + "px"; | ||
| 884 | + style.top = pixelPosition.y + "px"; | ||
| 885 | + } | ||
| 886 | + }; | ||
| 887 | + | ||
| 888 | + /** | ||
| 889 | + * 为该覆盖物的HTML元素构建CSS | ||
| 890 | + * @param {IconStyle} 一个图标的风格。 | ||
| 891 | + * @return {String} 构建完成的CSSTEXT。 | ||
| 892 | + */ | ||
| 893 | + TextIconOverlay.prototype._buildCssText = function(style) { | ||
| 894 | + //根据style来确定一些默认值 | ||
| 895 | + var url = style['url']; | ||
| 896 | + var size = style['size']; | ||
| 897 | + var anchor = style['anchor']; | ||
| 898 | + var offset = style['offset']; | ||
| 899 | + var textColor = style['textColor'] || 'black'; | ||
| 900 | + var textSize = style['textSize'] || 10; | ||
| 901 | + | ||
| 902 | + var csstext = []; | ||
| 903 | + if (T.browser["ie"] < 7) { | ||
| 904 | + csstext.push('filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(' + | ||
| 905 | + 'sizingMethod=scale,src="' + url + '");'); | ||
| 906 | + } else { | ||
| 907 | + csstext.push('background-image:url(' + url + ');'); | ||
| 908 | + var backgroundPosition = '0 0'; | ||
| 909 | + (offset instanceof BMap.Size) && (backgroundPosition = offset.width + 'px' + ' ' + offset.height + 'px'); | ||
| 910 | + csstext.push('background-position:' + backgroundPosition + ';'); | ||
| 911 | + } | ||
| 912 | + | ||
| 913 | + if (size instanceof BMap.Size){ | ||
| 914 | + if (anchor instanceof BMap.Size) { | ||
| 915 | + if (anchor.height > 0 && anchor.height < size.height) { | ||
| 916 | + csstext.push('height:' + (size.height - anchor.height) + 'px; padding-top:' + anchor.height + 'px;'); | ||
| 917 | + } | ||
| 918 | + if(anchor.width > 0 && anchor.width < size.width){ | ||
| 919 | + csstext.push('width:' + (size.width - anchor.width) + 'px; padding-left:' + anchor.width + 'px;'); | ||
| 920 | + } | ||
| 921 | + } else { | ||
| 922 | + csstext.push('height:' + size.height + 'px; line-height:' + size.height + 'px;'); | ||
| 923 | + csstext.push('width:' + size.width + 'px; text-align:center;'); | ||
| 924 | + } | ||
| 925 | + } | ||
| 926 | + | ||
| 927 | + csstext.push('cursor:pointer; color:' + textColor + '; position:absolute; font-size:' + | ||
| 928 | + textSize + 'px; font-family:Arial,sans-serif; font-weight:bold'); | ||
| 929 | + return csstext.join(''); | ||
| 930 | + }; | ||
| 931 | + | ||
| 932 | + | ||
| 933 | + /** | ||
| 934 | + | ||
| 935 | + * 当鼠标点击该覆盖物时会触发该事件 | ||
| 936 | + | ||
| 937 | + * @name TextIconOverlay#click | ||
| 938 | + | ||
| 939 | + * @event | ||
| 940 | + | ||
| 941 | + * @param {Event Object} e 回调函数会返回event参数,包括以下返回值: | ||
| 942 | + | ||
| 943 | + * <br />"<b>type</b> : {String} 事件类型 | ||
| 944 | + | ||
| 945 | + * <br />"<b>target</b>:{BMapLib.TextIconOverlay} 事件目标 | ||
| 946 | + | ||
| 947 | + * | ||
| 948 | + | ||
| 949 | + */ | ||
| 950 | + | ||
| 951 | + /** | ||
| 952 | + | ||
| 953 | + * 当鼠标进入该覆盖物区域时会触发该事件 | ||
| 954 | + | ||
| 955 | + * @name TextIconOverlay#mouseover | ||
| 956 | + | ||
| 957 | + * @event | ||
| 958 | + * @param {Event Object} e 回调函数会返回event参数,包括以下返回值: | ||
| 959 | + | ||
| 960 | + * <br />"<b>type</b> : {String} 事件类型 | ||
| 961 | + | ||
| 962 | + * <br />"<b>target</b>:{BMapLib.TextIconOverlay} 事件目标 | ||
| 963 | + | ||
| 964 | + * <br />"<b>point</b> : {BMap.Point} 最新添加上的节点BMap.Point对象 | ||
| 965 | + | ||
| 966 | + * <br />"<b>pixel</b>:{BMap.pixel} 最新添加上的节点BMap.Pixel对象 | ||
| 967 | + | ||
| 968 | + * | ||
| 969 | + | ||
| 970 | + * @example <b>参考示例:</b><br /> | ||
| 971 | + | ||
| 972 | + * myTextIconOverlay.addEventListener("mouseover", function(e) { alert(e.point); }); | ||
| 973 | + | ||
| 974 | + */ | ||
| 975 | + | ||
| 976 | + /** | ||
| 977 | + | ||
| 978 | + * 当鼠标离开该覆盖物区域时会触发该事件 | ||
| 979 | + | ||
| 980 | + * @name TextIconOverlay#mouseout | ||
| 981 | + | ||
| 982 | + * @event | ||
| 983 | + | ||
| 984 | + * @param {Event Object} e 回调函数会返回event参数,包括以下返回值: | ||
| 985 | + | ||
| 986 | + * <br />"<b>type</b> : {String} 事件类型 | ||
| 987 | + | ||
| 988 | + * <br />"<b>target</b>:{BMapLib.TextIconOverlay} 事件目标 | ||
| 989 | + | ||
| 990 | + * <br />"<b>point</b> : {BMap.Point} 最新添加上的节点BMap.Point对象 | ||
| 991 | + | ||
| 992 | + * <br />"<b>pixel</b>:{BMap.pixel} 最新添加上的节点BMap.Pixel对象 | ||
| 993 | + | ||
| 994 | + * | ||
| 995 | + | ||
| 996 | + * @example <b>参考示例:</b><br /> | ||
| 997 | + | ||
| 998 | + * myTextIconOverlay.addEventListener("mouseout", function(e) { alert(e.point); }); | ||
| 999 | + | ||
| 1000 | + */ | ||
| 1001 | + | ||
| 1002 | + | ||
| 1003 | + /** | ||
| 1004 | + * 为该覆盖物绑定一系列事件 | ||
| 1005 | + * 当前支持click mouseover mouseout | ||
| 1006 | + * @return 无返回值。 | ||
| 1007 | + */ | ||
| 1008 | + TextIconOverlay.prototype._bind = function(){ | ||
| 1009 | + if (!this._domElement){ | ||
| 1010 | + return; | ||
| 1011 | + } | ||
| 1012 | + | ||
| 1013 | + var me = this; | ||
| 1014 | + var map = this._map; | ||
| 1015 | + | ||
| 1016 | + var BaseEvent = T.lang.Event; | ||
| 1017 | + function eventExtend(e, be){ | ||
| 1018 | + var elem = e.srcElement || e.target; | ||
| 1019 | + var x = e.clientX || e.pageX; | ||
| 1020 | + var y = e.clientY || e.pageY; | ||
| 1021 | + if (e && be && x && y && elem){ | ||
| 1022 | + var offset = T.dom.getPosition(map.getContainer()); | ||
| 1023 | + be.pixel = new BMap.Pixel(x - offset.left, y - offset.top); | ||
| 1024 | + be.point = map.pixelToPoint(be.pixel); | ||
| 1025 | + } | ||
| 1026 | + return be; | ||
| 1027 | + }//给事件参数增加pixel和point两个值 | ||
| 1028 | + | ||
| 1029 | + T.event.on(this._domElement,"mouseover", function(e){ | ||
| 1030 | + me.dispatchEvent(eventExtend(e, new BaseEvent("onmouseover"))); | ||
| 1031 | + }); | ||
| 1032 | + T.event.on(this._domElement,"mouseout", function(e){ | ||
| 1033 | + me.dispatchEvent(eventExtend(e, new BaseEvent("onmouseout"))); | ||
| 1034 | + }); | ||
| 1035 | + T.event.on(this._domElement,"click", function(e){ | ||
| 1036 | + me.dispatchEvent(eventExtend(e, new BaseEvent("onclick"))); | ||
| 1037 | + }); | ||
| 1038 | + }; | ||
| 1039 | + | ||
| 1040 | })(); | 1040 | })(); |
| 1041 | \ No newline at end of file | 1041 | \ No newline at end of file |
src/main/resources/static/gpsTest/test.html
| 1 | -<!DOCTYPE html> | ||
| 2 | -<html> | ||
| 3 | -<head> | ||
| 4 | -<meta charset="UTF-8"> | ||
| 5 | -<title>GPS点测试</title> | ||
| 6 | -<meta name=”renderer” content=”webkit”> | ||
| 7 | -<meta http-equiv=”X-UA-Compatible” content=”IE=Edge,chrome=1″> | ||
| 8 | - | ||
| 9 | -<meta http-equiv="Pragma" content="no-cache"> | ||
| 10 | -<meta http-equiv="Cache-control" content="no-cache"> | ||
| 11 | -<meta http-equiv="Cache" content="no-cache"> | ||
| 12 | -<head> | ||
| 13 | -<!-- select2 下拉框插件 --> | ||
| 14 | -<link href="/metronic_v4.5.4/plugins/select2/css/select2.min.css" | ||
| 15 | - rel="stylesheet" type="text/css" /> | ||
| 16 | -<style type="text/css"> | ||
| 17 | -html,body { | ||
| 18 | - height: 100%; | ||
| 19 | - overflow: hidden; | ||
| 20 | -} | ||
| 21 | - | ||
| 22 | -#mapContainer { | ||
| 23 | - width: 100%; | ||
| 24 | - height: calc(100% - 93px); | ||
| 25 | -} | ||
| 26 | - | ||
| 27 | -form { | ||
| 28 | - padding: 25px; | ||
| 29 | -} | ||
| 30 | - | ||
| 31 | -form .item { | ||
| 32 | - display: inline-block; | ||
| 33 | -} | ||
| 34 | - | ||
| 35 | -form .item input { | ||
| 36 | - height: 26px; | ||
| 37 | - width: 110px; | ||
| 38 | -} | ||
| 39 | - | ||
| 40 | -form .item select { | ||
| 41 | - height: 32px; | ||
| 42 | -} | ||
| 43 | -</style> | ||
| 44 | -</head> | ||
| 45 | -<body> | ||
| 46 | - <form action=""> | ||
| 47 | - <div class="item"> | ||
| 48 | - 线路: <select name="xl" style="width: 150px;"> | ||
| 49 | - </select> | ||
| 50 | - </div> | ||
| 51 | - <div class="item"> | ||
| 52 | - 方向: <select name="directions" style="width: 70px;"> | ||
| 53 | - <option value="0">上行</option> | ||
| 54 | - <option value="1">下行</option> | ||
| 55 | - </select> | ||
| 56 | - </div> | ||
| 57 | - <div class="item"> | ||
| 58 | - 设备号: <input name="device" value="059L0903" /> | ||
| 59 | - </div> | ||
| 60 | - <div class="item"> | ||
| 61 | - 开始时间戳: <input type="number" name="startTime" value="1461380940000" /> | ||
| 62 | - </div> | ||
| 63 | - <div class="item"> | ||
| 64 | - 结束时间戳: <input type="number" name="endTime" value="1461381960000" /> | ||
| 65 | - </div> | ||
| 66 | - <div class="item"> | ||
| 67 | - <input type="button" value="查询GPS轨迹" onclick="searchGps()"> | ||
| 68 | - </div> | ||
| 69 | - <div class="item"> | ||
| 70 | - <input type="button" value="开启测距" onclick="myDis.open();" | ||
| 71 | - style="width: 75px" /> <input type="button" value="关闭测距" | ||
| 72 | - onclick="myDis.close()" style="width: 75px" /> | ||
| 73 | - | ||
| 74 | - </div> | ||
| 75 | - | ||
| 76 | - <div class="item"> | ||
| 77 | - <a target="_blank" href="http://tool.chinaz.com/Tools/unixtime.aspx" | ||
| 78 | - style="font-size: 12px; color: red;">毫秒时间戳转换</a> | ||
| 79 | - </div> | ||
| 80 | - </form> | ||
| 81 | - | ||
| 82 | - <div id="mapContainer"></div> | ||
| 83 | - <script src="/assets/plugins/pinyin.js"></script> | ||
| 84 | - <script src="/metronic_v4.5.4/plugins/jquery.min.js"></script> | ||
| 85 | - <script src="/assets/plugins/jquery.serializejson.js"></script> | ||
| 86 | - <script | ||
| 87 | - src="http://api.map.baidu.com/api?v=2.0&ak=IGGrr4UjwIYzatoCRFKEL8sT"></script> | ||
| 88 | - <script type="text/javascript" | ||
| 89 | - src="http://api.map.baidu.com/library/DistanceTool/1.2/src/DistanceTool_min.js"></script> | ||
| 90 | - <!-- moment.js 日期处理类库 --> | ||
| 91 | - <script src="/assets/plugins/moment-with-locales.js"></script> | ||
| 92 | - <!-- select2 下拉框 --> | ||
| 93 | - <script src="/metronic_v4.5.4/plugins/select2/js/select2.full.min.js"></script> | ||
| 94 | - <script> | ||
| 95 | - | ||
| 96 | - var inMark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAA1CAYAAABSrotqAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAGW0lEQVRYw62XX2wc1RWHv3vv7NhrQkKCIa0poaKRmjdUFUGr+IH+ITy0Kg/0qVRV1ZamVV95al94oPSBVmoRUZTIKRFBLW1aapBK6gIChYTgFJRQHoITqCCO7eC1vY7t2Z1/954+zK69Xs9mx4mPdLWjmTvnO79z7zl3VlHAvv3XmXuM8R4EBpVSu1DqpiQRBJlH5APn5KQ4NzzycP/pbr7U1R5+6y+Vr2njP6EVX1FKoRTZAOJUQMBlP4gIIrwtNvnlyMO3vL4u4AND49vMjZsOaqMfUgpMA+ZEiBJIrJAkQslT+B4YrXACzknj1x4N6rWfnfrJ7XNdgd888NEOs+XmEaPVLq0zRVEiRGnmsGlJsnKtFfT4ih5PIQJWwDr3QRJUHzix9wsXOwLvOzDW72269ZQxeqcxIAL1WLAtoDzgMlgr+vwsG6kTrOXDoDL91Xcf/eLM8pxWuJT7j4hSO5UC66AW5cM6mXNCEDmsA60UAjv9rf1HWoU1L9Tg0OT3dU/5Wd9TeFpRiwWRFZhNhSvTMbX5hDh0uNhR6jWUb/LYvL0H460kSyko+xrrhCgVJAp/MPrzgecAMVkuH/PuuHv335VSW3s8TZgIrgUWzKdMXagRLqU4KygF4gRnhSiwLFZivF6N32tWAhTwPUWSCmhz18RC3z4+fsNpgN3f+/H9oO4ESO3qNNaupFQ+qWeRa5U7AGY/rlO7kq5Kb+qkUUrqzru/+8M9zTXUeKUHs92miG3LmlhhbjJCGVVoVCdCnG3ZyamgVRaQLvV+B9AeoJUu3QtgdLZWy6mspgigzdpyFS+/ZwTVhBv7/WyOgDbZBtTa3NMEKqX0Dsg6RqvFoUN3cOyczr2f1F3+FtbmDkB5gEKzFQFr215OBe3lO9Yu33GSrg47XUnxtiYQRKUgpdadCaAbnSMfmK+8Pf3L74ssATSAtorSt7a/vKnPUA87pMhTa9cAKJfzMwKysAwU56aUWQvcssUQJ/lA6aBw8xaPJHe+m4asLERcOpb3cvkGg1/SeEatGSZn+CVFeZPJDQRnxwDJgDY5nzcniIXbBkq5zo3Jyqg5PAMDAz5BlL/oLo0uLAOT4MqZvEnWCbEoPjfgU/LUKoDRK/BSSXHbgE8kqmOzt+HiGUA8QBY+Ov127823u0YAq1VGDno0n9/hs7BoWQocSSKIQKmk6OvTbN5sqAZCLeqw3uBmz791ChBFdmL4g4dnziptdnXYYhit2FxWlH2N72WHcmqhFjkW61c/xsTZc6OP3PIlIPayAHA2Dt/wem/oCLROqAZCNchU5B3AnczF9dcBR0sKxQZzI4U9rNOS+vwrDWHLJ76bOH7gTZBwo2GCBDOv/OF4Q+EyUCb+sW/JJeGxDQfG4b8vjRwK2hUKYNPF6gsbDUyC6lHAtgMB3NTfnv5ns+dtkL6F2eF9/6KRznagXDyxvyZx9PJG4WxUf+niif01Wtr8KiBgo8VPj24UMA5mXqAlne1AAPfhc79+DZHZ66aJq0wM/eJVWtKZB5Tqu0frNlr80/Xy0jB4fmbsZNQVCNj6+LlDoFxh7+2mkHjy3OFGOtse5U2H3sE/Xn5ZeT33dfJ5tdYmNjk5+tPt9wMhbd8Fed8DAqTJwuyhaxWYLM4MASk5HyGdPkDshT8/+hLiLq8XJuIu/+/Ir4bz0nk1oMyNHgttuPTseoGuvnh4/uzwqtorBATszNnXDqyvoUu48N6rB2mrvSJAAHd+/48mbVgr3AhsGDw/NvTIFG2lUBQoQFr/5L2nipSIgAvH//s0HTZL01QXPwro3X3o8rAu9expfdBeFpJGx0b3fvYhckqhqMJllVFl/PfdFNanx5/qpq6IwmZQvYPPTB9XpvTlPIWSxqOjez/z9YY6181ZN3NAEs5d+k2nCfHc5JNA0g1WVGGLyspbynh3tSp0aXLm9N7tg0XUFVXYVJlG81NPrlE3P/k7srUr1OyLAgHS/zzxjRex9v3mDbHp+2d/u+fFBrBwqoqaUKnEYfXS480b4dzk41QqMV125vWYBvoGn5l+596Dn74D9K0z6MY/4M7WvqkESOPK+GNRlsRm3eXNK+SwVYkPlBpBacA05uvGfVgpBSFr2K4RRALE5GykTif+toZT1WFu87pVSft1Asy1q70WhYrVwOa4ZoXred7JOq7h/wF6az0ukZgX/AAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxNS0wNy0yNVQyMTo1MDo0MyswODowMOgS43cAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTMtMTEtMjBUMjI6NDc6MTErMDg6MDAou1syAAAATnRFWHRzb2Z0d2FyZQBJbWFnZU1hZ2ljayA2LjguOC0xMCBRMTYgeDg2XzY0IDIwMTUtMDctMTkgaHR0cDovL3d3dy5pbWFnZW1hZ2ljay5vcmcFDJw1AAAAGHRFWHRUaHVtYjo6RG9jdW1lbnQ6OlBhZ2VzADGn/7svAAAAF3RFWHRUaHVtYjo6SW1hZ2U6OkhlaWdodAA1Mwmpb+QAAAAWdEVYdFRodW1iOjpJbWFnZTo6V2lkdGgAMjgpleAmAAAAGXRFWHRUaHVtYjo6TWltZXR5cGUAaW1hZ2UvcG5nP7JWTgAAABd0RVh0VGh1bWI6Ok1UaW1lADEzODQ5NTg4MzEXUMEwAAAAE3RFWHRUaHVtYjo6U2l6ZQA0LjUzS0JC/AyPiAAAAFp0RVh0VGh1bWI6OlVSSQBmaWxlOi8vL2hvbWUvd3d3cm9vdC93d3cuZWFzeWljb24ubmV0L2Nkbi1pbWcuZWFzeWljb24uY24vc3JjLzExMjk3LzExMjk3NzIucG5nqXNeUQAAAABJRU5ErkJggg=='; | ||
| 97 | - var outMark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAvCAMAAAC18jgTAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAABO1BMVEUAAAAiu4ggv40gvowgvowgvosgvowfvo0jv44hv40gvosgvowcxo4fvowgvowdvYogv4whvo0gvowhvYwrqoAhv4wnxIkgv4wA//8gvIshvosgvowhvIshvowgvowrv5Ugv4ohvosgvowhv4wgv4whvYwXuYsgvowgvowiu4gfvo0zzJkhvowktpIgvowgv40hvo0gv4wgvowAqqogvosgvowjv4sgvowivIskv4khvowgvYsiu44hvosfvI0hv4sgvYofvowgvowgv40gv4wjuYsgvowhvowfvIsgvYsgvo0hvoxAv4Agv4wgvowgvoshvo0mv4whvowgvowfwo8gv4wgv40duokAAAAfvYsgvYwAAAAAAAAAAAAAAAAAAAAAAAAAAAAYjGUYj2kAAAAAAAAAAAAgvoz///9v2GMAAAAAZ3RSTlMAD1eZyOr4miSc950Jivoj0i/pfAarDaoBWH3JLuv5DDDL0ZunbQvu/h6CBbQO5jhOkNwDtfAsz0Qc42EtdUGLYKKOwsYW7/s5f7nMBCj9N40U8/YZh48aAaOmAggNERMWF0lLGBkanzLKGQAAAAFiS0dEaMts9CIAAAGZSURBVDjLfZRnW8IwFIUvyN6FUlCx4AZxKw7cA/eeKKNUwfz/f2ChZNAmnC+U+54m9548KQCRwznicns8bpfX6QC7fP4AIgoEfRYcCkfQgCLhEMujMWRTLEq55EYcuSXyPpcbjv4aoRgSKGb2EUZChXvzRcSGSHfaIP0fT0iyLCXitOI38qP5JBWzKSVFE3OAk/I0HiudJMVR8JL1FRqMQgb3ggs/Jthox3B1HIg3wxoyuDoBKn6UWYOMqyp4uIYsNfC3yNEtJoc3OQXT3DFJmDNMUCkaFI1yFubmqcMedb4AsMAeVqaYzbGHtWj4l5bFx51f6a64mhca/OaeayK+3m9qY5PPS1tk7G0eV3doMLtlToN7bLT7JZvhYPByHqoWfmS93ceD/CRtNcApy89kG4fiOeXlCucLAoULzC+vgCvSxjUIdGPy2zuR4b53jx8eQagn5gi5en5B6PVtiAHeEfoYxqHiUT9FrNrT17f5a8O1eqOptXT951fXW1qzUa9ZXtfanU7nry/jsa1VuSsYtjZ3BdIDFin/A1AVNdoKDyAYAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE1LTA3LTI1VDIxOjUwOjQzKzA4OjAw6BLjdwAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxMy0xMS0yMFQyMjo0NzoxMyswODowML8kShsAAABOdEVYdHNvZnR3YXJlAEltYWdlTWFnaWNrIDYuOC44LTEwIFExNiB4ODZfNjQgMjAxNS0wNy0xOSBodHRwOi8vd3d3LmltYWdlbWFnaWNrLm9yZwUMnDUAAAAYdEVYdFRodW1iOjpEb2N1bWVudDo6UGFnZXMAMaf/uy8AAAAXdEVYdFRodW1iOjpJbWFnZTo6SGVpZ2h0ADQ3F9+avAAAABZ0RVh0VGh1bWI6OkltYWdlOjpXaWR0aAAzMtBbOHkAAAAZdEVYdFRodW1iOjpNaW1ldHlwZQBpbWFnZS9wbmc/slZOAAAAF3RFWHRUaHVtYjo6TVRpbWUAMTM4NDk1ODgzM/leoBwAAAATdEVYdFRodW1iOjpTaXplADQuMDFLQkKe5chzAAAAWnRFWHRUaHVtYjo6VVJJAGZpbGU6Ly8vaG9tZS93d3dyb290L3d3dy5lYXN5aWNvbi5uZXQvY2RuLWltZy5lYXN5aWNvbi5jbi9zcmMvMTEyOTcvMTEyOTc4Ni5wbmetpUpEAAAAAElFTkSuQmCC'; | ||
| 98 | - | ||
| 99 | - var inOuts = [outMark, inMark]; | ||
| 100 | - | ||
| 101 | - var stationCodeMap = {}; | ||
| 102 | - | ||
| 103 | - var map = new BMap.Map("mapContainer"); | ||
| 104 | - map.centerAndZoom(new BMap.Point(121.544336, 31.221315), 15); | ||
| 105 | - map.enableScrollWheelZoom(); | ||
| 106 | - //中心点和缩放级别 | ||
| 107 | - map.setCurrentCity("上海"); | ||
| 108 | - var myDis = new BMapLib.DistanceTool(map); | ||
| 109 | - | ||
| 110 | - | ||
| 111 | - $.get('/line/all', function(rs){ | ||
| 112 | - var data = []; | ||
| 113 | - $.each(rs, function(){ | ||
| 114 | - data.push({id: this.id, text: this.name}); | ||
| 115 | - }); | ||
| 116 | - | ||
| 117 | - initPinYinSelect2('select[name=xl]', data); | ||
| 118 | - }); | ||
| 119 | - | ||
| 120 | - function searchGps(){ | ||
| 121 | - var params = $('form').serializeJSON(); | ||
| 122 | - //查询线路路由站点 | ||
| 123 | - $.get('/test/gps/route', params, function(rs){ | ||
| 124 | - var array = rs[0].children[0].children | ||
| 125 | - ,coords,circle, cdsArray, points, polygon; | ||
| 126 | - //画出站点 | ||
| 127 | - console.log(array); | ||
| 128 | - $.each(array, function(){ | ||
| 129 | - stationCodeMap[this.stationStationCod] = this.name; | ||
| 130 | - if(this.stationShapesType === 'r'){ | ||
| 131 | - //画圆 | ||
| 132 | - coords = this.stationBJwpoints.split(' '); | ||
| 133 | - circle = new BMap.Circle(new BMap.Point(coords[0], coords[1]),this.stationRadius); | ||
| 134 | - circle.setStrokeColor('red'); | ||
| 135 | - circle.setStrokeWeight(2) | ||
| 136 | - map.addOverlay(circle); | ||
| 137 | - } | ||
| 138 | - else if(this.stationShapesType === 'd'){ | ||
| 139 | - //画多边形 | ||
| 140 | - coords = this.stationBPolygonGrid.substring(9, this.stationBPolygonGrid.length - 2); | ||
| 141 | - cdsArray = coords.split(','); | ||
| 142 | - points = []; | ||
| 143 | - $.each(cdsArray, function(){ | ||
| 144 | - coords = this.split(' '); | ||
| 145 | - points.push(new BMap.Point(coords[0], coords[1])); | ||
| 146 | - }); | ||
| 147 | - | ||
| 148 | - polygon = new BMap.Polygon(points, {strokeColor:"red", strokeWeight:2, strokeOpacity:0.5}); | ||
| 149 | - map.addOverlay(polygon); | ||
| 150 | - } | ||
| 151 | - }); | ||
| 152 | - coords = array[array.length / 2].stationBJwpoints.split(' '); | ||
| 153 | - map.setCenter(new BMap.Point(coords[0], coords[1])) | ||
| 154 | - }); | ||
| 155 | - | ||
| 156 | - //查询gps点 | ||
| 157 | - $.get('/gps/history/' + params.device, params, function(gpsArray){ | ||
| 158 | - console.log(stationCodeMap); | ||
| 159 | - var marker, label, point, state, text; | ||
| 160 | - $.each(gpsArray, function(){ | ||
| 161 | - point = new BMap.Point(this.lon, this.lat); | ||
| 162 | - marker = new BMap.Marker(point); | ||
| 163 | - state = this.inout_stop; | ||
| 164 | - | ||
| 165 | - if(state == 0 || state == 1){ | ||
| 166 | - text = state == 0?'出':'进'; | ||
| 167 | - | ||
| 168 | - console.log(stationCodeMap[this.stopNo], this); | ||
| 169 | - marker.setIcon(new BMap.Icon(inOuts[this.inout_stop], new BMap.Size(25,25))); | ||
| 170 | - label = new BMap.Label( | ||
| 171 | - stationCodeMap[this.stopNo] + '/' +moment(this.ts).format('HH:mm.ss') + ' -'+text | ||
| 172 | - , {position: point, offset: new BMap.Size(-25,-18)}); | ||
| 173 | - marker.setLabel(label); | ||
| 174 | - } | ||
| 175 | - else{ | ||
| 176 | - label = new BMap.Label(moment(this.ts).format('HH:mm.ss') | ||
| 177 | - , {position: point, offset: new BMap.Size(-25,-18)}); | ||
| 178 | - marker.setLabel(label); | ||
| 179 | - } | ||
| 180 | - | ||
| 181 | - map.addOverlay(marker); | ||
| 182 | - }); | ||
| 183 | - }); | ||
| 184 | - } | ||
| 185 | - | ||
| 186 | - | ||
| 187 | - /** | ||
| 188 | - * 支持拼音搜索的select2 | ||
| 189 | - * @param selector | ||
| 190 | - * @param data | ||
| 191 | - */ | ||
| 192 | - function initPinYinSelect2(selector, data, cb){ | ||
| 193 | - | ||
| 194 | - $.each(data, function(){ | ||
| 195 | - this.fullChars = pinyin.getFullChars(this.text).toUpperCase(); | ||
| 196 | - this.camelChars = pinyin.getCamelChars(this.text); | ||
| 197 | - }); | ||
| 198 | - | ||
| 199 | - $.fn.select2.amd.require(['select2/compat/matcher'], function (oldMatcher) { | ||
| 200 | - $(selector).select2({ | ||
| 201 | - data: data, | ||
| 202 | - matcher: oldMatcher(function(term, text, item){ | ||
| 203 | - var upTerm = term.toUpperCase(); | ||
| 204 | - if(item.fullChars.indexOf(upTerm) != -1 | ||
| 205 | - || item.camelChars.indexOf(upTerm) != -1) | ||
| 206 | - return true; | ||
| 207 | - | ||
| 208 | - return text.indexOf(term) != -1; | ||
| 209 | - }) | ||
| 210 | - }); | ||
| 211 | - | ||
| 212 | - cb && cb(); | ||
| 213 | - }); | ||
| 214 | - | ||
| 215 | - return $(selector); | ||
| 216 | - } | ||
| 217 | -</script> | ||
| 218 | -</body> | ||
| 219 | -</html> | 1 | +<!DOCTYPE html> |
| 2 | +<html> | ||
| 3 | +<head> | ||
| 4 | +<meta charset="UTF-8"> | ||
| 5 | +<title>GPS点测试</title> | ||
| 6 | +<meta name=”renderer” content=”webkit”> | ||
| 7 | +<meta http-equiv=”X-UA-Compatible” content=”IE=Edge,chrome=1″> | ||
| 8 | + | ||
| 9 | +<meta http-equiv="Pragma" content="no-cache"> | ||
| 10 | +<meta http-equiv="Cache-control" content="no-cache"> | ||
| 11 | +<meta http-equiv="Cache" content="no-cache"> | ||
| 12 | +<head> | ||
| 13 | +<!-- select2 下拉框插件 --> | ||
| 14 | +<link href="/metronic_v4.5.4/plugins/select2/css/select2.min.css" | ||
| 15 | + rel="stylesheet" type="text/css" /> | ||
| 16 | +<style type="text/css"> | ||
| 17 | +html,body { | ||
| 18 | + height: 100%; | ||
| 19 | + overflow: hidden; | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +#mapContainer { | ||
| 23 | + width: 100%; | ||
| 24 | + height: calc(100% - 93px); | ||
| 25 | +} | ||
| 26 | + | ||
| 27 | +form { | ||
| 28 | + padding: 25px; | ||
| 29 | +} | ||
| 30 | + | ||
| 31 | +form .item { | ||
| 32 | + display: inline-block; | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +form .item input { | ||
| 36 | + height: 26px; | ||
| 37 | + width: 110px; | ||
| 38 | +} | ||
| 39 | + | ||
| 40 | +form .item select { | ||
| 41 | + height: 32px; | ||
| 42 | +} | ||
| 43 | +</style> | ||
| 44 | +</head> | ||
| 45 | +<body> | ||
| 46 | + <form action=""> | ||
| 47 | + <div class="item"> | ||
| 48 | + 线路: <select name="xl" style="width: 150px;"> | ||
| 49 | + </select> | ||
| 50 | + </div> | ||
| 51 | + <div class="item"> | ||
| 52 | + 方向: <select name="directions" style="width: 70px;"> | ||
| 53 | + <option value="0">上行</option> | ||
| 54 | + <option value="1">下行</option> | ||
| 55 | + </select> | ||
| 56 | + </div> | ||
| 57 | + <div class="item"> | ||
| 58 | + 设备号: <input name="device" value="059L0903" /> | ||
| 59 | + </div> | ||
| 60 | + <div class="item"> | ||
| 61 | + 开始时间戳: <input type="number" name="startTime" value="1461380940000" /> | ||
| 62 | + </div> | ||
| 63 | + <div class="item"> | ||
| 64 | + 结束时间戳: <input type="number" name="endTime" value="1461381960000" /> | ||
| 65 | + </div> | ||
| 66 | + <div class="item"> | ||
| 67 | + <input type="button" value="查询GPS轨迹" onclick="searchGps()"> | ||
| 68 | + </div> | ||
| 69 | + <div class="item"> | ||
| 70 | + <input type="button" value="开启测距" onclick="myDis.open();" | ||
| 71 | + style="width: 75px" /> <input type="button" value="关闭测距" | ||
| 72 | + onclick="myDis.close()" style="width: 75px" /> | ||
| 73 | + | ||
| 74 | + </div> | ||
| 75 | + | ||
| 76 | + <div class="item"> | ||
| 77 | + <a target="_blank" href="http://tool.chinaz.com/Tools/unixtime.aspx" | ||
| 78 | + style="font-size: 12px; color: red;">毫秒时间戳转换</a> | ||
| 79 | + </div> | ||
| 80 | + </form> | ||
| 81 | + | ||
| 82 | + <div id="mapContainer"></div> | ||
| 83 | + <script src="/assets/plugins/pinyin.js"></script> | ||
| 84 | + <script src="/metronic_v4.5.4/plugins/jquery.min.js"></script> | ||
| 85 | + <script src="/assets/plugins/jquery.serializejson.js"></script> | ||
| 86 | + <script | ||
| 87 | + src="//api.map.baidu.com/api?v=2.0&ak=IGGrr4UjwIYzatoCRFKEL8sT"></script> | ||
| 88 | + <script type="text/javascript" | ||
| 89 | + src="//api.map.baidu.com/library/DistanceTool/1.2/src/DistanceTool_min.js"></script> | ||
| 90 | + <!-- moment.js 日期处理类库 --> | ||
| 91 | + <script src="/assets/plugins/moment-with-locales.js"></script> | ||
| 92 | + <!-- select2 下拉框 --> | ||
| 93 | + <script src="/metronic_v4.5.4/plugins/select2/js/select2.full.min.js"></script> | ||
| 94 | + <script> | ||
| 95 | + | ||
| 96 | + var inMark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAA1CAYAAABSrotqAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAGW0lEQVRYw62XX2wc1RWHv3vv7NhrQkKCIa0poaKRmjdUFUGr+IH+ITy0Kg/0qVRV1ZamVV95al94oPSBVmoRUZTIKRFBLW1aapBK6gIChYTgFJRQHoITqCCO7eC1vY7t2Z1/954+zK69Xs9mx4mPdLWjmTvnO79z7zl3VlHAvv3XmXuM8R4EBpVSu1DqpiQRBJlH5APn5KQ4NzzycP/pbr7U1R5+6y+Vr2njP6EVX1FKoRTZAOJUQMBlP4gIIrwtNvnlyMO3vL4u4AND49vMjZsOaqMfUgpMA+ZEiBJIrJAkQslT+B4YrXACzknj1x4N6rWfnfrJ7XNdgd888NEOs+XmEaPVLq0zRVEiRGnmsGlJsnKtFfT4ih5PIQJWwDr3QRJUHzix9wsXOwLvOzDW72269ZQxeqcxIAL1WLAtoDzgMlgr+vwsG6kTrOXDoDL91Xcf/eLM8pxWuJT7j4hSO5UC66AW5cM6mXNCEDmsA60UAjv9rf1HWoU1L9Tg0OT3dU/5Wd9TeFpRiwWRFZhNhSvTMbX5hDh0uNhR6jWUb/LYvL0H460kSyko+xrrhCgVJAp/MPrzgecAMVkuH/PuuHv335VSW3s8TZgIrgUWzKdMXagRLqU4KygF4gRnhSiwLFZivF6N32tWAhTwPUWSCmhz18RC3z4+fsNpgN3f+/H9oO4ESO3qNNaupFQ+qWeRa5U7AGY/rlO7kq5Kb+qkUUrqzru/+8M9zTXUeKUHs92miG3LmlhhbjJCGVVoVCdCnG3ZyamgVRaQLvV+B9AeoJUu3QtgdLZWy6mspgigzdpyFS+/ZwTVhBv7/WyOgDbZBtTa3NMEKqX0Dsg6RqvFoUN3cOyczr2f1F3+FtbmDkB5gEKzFQFr215OBe3lO9Yu33GSrg47XUnxtiYQRKUgpdadCaAbnSMfmK+8Pf3L74ssATSAtorSt7a/vKnPUA87pMhTa9cAKJfzMwKysAwU56aUWQvcssUQJ/lA6aBw8xaPJHe+m4asLERcOpb3cvkGg1/SeEatGSZn+CVFeZPJDQRnxwDJgDY5nzcniIXbBkq5zo3Jyqg5PAMDAz5BlL/oLo0uLAOT4MqZvEnWCbEoPjfgU/LUKoDRK/BSSXHbgE8kqmOzt+HiGUA8QBY+Ov127823u0YAq1VGDno0n9/hs7BoWQocSSKIQKmk6OvTbN5sqAZCLeqw3uBmz791ChBFdmL4g4dnziptdnXYYhit2FxWlH2N72WHcmqhFjkW61c/xsTZc6OP3PIlIPayAHA2Dt/wem/oCLROqAZCNchU5B3AnczF9dcBR0sKxQZzI4U9rNOS+vwrDWHLJ76bOH7gTZBwo2GCBDOv/OF4Q+EyUCb+sW/JJeGxDQfG4b8vjRwK2hUKYNPF6gsbDUyC6lHAtgMB3NTfnv5ns+dtkL6F2eF9/6KRznagXDyxvyZx9PJG4WxUf+niif01Wtr8KiBgo8VPj24UMA5mXqAlne1AAPfhc79+DZHZ66aJq0wM/eJVWtKZB5Tqu0frNlr80/Xy0jB4fmbsZNQVCNj6+LlDoFxh7+2mkHjy3OFGOtse5U2H3sE/Xn5ZeT33dfJ5tdYmNjk5+tPt9wMhbd8Fed8DAqTJwuyhaxWYLM4MASk5HyGdPkDshT8/+hLiLq8XJuIu/+/Ir4bz0nk1oMyNHgttuPTseoGuvnh4/uzwqtorBATszNnXDqyvoUu48N6rB2mrvSJAAHd+/48mbVgr3AhsGDw/NvTIFG2lUBQoQFr/5L2nipSIgAvH//s0HTZL01QXPwro3X3o8rAu9expfdBeFpJGx0b3fvYhckqhqMJllVFl/PfdFNanx5/qpq6IwmZQvYPPTB9XpvTlPIWSxqOjez/z9YY6181ZN3NAEs5d+k2nCfHc5JNA0g1WVGGLyspbynh3tSp0aXLm9N7tg0XUFVXYVJlG81NPrlE3P/k7srUr1OyLAgHS/zzxjRex9v3mDbHp+2d/u+fFBrBwqoqaUKnEYfXS480b4dzk41QqMV125vWYBvoGn5l+596Dn74D9K0z6MY/4M7WvqkESOPK+GNRlsRm3eXNK+SwVYkPlBpBacA05uvGfVgpBSFr2K4RRALE5GykTif+toZT1WFu87pVSft1Asy1q70WhYrVwOa4ZoXred7JOq7h/wF6az0ukZgX/AAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxNS0wNy0yNVQyMTo1MDo0MyswODowMOgS43cAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTMtMTEtMjBUMjI6NDc6MTErMDg6MDAou1syAAAATnRFWHRzb2Z0d2FyZQBJbWFnZU1hZ2ljayA2LjguOC0xMCBRMTYgeDg2XzY0IDIwMTUtMDctMTkgaHR0cDovL3d3dy5pbWFnZW1hZ2ljay5vcmcFDJw1AAAAGHRFWHRUaHVtYjo6RG9jdW1lbnQ6OlBhZ2VzADGn/7svAAAAF3RFWHRUaHVtYjo6SW1hZ2U6OkhlaWdodAA1Mwmpb+QAAAAWdEVYdFRodW1iOjpJbWFnZTo6V2lkdGgAMjgpleAmAAAAGXRFWHRUaHVtYjo6TWltZXR5cGUAaW1hZ2UvcG5nP7JWTgAAABd0RVh0VGh1bWI6Ok1UaW1lADEzODQ5NTg4MzEXUMEwAAAAE3RFWHRUaHVtYjo6U2l6ZQA0LjUzS0JC/AyPiAAAAFp0RVh0VGh1bWI6OlVSSQBmaWxlOi8vL2hvbWUvd3d3cm9vdC93d3cuZWFzeWljb24ubmV0L2Nkbi1pbWcuZWFzeWljb24uY24vc3JjLzExMjk3LzExMjk3NzIucG5nqXNeUQAAAABJRU5ErkJggg=='; | ||
| 97 | + var outMark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAvCAMAAAC18jgTAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAABO1BMVEUAAAAiu4ggv40gvowgvowgvosgvowfvo0jv44hv40gvosgvowcxo4fvowgvowdvYogv4whvo0gvowhvYwrqoAhv4wnxIkgv4wA//8gvIshvosgvowhvIshvowgvowrv5Ugv4ohvosgvowhv4wgv4whvYwXuYsgvowgvowiu4gfvo0zzJkhvowktpIgvowgv40hvo0gv4wgvowAqqogvosgvowjv4sgvowivIskv4khvowgvYsiu44hvosfvI0hv4sgvYofvowgvowgv40gv4wjuYsgvowhvowfvIsgvYsgvo0hvoxAv4Agv4wgvowgvoshvo0mv4whvowgvowfwo8gv4wgv40duokAAAAfvYsgvYwAAAAAAAAAAAAAAAAAAAAAAAAAAAAYjGUYj2kAAAAAAAAAAAAgvoz///9v2GMAAAAAZ3RSTlMAD1eZyOr4miSc950Jivoj0i/pfAarDaoBWH3JLuv5DDDL0ZunbQvu/h6CBbQO5jhOkNwDtfAsz0Qc42EtdUGLYKKOwsYW7/s5f7nMBCj9N40U8/YZh48aAaOmAggNERMWF0lLGBkanzLKGQAAAAFiS0dEaMts9CIAAAGZSURBVDjLfZRnW8IwFIUvyN6FUlCx4AZxKw7cA/eeKKNUwfz/f2ChZNAmnC+U+54m9548KQCRwznicns8bpfX6QC7fP4AIgoEfRYcCkfQgCLhEMujMWRTLEq55EYcuSXyPpcbjv4aoRgSKGb2EUZChXvzRcSGSHfaIP0fT0iyLCXitOI38qP5JBWzKSVFE3OAk/I0HiudJMVR8JL1FRqMQgb3ggs/Jthox3B1HIg3wxoyuDoBKn6UWYOMqyp4uIYsNfC3yNEtJoc3OQXT3DFJmDNMUCkaFI1yFubmqcMedb4AsMAeVqaYzbGHtWj4l5bFx51f6a64mhca/OaeayK+3m9qY5PPS1tk7G0eV3doMLtlToN7bLT7JZvhYPByHqoWfmS93ceD/CRtNcApy89kG4fiOeXlCucLAoULzC+vgCvSxjUIdGPy2zuR4b53jx8eQagn5gi5en5B6PVtiAHeEfoYxqHiUT9FrNrT17f5a8O1eqOptXT951fXW1qzUa9ZXtfanU7nry/jsa1VuSsYtjZ3BdIDFin/A1AVNdoKDyAYAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE1LTA3LTI1VDIxOjUwOjQzKzA4OjAw6BLjdwAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxMy0xMS0yMFQyMjo0NzoxMyswODowML8kShsAAABOdEVYdHNvZnR3YXJlAEltYWdlTWFnaWNrIDYuOC44LTEwIFExNiB4ODZfNjQgMjAxNS0wNy0xOSBodHRwOi8vd3d3LmltYWdlbWFnaWNrLm9yZwUMnDUAAAAYdEVYdFRodW1iOjpEb2N1bWVudDo6UGFnZXMAMaf/uy8AAAAXdEVYdFRodW1iOjpJbWFnZTo6SGVpZ2h0ADQ3F9+avAAAABZ0RVh0VGh1bWI6OkltYWdlOjpXaWR0aAAzMtBbOHkAAAAZdEVYdFRodW1iOjpNaW1ldHlwZQBpbWFnZS9wbmc/slZOAAAAF3RFWHRUaHVtYjo6TVRpbWUAMTM4NDk1ODgzM/leoBwAAAATdEVYdFRodW1iOjpTaXplADQuMDFLQkKe5chzAAAAWnRFWHRUaHVtYjo6VVJJAGZpbGU6Ly8vaG9tZS93d3dyb290L3d3dy5lYXN5aWNvbi5uZXQvY2RuLWltZy5lYXN5aWNvbi5jbi9zcmMvMTEyOTcvMTEyOTc4Ni5wbmetpUpEAAAAAElFTkSuQmCC'; | ||
| 98 | + | ||
| 99 | + var inOuts = [outMark, inMark]; | ||
| 100 | + | ||
| 101 | + var stationCodeMap = {}; | ||
| 102 | + | ||
| 103 | + var map = new BMap.Map("mapContainer"); | ||
| 104 | + map.centerAndZoom(new BMap.Point(121.544336, 31.221315), 15); | ||
| 105 | + map.enableScrollWheelZoom(); | ||
| 106 | + //中心点和缩放级别 | ||
| 107 | + map.setCurrentCity("上海"); | ||
| 108 | + var myDis = new BMapLib.DistanceTool(map); | ||
| 109 | + | ||
| 110 | + | ||
| 111 | + $.get('/line/all', function(rs){ | ||
| 112 | + var data = []; | ||
| 113 | + $.each(rs, function(){ | ||
| 114 | + data.push({id: this.id, text: this.name}); | ||
| 115 | + }); | ||
| 116 | + | ||
| 117 | + initPinYinSelect2('select[name=xl]', data); | ||
| 118 | + }); | ||
| 119 | + | ||
| 120 | + function searchGps(){ | ||
| 121 | + var params = $('form').serializeJSON(); | ||
| 122 | + //查询线路路由站点 | ||
| 123 | + $.get('/test/gps/route', params, function(rs){ | ||
| 124 | + var array = rs[0].children[0].children | ||
| 125 | + ,coords,circle, cdsArray, points, polygon; | ||
| 126 | + //画出站点 | ||
| 127 | + console.log(array); | ||
| 128 | + $.each(array, function(){ | ||
| 129 | + stationCodeMap[this.stationStationCod] = this.name; | ||
| 130 | + if(this.stationShapesType === 'r'){ | ||
| 131 | + //画圆 | ||
| 132 | + coords = this.stationBJwpoints.split(' '); | ||
| 133 | + circle = new BMap.Circle(new BMap.Point(coords[0], coords[1]),this.stationRadius); | ||
| 134 | + circle.setStrokeColor('red'); | ||
| 135 | + circle.setStrokeWeight(2) | ||
| 136 | + map.addOverlay(circle); | ||
| 137 | + } | ||
| 138 | + else if(this.stationShapesType === 'd'){ | ||
| 139 | + //画多边形 | ||
| 140 | + coords = this.stationBPolygonGrid.substring(9, this.stationBPolygonGrid.length - 2); | ||
| 141 | + cdsArray = coords.split(','); | ||
| 142 | + points = []; | ||
| 143 | + $.each(cdsArray, function(){ | ||
| 144 | + coords = this.split(' '); | ||
| 145 | + points.push(new BMap.Point(coords[0], coords[1])); | ||
| 146 | + }); | ||
| 147 | + | ||
| 148 | + polygon = new BMap.Polygon(points, {strokeColor:"red", strokeWeight:2, strokeOpacity:0.5}); | ||
| 149 | + map.addOverlay(polygon); | ||
| 150 | + } | ||
| 151 | + }); | ||
| 152 | + coords = array[array.length / 2].stationBJwpoints.split(' '); | ||
| 153 | + map.setCenter(new BMap.Point(coords[0], coords[1])) | ||
| 154 | + }); | ||
| 155 | + | ||
| 156 | + //查询gps点 | ||
| 157 | + $.get('/gps/history/' + params.device, params, function(gpsArray){ | ||
| 158 | + console.log(stationCodeMap); | ||
| 159 | + var marker, label, point, state, text; | ||
| 160 | + $.each(gpsArray, function(){ | ||
| 161 | + point = new BMap.Point(this.lon, this.lat); | ||
| 162 | + marker = new BMap.Marker(point); | ||
| 163 | + state = this.inout_stop; | ||
| 164 | + | ||
| 165 | + if(state == 0 || state == 1){ | ||
| 166 | + text = state == 0?'出':'进'; | ||
| 167 | + | ||
| 168 | + console.log(stationCodeMap[this.stopNo], this); | ||
| 169 | + marker.setIcon(new BMap.Icon(inOuts[this.inout_stop], new BMap.Size(25,25))); | ||
| 170 | + label = new BMap.Label( | ||
| 171 | + stationCodeMap[this.stopNo] + '/' +moment(this.ts).format('HH:mm.ss') + ' -'+text | ||
| 172 | + , {position: point, offset: new BMap.Size(-25,-18)}); | ||
| 173 | + marker.setLabel(label); | ||
| 174 | + } | ||
| 175 | + else{ | ||
| 176 | + label = new BMap.Label(moment(this.ts).format('HH:mm.ss') | ||
| 177 | + , {position: point, offset: new BMap.Size(-25,-18)}); | ||
| 178 | + marker.setLabel(label); | ||
| 179 | + } | ||
| 180 | + | ||
| 181 | + map.addOverlay(marker); | ||
| 182 | + }); | ||
| 183 | + }); | ||
| 184 | + } | ||
| 185 | + | ||
| 186 | + | ||
| 187 | + /** | ||
| 188 | + * 支持拼音搜索的select2 | ||
| 189 | + * @param selector | ||
| 190 | + * @param data | ||
| 191 | + */ | ||
| 192 | + function initPinYinSelect2(selector, data, cb){ | ||
| 193 | + | ||
| 194 | + $.each(data, function(){ | ||
| 195 | + this.fullChars = pinyin.getFullChars(this.text).toUpperCase(); | ||
| 196 | + this.camelChars = pinyin.getCamelChars(this.text); | ||
| 197 | + }); | ||
| 198 | + | ||
| 199 | + $.fn.select2.amd.require(['select2/compat/matcher'], function (oldMatcher) { | ||
| 200 | + $(selector).select2({ | ||
| 201 | + data: data, | ||
| 202 | + matcher: oldMatcher(function(term, text, item){ | ||
| 203 | + var upTerm = term.toUpperCase(); | ||
| 204 | + if(item.fullChars.indexOf(upTerm) != -1 | ||
| 205 | + || item.camelChars.indexOf(upTerm) != -1) | ||
| 206 | + return true; | ||
| 207 | + | ||
| 208 | + return text.indexOf(term) != -1; | ||
| 209 | + }) | ||
| 210 | + }); | ||
| 211 | + | ||
| 212 | + cb && cb(); | ||
| 213 | + }); | ||
| 214 | + | ||
| 215 | + return $(selector); | ||
| 216 | + } | ||
| 217 | +</script> | ||
| 218 | +</body> | ||
| 219 | +</html> |
src/main/resources/static/index.html
| @@ -220,7 +220,7 @@ | @@ -220,7 +220,7 @@ | ||
| 220 | <!-- LOGO --> | 220 | <!-- LOGO --> |
| 221 | <div class="page-logo"> | 221 | <div class="page-logo"> |
| 222 | <a href="index.html" class="logo-default logo-default-text"> | 222 | <a href="index.html" class="logo-default logo-default-text"> |
| 223 | - 临港公交调度系统 </a> | 223 | + 浦东公交调度系统 </a> |
| 224 | <div class="menu-toggler sidebar-toggler"></div> | 224 | <div class="menu-toggler sidebar-toggler"></div> |
| 225 | </div> | 225 | </div> |
| 226 | <!-- END LOGO --> | 226 | <!-- END LOGO --> |
src/main/resources/static/login.html
| @@ -181,7 +181,7 @@ | @@ -181,7 +181,7 @@ | ||
| 181 | <div class="wrapper ng-scope"> | 181 | <div class="wrapper ng-scope"> |
| 182 | <div id="loginPanel" class="dialog dialog-shadow"> | 182 | <div id="loginPanel" class="dialog dialog-shadow"> |
| 183 | <br> | 183 | <br> |
| 184 | - <h3 class="logo-text">临港公交调度系统</h3> | 184 | + <h3 class="logo-text">浦东公交调度系统</h3> |
| 185 | <hr> | 185 | <hr> |
| 186 | <form style="padding: 0px 35px;"> | 186 | <form style="padding: 0px 35px;"> |
| 187 | <div class="form-group" style="margin-bottom: 0"> | 187 | <div class="form-group" style="margin-bottom: 0"> |
src/main/resources/static/pages/base/geo_data_edit/main.html
| 1 | -<!DOCTYPE html> | ||
| 2 | -<html lang="zh-cn"> | ||
| 3 | - | ||
| 4 | -<head> | ||
| 5 | - <meta charset="UTF-8"> | ||
| 6 | - <link rel="stylesheet" href="/assets/plugins/uk3.0/uikit.min.css"/> | ||
| 7 | - <link rel="stylesheet" href="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.css" /> | ||
| 8 | - <!-- jquery contextMenu style --> | ||
| 9 | - <link rel="stylesheet" href="/real_control_v2/assets/css/jquery.contextMenu.min.css" /> | ||
| 10 | - <link rel="stylesheet" | ||
| 11 | - href="http://api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.css" | ||
| 12 | - type="text/css" /> | ||
| 13 | - <!-- main css --> | ||
| 14 | - <link rel="stylesheet" href="/pages/base/geo_data_edit/css/mian.css" /> | ||
| 15 | - <link rel="stylesheet" href="/real_control_v2/assets/plugins/flatpickr/flatpickr.min.css"> | ||
| 16 | -</head> | ||
| 17 | - | ||
| 18 | -<body> | ||
| 19 | -<div class="loading"> | ||
| 20 | - <div><span uk-spinner></span><span class="text">正在加载...</span></div> | ||
| 21 | -</div> | ||
| 22 | -<div class="ct_page" > | ||
| 23 | - <div class="instructions_tips uk-animation-slide-top-medium"> | ||
| 24 | - <button type="button" uk-close></button> | ||
| 25 | - <div> | ||
| 26 | - <h4>说明</h4> | ||
| 27 | - <ul class="uk-list"> | ||
| 28 | - <li>1、所有的改道、缩线、并线等对走向调整都必须新建版本,以保留原走向版本。</li> | ||
| 29 | - <li>2、只有在人工数据录入错误的情况下,才有理由对当前启用的版本进行走向编辑。</li> | ||
| 30 | - <li>3、走向版本可以任意切换,但是必须维护好一个准确的“版本切换记录”。</li> | ||
| 31 | - <hr> | ||
| 32 | - <li>4、调整缓冲区、修改站点名称、修改路段名称 不算走向调整,不需要新建版本。</li> | ||
| 33 | - </ul> | ||
| 34 | - </div> | ||
| 35 | - </div> | ||
| 36 | - <div id="map_wrap"></div> | ||
| 37 | - <div class="main_left_panel_m_layer"></div> | ||
| 38 | - <div class="main_left_panel"> | ||
| 39 | - <div class="_line_info"> | ||
| 40 | - <div class="_line_name"> | ||
| 41 | - <a class="dropdown_txt"></a> | ||
| 42 | - <div class="line_change_panel" uk-dropdown="mode: click"> | ||
| 43 | - <div class="uk-inline"> | ||
| 44 | - <a class="uk-form-icon uk-form-icon-flip" uk-icon="icon: search"></a> | ||
| 45 | - <input class="uk-input" type="text" id="line_search_input"> | ||
| 46 | - </div> | ||
| 47 | - <ul class="uk-list"></ul> | ||
| 48 | - </div> | ||
| 49 | - | ||
| 50 | - | ||
| 51 | - | ||
| 52 | - <a uk-icon="icon: trash" class="remove_line_version_icon uk-animation-slide-right-small" title="删除线路版本" style="display: none" uk-tooltip></a> | ||
| 53 | - <a uk-icon="icon: plus" class="add_line_version_icon" title="新增一个线路版本" uk-tooltip></a> | ||
| 54 | - </div> | ||
| 55 | - <div class="_version_dropdown_wrap"> | ||
| 56 | - <a class="_version_text"></a> | ||
| 57 | - <div uk-dropdown> | ||
| 58 | - <ul class="uk-nav uk-dropdown-nav all_version_list"> | ||
| 59 | - </ul> | ||
| 60 | - </div> | ||
| 61 | - </div> | ||
| 62 | - <a class="clock_enable_version"></a> | ||
| 63 | - </div> | ||
| 64 | - | ||
| 65 | - <div class="_route_info_wrap"> | ||
| 66 | - <ul uk-tab> | ||
| 67 | - <li><a>上行</a></li> | ||
| 68 | - <li><a>下行</a></li> | ||
| 69 | - | ||
| 70 | - </ul> | ||
| 71 | - | ||
| 72 | - <ul class="uk-switcher uk-margin up_down_route_list"> | ||
| 73 | - <li> | ||
| 74 | - <div class="station_route"></div> | ||
| 75 | - <div class="road_route"></div> | ||
| 76 | - </li> | ||
| 77 | - <li> | ||
| 78 | - <div class="station_route"></div> | ||
| 79 | - <div class="road_route"></div> | ||
| 80 | - </li> | ||
| 81 | - </ul> | ||
| 82 | - <div class="pos_tb_icon"> | ||
| 83 | - <a uk-icon="icon: chevron-down;"></a> | ||
| 84 | - </div> | ||
| 85 | - </div> | ||
| 86 | - </div> | ||
| 87 | - <div class="main_lt_search_panel"> | ||
| 88 | - <div class="uk-inline ct_s_i_wrap"> | ||
| 89 | - <span class="uk-form-icon uk-form-icon-flip" uk-icon="icon: search"></span> | ||
| 90 | - <input class="uk-input ct_search_input" placeholder="搜索地图位置" type="text"> | ||
| 91 | - </div> | ||
| 92 | - <div class="ct_search_result"></div> | ||
| 93 | - </div> | ||
| 94 | - <div class="main_rt_tools_panel"> | ||
| 95 | - <!--<a style="color: red;" uk-icon="icon: unlock;ratio: .9" class="_icon" title="当前版本有变更未启用" uk-tooltip="pos:bottom"></a>--> | ||
| 96 | - | ||
| 97 | - <a uk-icon="icon: bookmark;ratio: .9" class="_icon" title="走向版本变更记录" uk-tooltip="pos:bottom"></a> | ||
| 98 | - <a uk-icon="icon: expand;ratio: .9" class="_icon full_screen_icon"></a> | ||
| 99 | - </div> | ||
| 100 | -</div> | ||
| 101 | - | ||
| 102 | -<script id="geo_d_e_search_result-temp" type="text/html"> | ||
| 103 | - <ul class="s_list uk-list"> | ||
| 104 | - {{each list as obj i}} | ||
| 105 | - <li data-lat="{{obj.point.lat}}" data-lng="{{obj.point.lng}}"> | ||
| 106 | - <span class="_title">{{obj.title}}</span> | ||
| 107 | - <span class="_address">{{obj.address}}</span> | ||
| 108 | - </li> | ||
| 109 | - {{/each}} | ||
| 110 | - | ||
| 111 | - {{if list.length==0}} | ||
| 112 | - <li class="_empty">没有搜索到相关数据!</li> | ||
| 113 | - {{/if}} | ||
| 114 | - </ul> | ||
| 115 | -</script> | ||
| 116 | - | ||
| 117 | -<script id="geo_d_e_dropdown_list-temp" type="text/html"> | ||
| 118 | - {{each list as obj i}} | ||
| 119 | - <li data-code="{{obj.code}}"> | ||
| 120 | - <div class="name">{{obj.name}}</div> | ||
| 121 | - <div class="code">{{obj.code}}</div> | ||
| 122 | - </li> | ||
| 123 | - {{/each}} | ||
| 124 | - {{if ellipsis}} | ||
| 125 | - <li>...</li> | ||
| 126 | - {{/if}} | ||
| 127 | -</script> | ||
| 128 | -<!-- 百度 --> | ||
| 129 | -<script src="http://api.map.baidu.com/api?v=2.0&ak=IGGrr4UjwIYzatoCRFKEL8sT"></script> | ||
| 130 | -<script src="/metronic_v4.5.4/plugins/jquery.min.js"></script> | ||
| 131 | -<script src="/assets/plugins/uk3.0/uikit.min.js"></script> | ||
| 132 | -<script src="/assets/plugins/uk3.0/uikit-icons.min.js"></script> | ||
| 133 | -<script src="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.jquery.js" ></script> | ||
| 134 | -<!-- EventProxy --> | ||
| 135 | -<script src="/assets/js/eventproxy.js"></script> | ||
| 136 | -<!-- art-template 模版引擎 --> | ||
| 137 | -<script src="/assets/plugins/template.js"></script> | ||
| 138 | -<script src="/real_control_v2/assets/plugins/moment/moment.min.js"></script> | ||
| 139 | -<!-- jquery.serializejson JSON序列化插件 --> | ||
| 140 | -<script src="/assets/plugins/jquery.serializejson.js" merge="plugins"></script> | ||
| 141 | -<!-- common js --> | ||
| 142 | -<script src="/pages/base/geo_data_edit/js/ct_common.js"></script> | ||
| 143 | -<script src="/assets/js/TransGPS.js" ></script> | ||
| 144 | -<!-- Geolib --> | ||
| 145 | -<script src="/real_control_v2/geolib/geolib.js" ></script> | ||
| 146 | -<!-- jquery contextMenu --> | ||
| 147 | -<script src="/real_control_v2/assets/js/jquery.contextMenu.min.js" ></script> | ||
| 148 | -<script src="/assets/js/baidu/bd_GeoUtils_min.js" ></script> | ||
| 149 | -<!-- flatpickr --> | ||
| 150 | -<script src="/real_control_v2/assets/plugins/flatpickr/flatpickr.min.js" ></script> | ||
| 151 | -<script src="/real_control_v2/assets/plugins/flatpickr/l10n/zh.js" ></script> | ||
| 152 | -<script src="/assets/plugins/pinyin.js"></script> | ||
| 153 | - | ||
| 154 | -<script> | ||
| 155 | - var $loadPanel = $('body>.loading'); | ||
| 156 | - //___________________________________ | ||
| 157 | - var storage = window.localStorage; | ||
| 158 | - //___________________________________ | ||
| 159 | - | ||
| 160 | - top.document.title = "绘制线路"; | ||
| 161 | - | ||
| 162 | - // 关闭左侧栏 | ||
| 163 | - if (!top.$('body').hasClass('page-sidebar-closed')) {top.$('.menu-toggler.sidebar-toggler').click();} | ||
| 164 | - //全屏 | ||
| 165 | - $('.full_screen_icon').on('click', function () { | ||
| 166 | - var $iframe = window.parent.$('#geo_edit_wrap_iframe'), | ||
| 167 | - icon; | ||
| 168 | - if($(this).attr('uk-icon').indexOf('expand') != -1){ | ||
| 169 | - $iframe.addClass('full_screen'); | ||
| 170 | - icon = 'shrink'; | ||
| 171 | - } | ||
| 172 | - else{ | ||
| 173 | - $iframe.removeClass('full_screen'); | ||
| 174 | - icon = 'expand'; | ||
| 175 | - } | ||
| 176 | - $(this).attr('uk-icon', 'icon: '+icon+';ratio: .9'); | ||
| 177 | - }); | ||
| 178 | - | ||
| 179 | - var gb_main_ep; | ||
| 180 | - //文件加载 | ||
| 181 | - var res_load_ep = EventProxy.create('load_common_data', 'load_station_route','load_road_route' | ||
| 182 | - , 'load_version_manage', 'load_history_edit_logs', 'load_map', function () { | ||
| 183 | - startup(function () { | ||
| 184 | - $('.instructions_tips').show(); | ||
| 185 | - }); | ||
| 186 | - | ||
| 187 | - gb_change_line.init(); | ||
| 188 | - }); | ||
| 189 | - | ||
| 190 | - var g_line_code; | ||
| 191 | - var g_version; | ||
| 192 | - var startup = function (cb) { | ||
| 193 | - g_line_code = storage.getItem('geo_data_edit_line_code'); | ||
| 194 | - | ||
| 195 | - gb_main_ep = new EventProxy(); | ||
| 196 | - var eq = gb_main_ep; | ||
| 197 | - | ||
| 198 | - //站点 | ||
| 199 | - gb_station_route.init(g_emit('init_road')); | ||
| 200 | - //路段 | ||
| 201 | - eq.once('init_road', function () { | ||
| 202 | - gb_road_route.init(g_emit('init_map')) | ||
| 203 | - }); | ||
| 204 | - //地图 | ||
| 205 | - eq.once('init_map', function () { | ||
| 206 | - gb_ct_map._render(g_emit('end')); | ||
| 207 | - }); | ||
| 208 | - | ||
| 209 | - eq.once('end', function () { | ||
| 210 | - //线路版本信息 | ||
| 211 | - gb_version_manage.init(storage.getItem("geo_data_edit_line_version")); | ||
| 212 | - | ||
| 213 | - $loadPanel.hide(); | ||
| 214 | - gb_ct_search.init(); | ||
| 215 | - | ||
| 216 | - cb && cb(); | ||
| 217 | - }); | ||
| 218 | - }; | ||
| 219 | - | ||
| 220 | - var clearAll = function () { | ||
| 221 | - $('.up_down_route_list .station_route').empty(); | ||
| 222 | - $('.up_down_route_list .road_route').empty(); | ||
| 223 | - gb_ct_map.clearAll(); | ||
| 224 | - }; | ||
| 225 | - | ||
| 226 | - function g_emit(id) { | ||
| 227 | - console.log('g_emit [' + id + ']'); | ||
| 228 | - return function () { | ||
| 229 | - console.log('eq.emitLater(' + id + ')'); | ||
| 230 | - return gb_main_ep.emitLater(id); | ||
| 231 | - }; | ||
| 232 | - } | ||
| 233 | - | ||
| 234 | - //滚动条 | ||
| 235 | - $('._route_info_wrap>ul.uk-switcher').perfectScrollbar({suppressScrollX: true}); | ||
| 236 | - | ||
| 237 | - //to top btttom | ||
| 238 | - $('.pos_tb_icon a').on('click', function () { | ||
| 239 | - UIkit.notification('top top...'); | ||
| 240 | - }); | ||
| 241 | - | ||
| 242 | - function getUpDown(){ | ||
| 243 | - return $('.up_down_route_list>li:first').hasClass('uk-active')?0:1; | ||
| 244 | - } | ||
| 245 | - | ||
| 246 | - //切换上下行显示 | ||
| 247 | - $('.up_down_route_list').on('show', function () { | ||
| 248 | - gb_ct_map.changeUpDown(); | ||
| 249 | - }); | ||
| 250 | - | ||
| 251 | - $(document).on('submit', 'form', function (e) { | ||
| 252 | - e.stopPropagation(); | ||
| 253 | - return false; | ||
| 254 | - }); | ||
| 255 | - | ||
| 256 | - $(document).on('click', 'button.cancel', function (e) { | ||
| 257 | - e.stopPropagation(); | ||
| 258 | - return false; | ||
| 259 | - }); | ||
| 260 | - | ||
| 261 | - //关闭说明 | ||
| 262 | - $('.instructions_tips .uk-close').on('click', function () { | ||
| 263 | - $('.instructions_tips').remove(); | ||
| 264 | - }); | ||
| 265 | -</script> | ||
| 266 | - | ||
| 267 | - | ||
| 268 | -<script src="/pages/base/geo_data_edit/js/server_timer.js" ></script> | ||
| 269 | -<!--- js --> | ||
| 270 | -<script src="/pages/base/geo_data_edit/js/common_data.js" ></script> | ||
| 271 | -<script src="/pages/base/geo_data_edit/js/station_route.js" ></script> | ||
| 272 | -<script src="/pages/base/geo_data_edit/js/road_route.js" ></script> | ||
| 273 | -<script src="/pages/base/geo_data_edit/js/version_manage.js" ></script> | ||
| 274 | -<script src="/pages/base/geo_data_edit/js/history_edit_logs.js" ></script> | ||
| 275 | -<script src="/pages/base/geo_data_edit/js/map.js" ></script> | ||
| 276 | -<script src="/pages/base/geo_data_edit/js/submit.js" ></script> | ||
| 277 | -<script src="/pages/base/geo_data_edit/js/search.js" ></script> | ||
| 278 | -<script src="/pages/base/geo_data_edit/js/change_line.js" ></script> | ||
| 279 | - | ||
| 280 | -<script type="text/javascript" | ||
| 281 | - src="http://api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.js"></script> | ||
| 282 | -</body> | 1 | +<!DOCTYPE html> |
| 2 | +<html lang="zh-cn"> | ||
| 3 | + | ||
| 4 | +<head> | ||
| 5 | + <meta charset="UTF-8"> | ||
| 6 | + <link rel="stylesheet" href="/assets/plugins/uk3.0/uikit.min.css"/> | ||
| 7 | + <link rel="stylesheet" href="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.css" /> | ||
| 8 | + <!-- jquery contextMenu style --> | ||
| 9 | + <link rel="stylesheet" href="/real_control_v2/assets/css/jquery.contextMenu.min.css" /> | ||
| 10 | + <link rel="stylesheet" | ||
| 11 | + href="//api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.css" | ||
| 12 | + type="text/css" /> | ||
| 13 | + <!-- main css --> | ||
| 14 | + <link rel="stylesheet" href="/pages/base/geo_data_edit/css/mian.css" /> | ||
| 15 | + <link rel="stylesheet" href="/real_control_v2/assets/plugins/flatpickr/flatpickr.min.css"> | ||
| 16 | +</head> | ||
| 17 | + | ||
| 18 | +<body> | ||
| 19 | +<div class="loading"> | ||
| 20 | + <div><span uk-spinner></span><span class="text">正在加载...</span></div> | ||
| 21 | +</div> | ||
| 22 | +<div class="ct_page" > | ||
| 23 | + <div class="instructions_tips uk-animation-slide-top-medium"> | ||
| 24 | + <button type="button" uk-close></button> | ||
| 25 | + <div> | ||
| 26 | + <h4>说明</h4> | ||
| 27 | + <ul class="uk-list"> | ||
| 28 | + <li>1、所有的改道、缩线、并线等对走向调整都必须新建版本,以保留原走向版本。</li> | ||
| 29 | + <li>2、只有在人工数据录入错误的情况下,才有理由对当前启用的版本进行走向编辑。</li> | ||
| 30 | + <li>3、走向版本可以任意切换,但是必须维护好一个准确的“版本切换记录”。</li> | ||
| 31 | + <hr> | ||
| 32 | + <li>4、调整缓冲区、修改站点名称、修改路段名称 不算走向调整,不需要新建版本。</li> | ||
| 33 | + </ul> | ||
| 34 | + </div> | ||
| 35 | + </div> | ||
| 36 | + <div id="map_wrap"></div> | ||
| 37 | + <div class="main_left_panel_m_layer"></div> | ||
| 38 | + <div class="main_left_panel"> | ||
| 39 | + <div class="_line_info"> | ||
| 40 | + <div class="_line_name"> | ||
| 41 | + <a class="dropdown_txt"></a> | ||
| 42 | + <div class="line_change_panel" uk-dropdown="mode: click"> | ||
| 43 | + <div class="uk-inline"> | ||
| 44 | + <a class="uk-form-icon uk-form-icon-flip" uk-icon="icon: search"></a> | ||
| 45 | + <input class="uk-input" type="text" id="line_search_input"> | ||
| 46 | + </div> | ||
| 47 | + <ul class="uk-list"></ul> | ||
| 48 | + </div> | ||
| 49 | + | ||
| 50 | + | ||
| 51 | + | ||
| 52 | + <a uk-icon="icon: trash" class="remove_line_version_icon uk-animation-slide-right-small" title="删除线路版本" style="display: none" uk-tooltip></a> | ||
| 53 | + <a uk-icon="icon: plus" class="add_line_version_icon" title="新增一个线路版本" uk-tooltip></a> | ||
| 54 | + </div> | ||
| 55 | + <div class="_version_dropdown_wrap"> | ||
| 56 | + <a class="_version_text"></a> | ||
| 57 | + <div uk-dropdown> | ||
| 58 | + <ul class="uk-nav uk-dropdown-nav all_version_list"> | ||
| 59 | + </ul> | ||
| 60 | + </div> | ||
| 61 | + </div> | ||
| 62 | + <a class="clock_enable_version"></a> | ||
| 63 | + </div> | ||
| 64 | + | ||
| 65 | + <div class="_route_info_wrap"> | ||
| 66 | + <ul uk-tab> | ||
| 67 | + <li><a>上行</a></li> | ||
| 68 | + <li><a>下行</a></li> | ||
| 69 | + | ||
| 70 | + </ul> | ||
| 71 | + | ||
| 72 | + <ul class="uk-switcher uk-margin up_down_route_list"> | ||
| 73 | + <li> | ||
| 74 | + <div class="station_route"></div> | ||
| 75 | + <div class="road_route"></div> | ||
| 76 | + </li> | ||
| 77 | + <li> | ||
| 78 | + <div class="station_route"></div> | ||
| 79 | + <div class="road_route"></div> | ||
| 80 | + </li> | ||
| 81 | + </ul> | ||
| 82 | + <div class="pos_tb_icon"> | ||
| 83 | + <a uk-icon="icon: chevron-down;"></a> | ||
| 84 | + </div> | ||
| 85 | + </div> | ||
| 86 | + </div> | ||
| 87 | + <div class="main_lt_search_panel"> | ||
| 88 | + <div class="uk-inline ct_s_i_wrap"> | ||
| 89 | + <span class="uk-form-icon uk-form-icon-flip" uk-icon="icon: search"></span> | ||
| 90 | + <input class="uk-input ct_search_input" placeholder="搜索地图位置" type="text"> | ||
| 91 | + </div> | ||
| 92 | + <div class="ct_search_result"></div> | ||
| 93 | + </div> | ||
| 94 | + <div class="main_rt_tools_panel"> | ||
| 95 | + <!--<a style="color: red;" uk-icon="icon: unlock;ratio: .9" class="_icon" title="当前版本有变更未启用" uk-tooltip="pos:bottom"></a>--> | ||
| 96 | + | ||
| 97 | + <a uk-icon="icon: bookmark;ratio: .9" class="_icon" title="走向版本变更记录" uk-tooltip="pos:bottom"></a> | ||
| 98 | + <a uk-icon="icon: expand;ratio: .9" class="_icon full_screen_icon"></a> | ||
| 99 | + </div> | ||
| 100 | +</div> | ||
| 101 | + | ||
| 102 | +<script id="geo_d_e_search_result-temp" type="text/html"> | ||
| 103 | + <ul class="s_list uk-list"> | ||
| 104 | + {{each list as obj i}} | ||
| 105 | + <li data-lat="{{obj.point.lat}}" data-lng="{{obj.point.lng}}"> | ||
| 106 | + <span class="_title">{{obj.title}}</span> | ||
| 107 | + <span class="_address">{{obj.address}}</span> | ||
| 108 | + </li> | ||
| 109 | + {{/each}} | ||
| 110 | + | ||
| 111 | + {{if list.length==0}} | ||
| 112 | + <li class="_empty">没有搜索到相关数据!</li> | ||
| 113 | + {{/if}} | ||
| 114 | + </ul> | ||
| 115 | +</script> | ||
| 116 | + | ||
| 117 | +<script id="geo_d_e_dropdown_list-temp" type="text/html"> | ||
| 118 | + {{each list as obj i}} | ||
| 119 | + <li data-code="{{obj.code}}"> | ||
| 120 | + <div class="name">{{obj.name}}</div> | ||
| 121 | + <div class="code">{{obj.code}}</div> | ||
| 122 | + </li> | ||
| 123 | + {{/each}} | ||
| 124 | + {{if ellipsis}} | ||
| 125 | + <li>...</li> | ||
| 126 | + {{/if}} | ||
| 127 | +</script> | ||
| 128 | +<!-- 百度 --> | ||
| 129 | +<script src="//api.map.baidu.com/api?v=2.0&ak=IGGrr4UjwIYzatoCRFKEL8sT"></script> | ||
| 130 | +<script src="/metronic_v4.5.4/plugins/jquery.min.js"></script> | ||
| 131 | +<script src="/assets/plugins/uk3.0/uikit.min.js"></script> | ||
| 132 | +<script src="/assets/plugins/uk3.0/uikit-icons.min.js"></script> | ||
| 133 | +<script src="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.jquery.js" ></script> | ||
| 134 | +<!-- EventProxy --> | ||
| 135 | +<script src="/assets/js/eventproxy.js"></script> | ||
| 136 | +<!-- art-template 模版引擎 --> | ||
| 137 | +<script src="/assets/plugins/template.js"></script> | ||
| 138 | +<script src="/real_control_v2/assets/plugins/moment/moment.min.js"></script> | ||
| 139 | +<!-- jquery.serializejson JSON序列化插件 --> | ||
| 140 | +<script src="/assets/plugins/jquery.serializejson.js" merge="plugins"></script> | ||
| 141 | +<!-- common js --> | ||
| 142 | +<script src="/pages/base/geo_data_edit/js/ct_common.js"></script> | ||
| 143 | +<script src="/assets/js/TransGPS.js" ></script> | ||
| 144 | +<!-- Geolib --> | ||
| 145 | +<script src="/real_control_v2/geolib/geolib.js" ></script> | ||
| 146 | +<!-- jquery contextMenu --> | ||
| 147 | +<script src="/real_control_v2/assets/js/jquery.contextMenu.min.js" ></script> | ||
| 148 | +<script src="/assets/js/baidu/bd_GeoUtils_min.js" ></script> | ||
| 149 | +<!-- flatpickr --> | ||
| 150 | +<script src="/real_control_v2/assets/plugins/flatpickr/flatpickr.min.js" ></script> | ||
| 151 | +<script src="/real_control_v2/assets/plugins/flatpickr/l10n/zh.js" ></script> | ||
| 152 | +<script src="/assets/plugins/pinyin.js"></script> | ||
| 153 | + | ||
| 154 | +<script> | ||
| 155 | + var $loadPanel = $('body>.loading'); | ||
| 156 | + //___________________________________ | ||
| 157 | + var storage = window.localStorage; | ||
| 158 | + //___________________________________ | ||
| 159 | + | ||
| 160 | + top.document.title = "绘制线路"; | ||
| 161 | + | ||
| 162 | + // 关闭左侧栏 | ||
| 163 | + if (!top.$('body').hasClass('page-sidebar-closed')) {top.$('.menu-toggler.sidebar-toggler').click();} | ||
| 164 | + //全屏 | ||
| 165 | + $('.full_screen_icon').on('click', function () { | ||
| 166 | + var $iframe = window.parent.$('#geo_edit_wrap_iframe'), | ||
| 167 | + icon; | ||
| 168 | + if($(this).attr('uk-icon').indexOf('expand') != -1){ | ||
| 169 | + $iframe.addClass('full_screen'); | ||
| 170 | + icon = 'shrink'; | ||
| 171 | + } | ||
| 172 | + else{ | ||
| 173 | + $iframe.removeClass('full_screen'); | ||
| 174 | + icon = 'expand'; | ||
| 175 | + } | ||
| 176 | + $(this).attr('uk-icon', 'icon: '+icon+';ratio: .9'); | ||
| 177 | + }); | ||
| 178 | + | ||
| 179 | + var gb_main_ep; | ||
| 180 | + //文件加载 | ||
| 181 | + var res_load_ep = EventProxy.create('load_common_data', 'load_station_route','load_road_route' | ||
| 182 | + , 'load_version_manage', 'load_history_edit_logs', 'load_map', function () { | ||
| 183 | + startup(function () { | ||
| 184 | + $('.instructions_tips').show(); | ||
| 185 | + }); | ||
| 186 | + | ||
| 187 | + gb_change_line.init(); | ||
| 188 | + }); | ||
| 189 | + | ||
| 190 | + var g_line_code; | ||
| 191 | + var g_version; | ||
| 192 | + var startup = function (cb) { | ||
| 193 | + g_line_code = storage.getItem('geo_data_edit_line_code'); | ||
| 194 | + | ||
| 195 | + gb_main_ep = new EventProxy(); | ||
| 196 | + var eq = gb_main_ep; | ||
| 197 | + | ||
| 198 | + //站点 | ||
| 199 | + gb_station_route.init(g_emit('init_road')); | ||
| 200 | + //路段 | ||
| 201 | + eq.once('init_road', function () { | ||
| 202 | + gb_road_route.init(g_emit('init_map')) | ||
| 203 | + }); | ||
| 204 | + //地图 | ||
| 205 | + eq.once('init_map', function () { | ||
| 206 | + gb_ct_map._render(g_emit('end')); | ||
| 207 | + }); | ||
| 208 | + | ||
| 209 | + eq.once('end', function () { | ||
| 210 | + //线路版本信息 | ||
| 211 | + gb_version_manage.init(storage.getItem("geo_data_edit_line_version")); | ||
| 212 | + | ||
| 213 | + $loadPanel.hide(); | ||
| 214 | + gb_ct_search.init(); | ||
| 215 | + | ||
| 216 | + cb && cb(); | ||
| 217 | + }); | ||
| 218 | + }; | ||
| 219 | + | ||
| 220 | + var clearAll = function () { | ||
| 221 | + $('.up_down_route_list .station_route').empty(); | ||
| 222 | + $('.up_down_route_list .road_route').empty(); | ||
| 223 | + gb_ct_map.clearAll(); | ||
| 224 | + }; | ||
| 225 | + | ||
| 226 | + function g_emit(id) { | ||
| 227 | + console.log('g_emit [' + id + ']'); | ||
| 228 | + return function () { | ||
| 229 | + console.log('eq.emitLater(' + id + ')'); | ||
| 230 | + return gb_main_ep.emitLater(id); | ||
| 231 | + }; | ||
| 232 | + } | ||
| 233 | + | ||
| 234 | + //滚动条 | ||
| 235 | + $('._route_info_wrap>ul.uk-switcher').perfectScrollbar({suppressScrollX: true}); | ||
| 236 | + | ||
| 237 | + //to top btttom | ||
| 238 | + $('.pos_tb_icon a').on('click', function () { | ||
| 239 | + UIkit.notification('top top...'); | ||
| 240 | + }); | ||
| 241 | + | ||
| 242 | + function getUpDown(){ | ||
| 243 | + return $('.up_down_route_list>li:first').hasClass('uk-active')?0:1; | ||
| 244 | + } | ||
| 245 | + | ||
| 246 | + //切换上下行显示 | ||
| 247 | + $('.up_down_route_list').on('show', function () { | ||
| 248 | + gb_ct_map.changeUpDown(); | ||
| 249 | + }); | ||
| 250 | + | ||
| 251 | + $(document).on('submit', 'form', function (e) { | ||
| 252 | + e.stopPropagation(); | ||
| 253 | + return false; | ||
| 254 | + }); | ||
| 255 | + | ||
| 256 | + $(document).on('click', 'button.cancel', function (e) { | ||
| 257 | + e.stopPropagation(); | ||
| 258 | + return false; | ||
| 259 | + }); | ||
| 260 | + | ||
| 261 | + //关闭说明 | ||
| 262 | + $('.instructions_tips .uk-close').on('click', function () { | ||
| 263 | + $('.instructions_tips').remove(); | ||
| 264 | + }); | ||
| 265 | +</script> | ||
| 266 | + | ||
| 267 | + | ||
| 268 | +<script src="/pages/base/geo_data_edit/js/server_timer.js" ></script> | ||
| 269 | +<!--- js --> | ||
| 270 | +<script src="/pages/base/geo_data_edit/js/common_data.js" ></script> | ||
| 271 | +<script src="/pages/base/geo_data_edit/js/station_route.js" ></script> | ||
| 272 | +<script src="/pages/base/geo_data_edit/js/road_route.js" ></script> | ||
| 273 | +<script src="/pages/base/geo_data_edit/js/version_manage.js" ></script> | ||
| 274 | +<script src="/pages/base/geo_data_edit/js/history_edit_logs.js" ></script> | ||
| 275 | +<script src="/pages/base/geo_data_edit/js/map.js" ></script> | ||
| 276 | +<script src="/pages/base/geo_data_edit/js/submit.js" ></script> | ||
| 277 | +<script src="/pages/base/geo_data_edit/js/search.js" ></script> | ||
| 278 | +<script src="/pages/base/geo_data_edit/js/change_line.js" ></script> | ||
| 279 | + | ||
| 280 | +<script type="text/javascript" | ||
| 281 | + src="//api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.js"></script> | ||
| 282 | +</body> | ||
| 283 | </html> | 283 | </html> |
| 284 | \ No newline at end of file | 284 | \ No newline at end of file |
src/main/resources/static/pages/base/line/js/map.js
| 1 | -/** | ||
| 2 | - * 百度地图 | ||
| 3 | - * | ||
| 4 | - * - - - - - -》init:地图初始化 | ||
| 5 | - * | ||
| 6 | - * - - - - - -》getDistanceAndDuration:获取距离与时间 | ||
| 7 | - * | ||
| 8 | - * - - - - - -》drawingUpline:在地图上画出上行线路走向 | ||
| 9 | - * | ||
| 10 | - * - - - - - -》stationsPointsToLibraryPoint:根据站点坐标匹配库中的公交站点(手动规划) | ||
| 11 | - */ | ||
| 12 | - | ||
| 13 | -var WorldsBMapLine = function () { | ||
| 14 | - | ||
| 15 | - /** WorldsBMapLine 全局变量定义 mapBValue:地图对象;polyUpline:走向折线;sectionList:截取过的路段 ;pointIndex:计算路段被切的次数; | ||
| 16 | - * firstPoint:截取路段的第一个点;iseditStatus:路段是否在编辑状态;isCutSection : 获取路段是否在截取状态*/ | ||
| 17 | - var mapBValue = '', polyUpline='', sectionList = [], pointIndex = 0, iseditStatus = false, firstPoint = null, isCutSection = false; | ||
| 18 | - | ||
| 19 | - var Bmap = { | ||
| 20 | - | ||
| 21 | - init : function() { | ||
| 22 | - | ||
| 23 | - // 设置中心点, | ||
| 24 | - var CENTER_POINT = {lng : 121.528733,lat : 31.237425}; | ||
| 25 | - | ||
| 26 | - // 百度API Key | ||
| 27 | - var bdKey = 'IGGrr4UjwIYzatoCRFKEL8sT'; | ||
| 28 | - | ||
| 29 | - // 初始化百度地图 | ||
| 30 | - mapBValue = new BMap.Map("bmap_basic"); | ||
| 31 | - | ||
| 32 | - //中心点和缩放级别 | ||
| 33 | - mapBValue.centerAndZoom(new BMap.Point(CENTER_POINT.lng,CENTER_POINT.lat), 20); | ||
| 34 | - | ||
| 35 | - //启用地图拖拽事件,默认启用(可不写) | ||
| 36 | - mapBValue.enableDragging(); | ||
| 37 | - | ||
| 38 | - //启用地图滚轮放大缩小 | ||
| 39 | - mapBValue.enableScrollWheelZoom(); | ||
| 40 | - | ||
| 41 | - //禁用鼠标双击放大 | ||
| 42 | - mapBValue.disableDoubleClickZoom(); | ||
| 43 | - | ||
| 44 | - //启用键盘上下左右键移动地图 | ||
| 45 | - mapBValue.enableKeyboard(); | ||
| 46 | - | ||
| 47 | - return mapBValue; | ||
| 48 | - }, | ||
| 49 | - /** 获取第一个切路段的点 @return Point*/ | ||
| 50 | - getFirstPoint : function() { | ||
| 51 | - return firstPoint; | ||
| 52 | - }, | ||
| 53 | - /** 第一个切路段的点 */ | ||
| 54 | - setFirstPoint : function(Point) { | ||
| 55 | - firstPoint = Point; | ||
| 56 | - }, | ||
| 57 | - /** 获取地图对象 @return 地图对象map */ | ||
| 58 | - getmapBValue : function() { | ||
| 59 | - | ||
| 60 | - return mapBValue; | ||
| 61 | - | ||
| 62 | - }, | ||
| 63 | - | ||
| 64 | - getPolyUpline : function() { | ||
| 65 | - | ||
| 66 | - return polyUpline; | ||
| 67 | - }, | ||
| 68 | - | ||
| 69 | - /** 获取截取过的路段 @return 路段对象List */ | ||
| 70 | - getSectionList : function() { | ||
| 71 | - | ||
| 72 | - return sectionList; | ||
| 73 | - | ||
| 74 | - }, | ||
| 75 | - setSectionList : function(list) { | ||
| 76 | - | ||
| 77 | - sectionList = list; | ||
| 78 | - }, | ||
| 79 | - initCutSectionPoint : function() { | ||
| 80 | - sectionList = []; | ||
| 81 | - var tbodyHtml = template('section_list',{list : sectionList}); | ||
| 82 | - $('#section_table tbody').html(tbodyHtml); | ||
| 83 | - }, | ||
| 84 | - /** 获取切路段的点下标 @return int*/ | ||
| 85 | - setPointIndex : function(index) { | ||
| 86 | - pointIndex = index; | ||
| 87 | - }, | ||
| 88 | - getPointIndex : function() { | ||
| 89 | - | ||
| 90 | - return pointIndex; | ||
| 91 | - | ||
| 92 | - }, | ||
| 93 | - /** 获取路段是否在编辑状态 @return boolean*/ | ||
| 94 | - getIsEditStatus : function() { | ||
| 95 | - return iseditStatus; | ||
| 96 | - }, | ||
| 97 | - setIsEditStatus : function(v) { | ||
| 98 | - iseditStatus = v ; | ||
| 99 | - }, | ||
| 100 | - | ||
| 101 | - /** 获取路段是否在截取状态 @return boolean*/ | ||
| 102 | - getIsCutSection : function() { | ||
| 103 | - return isCutSection; | ||
| 104 | - }, | ||
| 105 | - setIsCutSection : function(v) { | ||
| 106 | - isCutSection = v ; | ||
| 107 | - }, | ||
| 108 | - | ||
| 109 | - /** 获取距离与时间 @param <points:坐标点集合> */ | ||
| 110 | - getDistanceAndDuration : function(points,callback){ | ||
| 111 | - | ||
| 112 | - // 获取长度 | ||
| 113 | - var len = points.length; | ||
| 114 | - (function(){ | ||
| 115 | - | ||
| 116 | - if (!arguments.callee.count) { | ||
| 117 | - | ||
| 118 | - arguments.callee.count = 0; | ||
| 119 | - | ||
| 120 | - } | ||
| 121 | - | ||
| 122 | - arguments.callee.count++; | ||
| 123 | - | ||
| 124 | - var index = parseInt(arguments.callee.count) - 1; | ||
| 125 | - | ||
| 126 | - if (index >= len-1) { | ||
| 127 | - callback && callback(points); | ||
| 128 | - | ||
| 129 | - return; | ||
| 130 | - } | ||
| 131 | - | ||
| 132 | - // 当函数被调用时,它的arguments.callee对象就会指向自身,也就是一个对自己的引用。(当前正在执行的函数。) | ||
| 133 | - var f = arguments.callee; | ||
| 134 | - // 起点坐标 <坐标格式:40.056878,116.30815> | ||
| 135 | - var origin = points[index].potion.lat + ',' + points[index].potion.lng; | ||
| 136 | - | ||
| 137 | - // 终点坐标 <坐标格式:40.056878,116.30815> | ||
| 138 | - var destination = points[index+1].potion.lat + ',' + points[index+1].potion.lng; | ||
| 139 | - var region = '上海'; | ||
| 140 | - | ||
| 141 | - var origin_region = '上海'; | ||
| 142 | - | ||
| 143 | - var destination_region = '上海'; | ||
| 144 | - | ||
| 145 | - var output = 'json'; | ||
| 146 | - | ||
| 147 | - var ak_My = 'wjlITmXeCek5MxyU3ZUBkTeU8B0o0npk'; | ||
| 148 | - | ||
| 149 | - /** | ||
| 150 | - * origin:起点名称或经纬度; | ||
| 151 | - * | ||
| 152 | - * destination:终点名称或经纬度; | ||
| 153 | - * | ||
| 154 | - * origin_region:起始点所在城市,驾车导航时必填。 | ||
| 155 | - * | ||
| 156 | - * destination_region:终点所在城市,驾车导航时必填。 | ||
| 157 | - * | ||
| 158 | - * output :表示输出类型,可设置为xml或json,默认为xml。 | ||
| 159 | - * | ||
| 160 | - **/ | ||
| 161 | - var paramsB = {origin:origin,destination:destination,region:region,origin_region:origin_region,destination_region:destination_region,output:output,ak:ak_My}; | ||
| 162 | - | ||
| 163 | - /** @description :未认证开发者默认配额为:2000次/天。 */ | ||
| 164 | - $.ajax({ | ||
| 165 | - | ||
| 166 | - // 百度地图根据坐标获取两点之间的时间与距离 | ||
| 167 | - url: 'http://api.map.baidu.com/direction/v1?mode=transit', | ||
| 168 | - | ||
| 169 | - data: paramsB, | ||
| 170 | - | ||
| 171 | - dataType: 'jsonp', | ||
| 172 | - | ||
| 173 | - success: function(r){ | ||
| 174 | - | ||
| 175 | - if(r) { | ||
| 176 | - | ||
| 177 | - if(r.message=='ok') { | ||
| 178 | - | ||
| 179 | - if(r.result.taxi==null) { | ||
| 180 | - | ||
| 181 | - // 获取距离(单位:米) | ||
| 182 | - points[index+1].distance = 0; | ||
| 183 | - | ||
| 184 | - // 获取时间(单位:秒) | ||
| 185 | - points[index+1].duration = 0; | ||
| 186 | - | ||
| 187 | - }else { | ||
| 188 | - | ||
| 189 | - // 获取距离(单位:米) | ||
| 190 | - points[index+1].distance = r.result.taxi.distance; | ||
| 191 | - | ||
| 192 | - // 获取时间(单位:秒) | ||
| 193 | - points[index+1].duration = r.result.taxi.duration; | ||
| 194 | - | ||
| 195 | - } | ||
| 196 | - | ||
| 197 | - | ||
| 198 | - } | ||
| 199 | - | ||
| 200 | - } | ||
| 201 | - | ||
| 202 | - f(); | ||
| 203 | - } | ||
| 204 | - }); | ||
| 205 | - | ||
| 206 | - })(); | ||
| 207 | - | ||
| 208 | - }, | ||
| 209 | - drawingSection: function(data){ | ||
| 210 | - /** 获取站点路由信息 @param:<Line.id:线路Id;0:上行> @return:<resultdata:站点路由数据> */ | ||
| 211 | - WorldsBMapLine.clearMarkAndOverlays(); | ||
| 212 | - // 编辑路段数据 | ||
| 213 | - if(data) { | ||
| 214 | - // 地图折线坐标点集合 | ||
| 215 | - var polylineArray = []; | ||
| 216 | - // 获取路段折线坐标字符串 | ||
| 217 | - var sectionBsectionVectorStr = data.sectionBsectionVector; | ||
| 218 | - if(sectionBsectionVectorStr==null) { | ||
| 219 | - return; | ||
| 220 | - } | ||
| 221 | - // 切割段折线坐标字符串 | ||
| 222 | - var tempStr = sectionBsectionVectorStr.substring(11,sectionBsectionVectorStr.length-1); | ||
| 223 | - // 分割折线坐标字符串 | ||
| 224 | - var lineArray = tempStr.split(','); | ||
| 225 | - for(var i = 0;i<lineArray.length;i++) { | ||
| 226 | - polylineArray.push(new BMap.Point(lineArray[i].split(' ')[0],lineArray[i].split(' ')[1])); | ||
| 227 | - } | ||
| 228 | - var index = parseInt(polylineArray.length/2); | ||
| 229 | - var center = polylineArray[index]; | ||
| 230 | - /** 在地图上画出线路走向 @param:<polylineArray:地图折线坐标点集合;resultdata:站点路由数据> */ | ||
| 231 | - WorldsBMapLine.drawingUpline(polylineArray,center); | ||
| 232 | - /** 在地图上画点 @param:<point_center:中心坐标点> */ | ||
| 233 | - WorldsBMapLine.drawingUpStationPoint(center,data.sectionName,1); | ||
| 234 | - } | ||
| 235 | - }, | ||
| 236 | - // 在地图上画出上行线路走向(单路段) | ||
| 237 | - drawingUpline : function (polylineArray,polyline_center,data) { | ||
| 238 | - /*WorldsBMap.clearMarkAndOverlays();*/ | ||
| 239 | - polyUpline = ''; | ||
| 240 | - // 创建线路走向 | ||
| 241 | - polyUpline = new BMap.Polyline(polylineArray, {strokeColor : "blue",strokeWeight : 6,strokeOpacity : 0.5}); | ||
| 242 | - // polyUpline.data = data; | ||
| 243 | - // 把折线添加到地图上 | ||
| 244 | - mapBValue.addOverlay(polyUpline); | ||
| 245 | - var PanOptions_ ={noAnimation :true}; | ||
| 246 | - mapBValue.reset(); | ||
| 247 | - mapBValue.panTo(polyline_center,PanOptions_); | ||
| 248 | - mapBValue.panBy(500,-510,PanOptions_); | ||
| 249 | - mapBValue.setZoom(14); | ||
| 250 | - }, | ||
| 251 | - | ||
| 252 | - // 在地图上画出上行线路走向(多路段) | ||
| 253 | - drawingUpline01 : function (polylineArray,polyline_center,data) { | ||
| 254 | - var polyUpline01 = 'polyline' + '_' + data.sectionrouteId; | ||
| 255 | - // 创建线路走向 | ||
| 256 | - polyUpline01 = new BMap.Polyline(polylineArray, {strokeColor : "blue",strokeWeight : 6,strokeOpacity : 0.5}); | ||
| 257 | - polyUpline01.data = data; | ||
| 258 | - // 把折线添加到地图上 | ||
| 259 | - mapBValue.addOverlay(polyUpline01); | ||
| 260 | - var sectionPoint = []; | ||
| 261 | - // 线路单击事件 | ||
| 262 | - polyUpline01.addEventListener('click',function(e) { | ||
| 263 | - if(WorldsBMapLine.getIsEditStatus()) { | ||
| 264 | - layer.msg('请先保存正在编辑的路段信息...'); | ||
| 265 | - return false; | ||
| 266 | - } | ||
| 267 | - if(WorldsBMapLine.getIsCutSection()) { | ||
| 268 | - layer.msg('请先撤销所有切路段的点...'); | ||
| 269 | - return false; | ||
| 270 | - } | ||
| 271 | - polyUpline01.enableEditing(); | ||
| 272 | - WorldsBMapLine.setIsEditStatus(true); | ||
| 273 | - // 关闭按钮事件 | ||
| 274 | - PublicFunctions.addAChangeCssAddDisabled(); | ||
| 275 | - }); | ||
| 276 | - | ||
| 277 | - // 添加路段双击事件 | ||
| 278 | - polyUpline01.addEventListener("dblclick",function(e){ | ||
| 279 | - if(WorldsBMapLine.getIsCutSection()) { | ||
| 280 | - layer.msg('请先撤销所有切路段的点...'); | ||
| 281 | - return false; | ||
| 282 | - } | ||
| 283 | - WorldsBMapLine.setIsEditStatus(false); | ||
| 284 | - // 关闭 | ||
| 285 | - layer.closeAll(); | ||
| 286 | - polyUpline01.disableEditing(); | ||
| 287 | - EditSectionObj.setEitdSection(polyUpline01.data); | ||
| 288 | - // 获取折线坐标集合 | ||
| 289 | - var editPloyLineArray = polyUpline01.getPath(); | ||
| 290 | - EditSectionObj.setEitdBsectionVector(JSON.stringify(editPloyLineArray)); | ||
| 291 | - sectionList = []; | ||
| 292 | - var tbodyHtml = template('section_list',{list : sectionList}); | ||
| 293 | - // 截取路段 | ||
| 294 | - $('#section_table tbody').html(tbodyHtml); | ||
| 295 | - // 加载修改路段弹出层mobal页面 | ||
| 296 | - $.get('editsection.html', function(m){ | ||
| 297 | - $(pjaxContainer).append(m); | ||
| 298 | - $('#edit_section_mobal_cache').trigger('editSectionMobalCache_show', [WorldsBMapLine,MapGetAjaxData,EditSectionObj,PublicFunctions]); | ||
| 299 | - }); | ||
| 300 | - // 打开按钮事件 | ||
| 301 | - PublicFunctions.editAChangeCssRemoveDisabled(); | ||
| 302 | - }); | ||
| 303 | - | ||
| 304 | - // 路段右击事件 | ||
| 305 | - var editSection = function(e,ee,marker){ | ||
| 306 | - if(WorldsBMapLine.getIsEditStatus()) { | ||
| 307 | - layer.msg('请先保存正在编辑的路段信息...'); | ||
| 308 | - return false; | ||
| 309 | - } | ||
| 310 | - var lng = e.lng; | ||
| 311 | - var lat = e.lat; | ||
| 312 | - var sectionName = null; | ||
| 313 | - var marker = new BMap.Marker(new BMap.Point(lng, lat)); // 创建点 | ||
| 314 | - var label = new BMap.Label(pointIndex+1,{offset:new BMap.Size(pointIndex>8?0:4,0)}); | ||
| 315 | - label.setStyle({border :"0", color : "white",backgroundColor:"rgba(0,0,0,0)"}); | ||
| 316 | - marker.setLabel(label); | ||
| 317 | - marker.isFlag = true; | ||
| 318 | - if(pointIndex == 0) { | ||
| 319 | - sectionPoint[pointIndex] = {lng:lng , lat:lat}; | ||
| 320 | - layer.msg('进入切路段状态,请选择本路段的终点!'); | ||
| 321 | - mapBValue.addOverlay(marker);// 添加覆盖物 | ||
| 322 | - firstPoint = {lng:lng, lat:lat}; | ||
| 323 | - pointIndex++; | ||
| 324 | - EditSectionObj.setEitdSection(polyUpline01.data); | ||
| 325 | - // 获取折线坐标集合 | ||
| 326 | - var editPloyLineArray = polyUpline01.getPath(); | ||
| 327 | - EditSectionObj.setEitdBsectionVector(JSON.stringify(editPloyLineArray)); | ||
| 328 | - } else if (pointIndex > 0) { | ||
| 329 | - layer.prompt({title: '请输入路段名!'}, function(sectionName, index){ | ||
| 330 | - pointList = []; | ||
| 331 | - sectionPoint[pointIndex] = {lng:lng , lat:lat}; | ||
| 332 | - pointList[0] = sectionPoint[pointIndex-1]; | ||
| 333 | - pointList[1] = sectionPoint[pointIndex]; | ||
| 334 | - sectionList.push({name:sectionName, section:pointList}); | ||
| 335 | - layer.close(index); | ||
| 336 | - layer.msg('路段截取成功,请选择下一个路段的终点'); | ||
| 337 | - mapBValue.addOverlay(marker);// 添加覆盖物 | ||
| 338 | - var tbodyHtml = template('section_list',{list : sectionList}); | ||
| 339 | - // 截取路段 | ||
| 340 | - $('#section_table tbody').html(tbodyHtml); | ||
| 341 | - pointIndex++; | ||
| 342 | - }); | ||
| 343 | - } | ||
| 344 | - WorldsBMapLine.setIsCutSection(true); | ||
| 345 | - } | ||
| 346 | - // 路段生成类型位gps上传时才开启右击事件 | ||
| 347 | - if(EditRoute.getLineGenerationType() == 'uploadGPS') { | ||
| 348 | - var markerMenu=new BMap.ContextMenu(); | ||
| 349 | - markerMenu.addItem(new BMap.MenuItem('切路段',editSection.bind(polyUpline01))); | ||
| 350 | - polyUpline01.addContextMenu(markerMenu); | ||
| 351 | - } | ||
| 352 | - | ||
| 353 | - | ||
| 354 | - var PanOptions_ ={noAnimation :true}; | ||
| 355 | - mapBValue.reset(); | ||
| 356 | - mapBValue.panTo(polyline_center,PanOptions_); | ||
| 357 | - mapBValue.panBy(500,-510,PanOptions_); | ||
| 358 | - mapBValue.setZoom(14); | ||
| 359 | - }, | ||
| 360 | - // 删除点刷新cutSectionTable | ||
| 361 | - refreshCutSectionTable : function() { | ||
| 362 | - var tbodyHtml = template('section_list',{list : sectionList}); | ||
| 363 | - $('#section_table tbody').html(tbodyHtml); | ||
| 364 | - }, | ||
| 365 | - // 删除点刷新覆盖物 | ||
| 366 | - deleteCutSectionPoint : function(point) { | ||
| 367 | - var lng = point.lng; | ||
| 368 | - var lat = point.lat; | ||
| 369 | - var allOverlay = mapBValue.getOverlays(); | ||
| 370 | - // 删除最后一个点 | ||
| 371 | - for (var i = 0; i < allOverlay.length -1; i++){ | ||
| 372 | - if(allOverlay[i].isFlag) { | ||
| 373 | - if(allOverlay[i].point.lng == lng && allOverlay[i].point.lat == lat){ | ||
| 374 | - mapBValue.removeOverlay(allOverlay[i]); | ||
| 375 | - break; | ||
| 376 | - } | ||
| 377 | - } | ||
| 378 | - } | ||
| 379 | - }, | ||
| 380 | - // 批量画点 | ||
| 381 | - batchPaintingPoint : function() { | ||
| 382 | - // 画第一个点 | ||
| 383 | - var Point = WorldsBMapLine.getFirstPoint(); | ||
| 384 | - if(Point){ | ||
| 385 | - var marker = new BMap.Marker(new BMap.Point(Point.lng, Point.lat)); // 创建点 | ||
| 386 | - var label = new BMap.Label(1,{offset:new BMap.Size(4,0)}); | ||
| 387 | - label.setStyle({border :"0", color : "white",backgroundColor:"rgba(0,0,0,0)"}); | ||
| 388 | - marker.setLabel(label); | ||
| 389 | - marker.isFlag = true; | ||
| 390 | - mapBValue.addOverlay(marker);// 添加覆盖物 | ||
| 391 | - | ||
| 392 | - WorldsBMapLine.getFirstPoint(); | ||
| 393 | - } | ||
| 394 | - $.each(sectionList, function(index, value) { | ||
| 395 | - var section = value.section; | ||
| 396 | - | ||
| 397 | - var marker = new BMap.Marker(new BMap.Point(section[1].lng, section[1].lat)); // 创建点 | ||
| 398 | - var label = new BMap.Label(index+2,{offset:new BMap.Size(index>7?0:4,0)}); | ||
| 399 | - label.setStyle({border :"0", color : "white",backgroundColor:"rgba(0,0,0,0)"}); | ||
| 400 | - marker.setLabel(label); | ||
| 401 | - marker.isFlag = true; | ||
| 402 | - mapBValue.addOverlay(marker);// 添加覆盖物 | ||
| 403 | - }); | ||
| 404 | - | ||
| 405 | - }, | ||
| 406 | - /** 在地图上画点 @param:<point_center:中心坐标点> */ | ||
| 407 | - drawingUpStationPoint : function(point_center,stationName,s) { | ||
| 408 | - | ||
| 409 | - // 自定义标注物图片 | ||
| 410 | - var icon_target = new BMap.Icon('/pages/base/stationroute/css/img/gjzd.png',new BMap.Size(10, 10)); | ||
| 411 | - | ||
| 412 | - var html2 = '<div style="position: absolute; margin: 0pt; padding: 0pt; width: 160px; height: 26px; left: -10px; top: -35px; overflow: hidden;">' | ||
| 413 | - + '<img class="rm3_image" style="border:none;left:0px; top:0px; position:absolute;" src="/pages/base/stationroute/css/img/back160.png">' | ||
| 414 | - + '</div>' | ||
| 415 | - + '<label class=" BMapLabel" unselectable="on" style="position: absolute; -moz-user-select: none; display: inline; cursor: inherit; border: 0px none; padding: 2px 1px 1px; white-space: nowrap; font: 12px arial,simsun; z-index: 80; color: rgb(255, 102, 0); left: 15px; top: -35px;"><span style="float: left; color: #fdfdfd; margin-left: -22px; font-size: 6px;">'+ s+'</span>'+ stationName+'</label>'; | ||
| 416 | - | ||
| 417 | - | ||
| 418 | - var myRichMarker1 = new BMapLib.RichMarker(html2, point_center,{ | ||
| 419 | - "anchor" : new BMap.Size(-10,8), | ||
| 420 | - "enableDragging" : true}); | ||
| 421 | - | ||
| 422 | - | ||
| 423 | - myRichMarker1.disableDragging(); | ||
| 424 | - mapBValue.addOverlay(myRichMarker1); | ||
| 425 | - | ||
| 426 | - | ||
| 427 | - // 创建标注物 | ||
| 428 | - marker = new BMap.Marker(point_center,{icon : icon_target}); | ||
| 429 | - | ||
| 430 | - // 允许覆盖物在map.clearOverlays方法中被清除。 | ||
| 431 | - marker.enableMassClear(); | ||
| 432 | - | ||
| 433 | - mapBValue.addOverlay(marker); | ||
| 434 | - }, | ||
| 435 | - | ||
| 436 | - // 根据站点坐标匹配库中的公交站点 | ||
| 437 | - stationsPointsToLibraryPoint : function(arra,callback) { | ||
| 438 | - // 获取长度 | ||
| 439 | - var len = arra.length; | ||
| 440 | - var station = {}; | ||
| 441 | - var stationList = []; | ||
| 442 | - (function(){ | ||
| 443 | - if (!arguments.callee.count) { | ||
| 444 | - arguments.callee.count = 0; | ||
| 445 | - } | ||
| 446 | - arguments.callee.count++; | ||
| 447 | - var index = parseInt(arguments.callee.count) - 1; | ||
| 448 | - if (index >= len) { | ||
| 449 | - callback && callback(stationList); | ||
| 450 | - return ; | ||
| 451 | - } | ||
| 452 | - var f = arguments.callee; | ||
| 453 | - station = arra[index]; | ||
| 454 | - if(arra[index].name!=''){ | ||
| 455 | - | ||
| 456 | - $.get('/station/matchStation',station,function(resultStation) { | ||
| 457 | - stationList.push({name:resultStation.name ,wgs:arra[index].wgs,potion:{lng:resultStation.potion_lng, lat:resultStation.potion_lat}, isHave:resultStation.isHave , id:resultStation.id}); | ||
| 458 | - f(); | ||
| 459 | - }); | ||
| 460 | - }else { | ||
| 461 | - f(); | ||
| 462 | - } | ||
| 463 | - })() | ||
| 464 | - }, | ||
| 465 | - // 地图画多边形 | ||
| 466 | - pointsPolygon : function(objStation) { | ||
| 467 | - | ||
| 468 | - // 将视图切换到指定的缩放等级,中心点坐标不变。注意:当有信息窗口在地图上打开时,地图缩放将保证信息窗口所在的坐标位置不动。(自1.2新增) | ||
| 469 | - mapBValue.setZoom(15); | ||
| 470 | - | ||
| 471 | - // 如果不为空 | ||
| 472 | - if(objStation) { | ||
| 473 | - | ||
| 474 | - // 清除地图覆盖物 | ||
| 475 | - mapBValue.clearOverlays(); | ||
| 476 | - | ||
| 477 | - // 获取中心点坐标字符串 | ||
| 478 | - var testpointStr = objStation.stationBJwpoints; | ||
| 479 | - | ||
| 480 | - // 按空格切割中心点坐标字符串 | ||
| 481 | - var BJwpointsPolygon = testpointStr.split(' '); | ||
| 482 | - | ||
| 483 | - // 中心点坐标 | ||
| 484 | - var pointPolygon = new BMap.Point(BJwpointsPolygon[0], BJwpointsPolygon[1]); | ||
| 485 | - | ||
| 486 | - // 获取多边形坐标字符串 | ||
| 487 | - var stationBPolygonGrid = objStation.stationBPolygonGrid; | ||
| 488 | - | ||
| 489 | - // 截取多边形坐标字符串 | ||
| 490 | - var stationBPolygonGridStr = stationBPolygonGrid.substring(9,stationBPolygonGrid.length-2); | ||
| 491 | - | ||
| 492 | - // 按逗号切割 | ||
| 493 | - var pointPolygonArray = stationBPolygonGridStr.split(','); | ||
| 494 | - | ||
| 495 | - // 多边形坐标集合 | ||
| 496 | - var polygonP = []; | ||
| 497 | - | ||
| 498 | - for(var v = 0;v<pointPolygonArray.length;v++) { | ||
| 499 | - | ||
| 500 | - polygonP.push(new BMap.Point(pointPolygonArray[v].split(" ")[0],pointPolygonArray[v].split(" ")[1])); | ||
| 501 | - | ||
| 502 | - } | ||
| 503 | - | ||
| 504 | - // 画多边形 | ||
| 505 | - polygon = new BMap.Polygon(polygonP, { | ||
| 506 | - | ||
| 507 | - // 线条显色 | ||
| 508 | - strokeColor : "blue", | ||
| 509 | - | ||
| 510 | - // 边线的宽度,以像素为单位。 | ||
| 511 | - strokeWeight : 2, | ||
| 512 | - | ||
| 513 | - // 边线透明度,取值范围0 - 1。 | ||
| 514 | - strokeOpacity : 0.5 | ||
| 515 | - }); | ||
| 516 | - | ||
| 517 | - // 增加地图覆盖物多边形 | ||
| 518 | - mapBValue.addOverlay(polygon); | ||
| 519 | - | ||
| 520 | - // 信息窗口属性 | ||
| 521 | - var opts_polygon = { | ||
| 522 | - | ||
| 523 | - // 信息窗口宽度 | ||
| 524 | - width : 200, | ||
| 525 | - | ||
| 526 | - // 信息窗口高度 | ||
| 527 | - height : 400, | ||
| 528 | - | ||
| 529 | - // 信息窗位置偏移值。 | ||
| 530 | - offset: new BMap.Size(500,20), | ||
| 531 | - | ||
| 532 | - //标题 | ||
| 533 | - title : '<h4 style="color:#FFFFFF">'+objStation.stationStationName+'站详情</h4>', | ||
| 534 | - | ||
| 535 | - //设置不允许信窗发送短息 | ||
| 536 | - enableMessage : false, | ||
| 537 | - | ||
| 538 | - //是否开启点击地图关闭信息窗口 | ||
| 539 | - enableCloseOnClick : false | ||
| 540 | - }; | ||
| 541 | - | ||
| 542 | - var markTypeStr = ''; | ||
| 543 | - | ||
| 544 | - if(objStation.stationRouteStationMark=='B') { | ||
| 545 | - | ||
| 546 | - markTypeStr='起点站'; | ||
| 547 | - | ||
| 548 | - }else if(objStation.stationRouteStationMark=='Z') { | ||
| 549 | - | ||
| 550 | - markTypeStr ='中途站'; | ||
| 551 | - | ||
| 552 | - | ||
| 553 | - }else if(objStation.stationRouteStationMark=='E') { | ||
| 554 | - | ||
| 555 | - markTypeStr='终点站'; | ||
| 556 | - | ||
| 557 | - } | ||
| 558 | - | ||
| 559 | - var htm = '<HR style="border:1 dashed #987cb9" width="100%" color=#987cb9 SIZE=1>'+ | ||
| 560 | - '<span style="color:#DDD;font-size: 15px;">站点名称:' + objStation.stationStationName + '</span>' + | ||
| 561 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">站点编码:' + objStation.stationStationCod + '</span>' + | ||
| 562 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">行业编码:' + (objStation.industryCode == null ? "":objStation.industryCode) + '</span>' + | ||
| 563 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">站点序号:' + objStation.stationRouteStationRouteCode + '</span>' + | ||
| 564 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">站点类型:' + markTypeStr + '</span>' + | ||
| 565 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">纬度坐标:' + objStation.stationBJwpoints + '</span>' + | ||
| 566 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">到站时间:' + objStation.stationRouteToTime + ' 分钟</span>' + | ||
| 567 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">到站距离:' + objStation.stationRouteDistances + ' 公里</span>' + | ||
| 568 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">版本号  :' + objStation.stationRouteVersions + '</span>' + | ||
| 569 | - '<span class="help-block" style="width: 100%;font-size: 15px;;color:#DDD;'+ | ||
| 570 | - 'overflow: hidden; white-space: nowrap; text-overflow: ellipsis; " title="'+ | ||
| 571 | - objStation.stationRouteDescriptions +'" >说明/描述:' + (objStation.stationRouteDescriptions == null ? "":objStation.stationRouteDescriptions)+ '</span>' ; | ||
| 572 | - | ||
| 573 | - // 创建信息窗口 | ||
| 574 | - var infoWindow_target = new BMap.InfoWindow(htm, opts_polygon); | ||
| 575 | - // 自定义标注物图片 | ||
| 576 | - var icon_target = new BMap.Icon('/pages/base/stationroute/css/img/cz.png',new BMap.Size(20, 20)); | ||
| 577 | - | ||
| 578 | - // 创建点 | ||
| 579 | - marker = new BMap.Marker(pointPolygon,{icon : icon_target}); | ||
| 580 | - | ||
| 581 | - // 把标注添物加到地图上 | ||
| 582 | - mapBValue.addOverlay(marker); | ||
| 583 | - | ||
| 584 | - // 是否在平移过程中禁止动画。(自1.2新增) | ||
| 585 | - var PanOptions_ ={noAnimation :true}; | ||
| 586 | - | ||
| 587 | - // 将地图的中心点更改为给定的点。 | ||
| 588 | - mapBValue.panTo(pointPolygon,PanOptions_); | ||
| 589 | - | ||
| 590 | - // 将地图在水平位置上移动x像素,垂直位置上移动y像素。 | ||
| 591 | - mapBValue.panBy(10,-150,PanOptions_); | ||
| 592 | - | ||
| 593 | - //开启信息窗口 | ||
| 594 | - mapBValue.openInfoWindow(infoWindow_target,pointPolygon); | ||
| 595 | - | ||
| 596 | - } | ||
| 597 | - | ||
| 598 | - }, | ||
| 599 | - | ||
| 600 | - // 画圆 | ||
| 601 | - pointsCircle : function(objStation) { | ||
| 602 | - | ||
| 603 | - // 将视图切换到指定的缩放等级,中心点坐标不变。注意:当有信息窗口在地图上打开时,地图缩放将保证信息窗口所在的坐标位置不动。(自1.2新增) | ||
| 604 | - mapBValue.setZoom(16); | ||
| 605 | - | ||
| 606 | - if(objStation) { | ||
| 607 | - | ||
| 608 | - // 清除地图覆盖物 | ||
| 609 | - mapBValue.clearOverlays(); | ||
| 610 | - | ||
| 611 | - // 获取中心坐标点字符串分割 | ||
| 612 | - var BJwpoints = objStation.stationBJwpoints.split(' '); | ||
| 613 | - | ||
| 614 | - // 中心坐标点 | ||
| 615 | - var point = new BMap.Point(BJwpoints[0], BJwpoints[1]); | ||
| 616 | - | ||
| 617 | - //创建圆 | ||
| 618 | - circle = new BMap.Circle(point,objStation.stationRadius,{strokeColor:"blue", strokeWeight:2, strokeOpacity:0.5}); | ||
| 619 | - | ||
| 620 | - // 允许覆盖物在map.clearOverlays方法中被清除 | ||
| 621 | - circle.enableMassClear(); | ||
| 622 | - | ||
| 623 | - // 百度地图添加覆盖物圆 | ||
| 624 | - mapBValue.addOverlay(circle); | ||
| 625 | - | ||
| 626 | - // 信息窗口参数属性 | ||
| 627 | - var opts = { | ||
| 628 | - | ||
| 629 | - // 信息窗口宽度 | ||
| 630 | - width : 200, | ||
| 631 | - | ||
| 632 | - // 信息窗口高度 | ||
| 633 | - height : 450, | ||
| 634 | - | ||
| 635 | - // 信息窗位置偏移值。 | ||
| 636 | - offset: new BMap.Size(500,120), | ||
| 637 | - | ||
| 638 | - //标题 | ||
| 639 | - title : '<h4 style="color:#FFFFFF">'+objStation.stationStationName+'站详情</h4>', | ||
| 640 | - | ||
| 641 | - //设置不允许信窗发送短息 | ||
| 642 | - enableMessage : false, | ||
| 643 | - | ||
| 644 | - //是否开启点击地图关闭信息窗口 | ||
| 645 | - enableCloseOnClick : false, | ||
| 646 | - | ||
| 647 | - // 是否开启信息窗口打开时地图自动移动(默认开启)。(自 1.1 新增) | ||
| 648 | - enableAutoPan:false | ||
| 649 | - }; | ||
| 650 | - | ||
| 651 | - var markTypeStr = ''; | ||
| 652 | - | ||
| 653 | - if(objStation.stationRouteStationMark=='B') { | ||
| 654 | - | ||
| 655 | - markTypeStr='起点站'; | ||
| 656 | - | ||
| 657 | - }else if(objStation.stationRouteStationMark=='Z') { | ||
| 658 | - | ||
| 659 | - markTypeStr ='中途站'; | ||
| 660 | - | ||
| 661 | - | ||
| 662 | - }else if(objStation.stationRouteStationMark=='E') { | ||
| 663 | - | ||
| 664 | - markTypeStr='终点站'; | ||
| 665 | - | ||
| 666 | - } | ||
| 667 | - | ||
| 668 | - var htm = '<HR style="border:1 dashed #987cb9" width="100%" color=#987cb9 SIZE=1>'+ | ||
| 669 | - '<span style="color:#DDD;font-size: 15px;">站点名称:' + objStation.stationStationName + '</span>' + | ||
| 670 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">站点编码:' + objStation.stationStationCod + '</span>' + | ||
| 671 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">行业编码:' + (objStation.industryCode == null ? "":objStation.industryCode)+ '</span>' + | ||
| 672 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">站点序号:' + objStation.stationRouteStationRouteCode + '</span>' + | ||
| 673 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">站点类型:' + markTypeStr + '</span>' + | ||
| 674 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">纬度坐标:' + objStation.stationBJwpoints + '</span>' + | ||
| 675 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">到站时间:' + objStation.stationRouteToTime + ' 分钟</span>' + | ||
| 676 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">到站距离:' + objStation.stationRouteDistances + ' 公里</span>' + | ||
| 677 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">范围半径:' + objStation.stationRadius + '</span>' + | ||
| 678 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">版本号  :' + objStation.stationRouteVersions + '</span>' + | ||
| 679 | - '<span class="help-block" style="width: 100%;font-size: 15px;;color:#DDD;'+ | ||
| 680 | - 'overflow: hidden; white-space: nowrap; text-overflow: ellipsis; " title="'+ | ||
| 681 | - objStation.stationRouteDescriptions +'" >说明/描述:' + (objStation.stationRouteDescriptions == null ? "":objStation.stationRouteDescriptions) + '</span>' ; | ||
| 682 | - | ||
| 683 | - // 创建信息窗口 | ||
| 684 | - var infoWindow_target = new BMap.InfoWindow(htm, opts); | ||
| 685 | - // 自定义标注物图片 | ||
| 686 | - var icon_target = new BMap.Icon('/pages/base/stationroute/css/img/cz.png',new BMap.Size(20, 20)); | ||
| 687 | - | ||
| 688 | - // 创建点 | ||
| 689 | - marker = new BMap.Marker(point,{icon : icon_target}); | ||
| 690 | - | ||
| 691 | - // 把标注添物加到地图上 | ||
| 692 | - mapBValue.addOverlay(marker); | ||
| 693 | - | ||
| 694 | - setTimeout(function(){ | ||
| 695 | - //开启信息窗口 | ||
| 696 | - marker.openInfoWindow(infoWindow_target,point); | ||
| 697 | - | ||
| 698 | - },100); | ||
| 699 | - | ||
| 700 | - // 是否在平移过程中禁止动画。(自1.2新增) | ||
| 701 | - var PanOptions_ ={noAnimation :true}; | ||
| 702 | - | ||
| 703 | - // 将地图的中心点更改为给定的点。 | ||
| 704 | - mapBValue.panTo(point,PanOptions_); | ||
| 705 | - | ||
| 706 | - mapBValue.panBy(10,-200,PanOptions_); | ||
| 707 | - | ||
| 708 | - // 添加标志物监听事件 | ||
| 709 | - marker.addEventListener("click",function() { | ||
| 710 | - | ||
| 711 | - //开启信息窗口 | ||
| 712 | - marker.openInfoWindow(infoWindow_target,point); | ||
| 713 | - | ||
| 714 | - }); | ||
| 715 | - | ||
| 716 | - } | ||
| 717 | - | ||
| 718 | - }, | ||
| 719 | - // 编辑图形 | ||
| 720 | - editShapes : function(objStation) { | ||
| 721 | - | ||
| 722 | - // 清空地图 | ||
| 723 | - WorldsBMapLine.clearMarkAndOverlays(); | ||
| 724 | - | ||
| 725 | - // 站点对象不为空 | ||
| 726 | - if(objStation) { | ||
| 727 | - var stationShapesType = objStation.stationShapesType; | ||
| 728 | - | ||
| 729 | - // 将视图切换到指定的缩放等级,中心点坐标不变。注意:当有信息窗口在地图上打开时,地图缩放将保证信息窗口所在的坐标位置不动。(自1.2新增) | ||
| 730 | - mapBValue.setZoom(16); | ||
| 731 | - | ||
| 732 | - // 编辑圆 | ||
| 733 | - if(stationShapesType =='r') { | ||
| 734 | - | ||
| 735 | - // 获取中心坐标点字符串分割 | ||
| 736 | - var BJwpoints = objStation.stationBJwpoints.split(' '); | ||
| 737 | - | ||
| 738 | - // 中心坐标点 | ||
| 739 | - var point = new BMap.Point(BJwpoints[0], BJwpoints[1]); | ||
| 740 | - | ||
| 741 | - //创建圆 | ||
| 742 | - circle = new BMap.Circle(point,objStation.stationRadius,{strokeColor:"blue", strokeWeight:2, strokeOpacity:0.5}); | ||
| 743 | - | ||
| 744 | - // 允许覆盖物在map.clearOverlays方法中被清除 | ||
| 745 | - circle.enableMassClear(); | ||
| 746 | - | ||
| 747 | - // 百度地图添加覆盖物圆 | ||
| 748 | - mapBValue.addOverlay(circle); | ||
| 749 | - | ||
| 750 | - // 开启编辑功能 | ||
| 751 | - circle.enableEditing(); | ||
| 752 | - | ||
| 753 | - // 是否在平移过程中禁止动画。(自1.2新增) | ||
| 754 | - var PanOptions_ ={noAnimation :true}; | ||
| 755 | - | ||
| 756 | - // 将地图的中心点更改为给定的点。 | ||
| 757 | - mapBValue.panTo(point,PanOptions_); | ||
| 758 | - | ||
| 759 | - mapBValue.panBy(10,-200,PanOptions_); | ||
| 760 | - | ||
| 761 | - // 编辑圆监听事件 | ||
| 762 | - circle.addEventListener('dblclick',function() { | ||
| 763 | - | ||
| 764 | - // 返回圆形的半径,单位为米。 | ||
| 765 | - var newRadius = circle.getRadius(); | ||
| 766 | - | ||
| 767 | - // 返回圆形的中心点坐标。 | ||
| 768 | - var newCenter = circle.getCenter().lng + ' ' + circle.getCenter().lat; | ||
| 769 | - | ||
| 770 | - /** 设置修改站点集合对象站点中心点百度坐标属性值 @param:<bJwpoints:中心点百度坐标) */ | ||
| 771 | - objStation.stationBJwpoints = newCenter; | ||
| 772 | - | ||
| 773 | - /** 设置修改站点集合对象范围图形类型属性值 @param:<shapesType:范围图形类型) */ | ||
| 774 | -// objStation.stationBJwpoints = 'r'; | ||
| 775 | - | ||
| 776 | - /** 设置修改站点集合对象圆形半径属性值 @param:<radius:圆形半径) */ | ||
| 777 | - objStation.stationRadius = Math.round(newRadius); | ||
| 778 | - | ||
| 779 | - /** 设置修改站点集合对象图形百度坐标集合属性值 @param:<bPolygonGrid:图形百度坐标集合) */ | ||
| 780 | - objStation.stationBPolygonGrid = ''; | ||
| 781 | - | ||
| 782 | - // 加载编辑页面 | ||
| 783 | - $.get('editstation.html', function(m){ | ||
| 784 | - | ||
| 785 | - $(pjaxContainer).append(m); | ||
| 786 | - | ||
| 787 | - $('#edit_station_mobal').trigger('editSelectMobal_show', [WorldsBMapLine,MapGetAjaxData,PublicFunctions,objStation]); | ||
| 788 | - | ||
| 789 | - }); | ||
| 790 | - | ||
| 791 | - // 打开按钮事件 | ||
| 792 | - PublicFunctions.editAChangeCssRemoveDisabled(); | ||
| 793 | - }); | ||
| 794 | - | ||
| 795 | - // 编辑多边行 | ||
| 796 | - }else if(stationShapesType =='d') { | ||
| 797 | - | ||
| 798 | - // 清除地图覆盖物 | ||
| 799 | - mapBValue.clearOverlays(); | ||
| 800 | - | ||
| 801 | - // 获取中心点坐标字符串 | ||
| 802 | - var testpointStr = objStation.stationBJwpoints; | ||
| 803 | - | ||
| 804 | - // 按空格切割中心点坐标字符串 | ||
| 805 | - var BJwpointsPolygon = testpointStr.split(' '); | ||
| 806 | - | ||
| 807 | - // 中心点坐标 | ||
| 808 | - var pointPolygon = new BMap.Point(BJwpointsPolygon[0], BJwpointsPolygon[1]); | ||
| 809 | - | ||
| 810 | - // 获取多边形坐标字符串 | ||
| 811 | - var stationBPolygonGrid = objStation.stationBPolygonGrid; | ||
| 812 | - | ||
| 813 | - // 截取多边形坐标字符串 | ||
| 814 | - var stationBPolygonGridStr = stationBPolygonGrid.substring(9,stationBPolygonGrid.length-2); | ||
| 815 | - | ||
| 816 | - // 按逗号切割 | ||
| 817 | - var pointPolygonArray = stationBPolygonGridStr.split(','); | ||
| 818 | - | ||
| 819 | - // 多边形坐标集合 | ||
| 820 | - var polygonP = []; | ||
| 821 | - | ||
| 822 | - for(var v = 0;v<pointPolygonArray.length;v++) { | ||
| 823 | - | ||
| 824 | - polygonP.push(new BMap.Point(pointPolygonArray[v].split(" ")[0],pointPolygonArray[v].split(" ")[1])); | ||
| 825 | - | ||
| 826 | - } | ||
| 827 | - | ||
| 828 | - // 画多边形 | ||
| 829 | - polygon = new BMap.Polygon(polygonP, { | ||
| 830 | - | ||
| 831 | - // 线条显色 | ||
| 832 | - strokeColor : "blue", | ||
| 833 | - | ||
| 834 | - // 边线的宽度,以像素为单位。 | ||
| 835 | - strokeWeight : 2, | ||
| 836 | - | ||
| 837 | - // 边线透明度,取值范围0 - 1。 | ||
| 838 | - strokeOpacity : 0.5 | ||
| 839 | - }); | ||
| 840 | - | ||
| 841 | - // 增加地图覆盖物多边形 | ||
| 842 | - mapBValue.addOverlay(polygon); | ||
| 843 | - | ||
| 844 | - // 开启编辑功能(自 1.1 新增) | ||
| 845 | - polygon.enableEditing(); | ||
| 846 | - | ||
| 847 | - // 是否在平移过程中禁止动画。(自1.2新增) | ||
| 848 | - var PanOptions_ ={noAnimation :true}; | ||
| 849 | - | ||
| 850 | - // 将地图的中心点更改为给定的点。 | ||
| 851 | - mapBValue.panTo(pointPolygon,PanOptions_); | ||
| 852 | - | ||
| 853 | - // 将地图在水平位置上移动x像素,垂直位置上移动y像素。 | ||
| 854 | - mapBValue.panBy(10,-150,PanOptions_); | ||
| 855 | - | ||
| 856 | - // 添加多变行编辑事件 | ||
| 857 | - polygon.addEventListener('dblclick',function(e) { | ||
| 858 | - | ||
| 859 | - // 获取编辑的多边形对象 | ||
| 860 | - var edit_pointE = polygon; | ||
| 861 | - | ||
| 862 | - var edit_bPloygonGrid = ""; | ||
| 863 | - | ||
| 864 | - var editPolyGonLen_ = edit_pointE.getPath().length; | ||
| 865 | - | ||
| 866 | - for(var k =0;k<editPolyGonLen_;k++) { | ||
| 867 | - | ||
| 868 | - if(k==0) { | ||
| 869 | - | ||
| 870 | - edit_bPloygonGrid = edit_pointE.getPath()[k].lng + ' ' + edit_pointE.getPath()[k].lat; | ||
| 871 | - | ||
| 872 | - }else { | ||
| 873 | - | ||
| 874 | - edit_bPloygonGrid = edit_bPloygonGrid + ',' + edit_pointE.getPath()[k].lng + ' ' + edit_pointE.getPath()[k].lat; | ||
| 875 | - | ||
| 876 | - } | ||
| 877 | - | ||
| 878 | - } | ||
| 879 | - | ||
| 880 | - edit_bPloygonGrid = edit_bPloygonGrid + ',' + edit_pointE.getPath()[0].lng + ' ' + edit_pointE.getPath()[0].lat; | ||
| 881 | - | ||
| 882 | - // 多边形中心点 | ||
| 883 | - var centre_points = edit_pointE.getBounds().getCenter().lng + ' ' + edit_pointE.getBounds().getCenter().lat; | ||
| 884 | - | ||
| 885 | - /** 设置修改站点集合对象站点中心点百度坐标属性值 @param:<bJwpoints:中心点百度坐标) */ | ||
| 886 | - objStation.stationBJwpoints = centre_points; | ||
| 887 | - | ||
| 888 | - /** 设置修改站点集合对象范围图形类型属性值 @param:<shapesType:范围图形类型) */ | ||
| 889 | - objStation.stationShapesType = 'd';; | ||
| 890 | - | ||
| 891 | - /** 设置修改站点集合对象圆形半径属性值 @param:<radius:圆形半径) */ | ||
| 892 | - objStation.stationRadius = ''; | ||
| 893 | - | ||
| 894 | - /** 设置修改站点集合对象图形百度坐标集合属性值 @param:<bPolygonGrid:图形百度坐标集合) */ | ||
| 895 | - objStation.stationBPolygonGrid = edit_bPloygonGrid; | ||
| 896 | - | ||
| 897 | - $.get('editstation.html', function(m){ | ||
| 898 | - | ||
| 899 | - $(pjaxContainer).append(m); | ||
| 900 | - | ||
| 901 | - $('#edit_station_mobal').trigger('editSelectMobal_show', [WorldsBMapLine,MapGetAjaxData,PublicFunctions,objStation]); | ||
| 902 | - | ||
| 903 | - }); | ||
| 904 | - | ||
| 905 | - // 打开按钮事件 | ||
| 906 | - PublicFunctions.editAChangeCssRemoveDisabled(); | ||
| 907 | - }); | ||
| 908 | - | ||
| 909 | - } | ||
| 910 | - } | ||
| 911 | - }, | ||
| 912 | - | ||
| 913 | - localtionPoint : function(stationNameV) { | ||
| 914 | - | ||
| 915 | - WorldsBMapLine.localSearchFromAdreesToPoint(stationNameV,function(Points) { | ||
| 916 | - | ||
| 917 | - if(Points) { | ||
| 918 | - | ||
| 919 | - var BJwpointsArray = Points.split(' '); | ||
| 920 | - | ||
| 921 | - var stationNameChangePoint = new BMap.Point(BJwpointsArray[0], BJwpointsArray[1]); | ||
| 922 | - | ||
| 923 | - var marker_stargt2 = new BMap.Marker(stationNameChangePoint); | ||
| 924 | - | ||
| 925 | - var PanOptions ={noAnimation :true}; | ||
| 926 | - | ||
| 927 | - mapBValue.panTo(stationNameChangePoint,PanOptions); | ||
| 928 | - | ||
| 929 | - mapBValue.panBy(0,-100); | ||
| 930 | - | ||
| 931 | - // 将标注添加到地图中 | ||
| 932 | - mapBValue.addOverlay(marker_stargt2); | ||
| 933 | - | ||
| 934 | - //跳动的动画 | ||
| 935 | - marker_stargt2.setAnimation(BMAP_ANIMATION_BOUNCE); | ||
| 936 | - | ||
| 937 | - } | ||
| 938 | - | ||
| 939 | - }); | ||
| 940 | - | ||
| 941 | - }, | ||
| 942 | - | ||
| 943 | - // 根据地理名称获取百度经纬度坐标 | ||
| 944 | - localSearchFromAdreesToPoint: function(Address,callback) { | ||
| 945 | - | ||
| 946 | - // 创建一个搜索类实例 | ||
| 947 | - var localSearch = new BMap.LocalSearch(mapBValue); | ||
| 948 | - | ||
| 949 | - // 检索完成后的回调函数。 | ||
| 950 | - localSearch.setSearchCompleteCallback(function (searchResult) { | ||
| 951 | - | ||
| 952 | - var resultPoints = ''; | ||
| 953 | - | ||
| 954 | - if(searchResult) { | ||
| 955 | - | ||
| 956 | - // 返回索引指定的结果。索引0表示第1条结果 | ||
| 957 | - var poi = searchResult.getPoi(0); | ||
| 958 | - | ||
| 959 | - if(poi) { | ||
| 960 | - | ||
| 961 | - //获取经度和纬度 | ||
| 962 | - resultPoints = poi.point.lng + ' ' + poi.point.lat; | ||
| 963 | - | ||
| 964 | - callback && callback(resultPoints); | ||
| 965 | - | ||
| 966 | - }else { | ||
| 967 | - | ||
| 968 | - callback && callback(false); | ||
| 969 | - | ||
| 970 | - } | ||
| 971 | - | ||
| 972 | - }else { | ||
| 973 | - | ||
| 974 | - callback && callback(false); | ||
| 975 | - } | ||
| 976 | - | ||
| 977 | - }); | ||
| 978 | - | ||
| 979 | - // 根据检索词发起检索。 | ||
| 980 | - localSearch.search(Address); | ||
| 981 | - | ||
| 982 | - }, | ||
| 983 | - | ||
| 984 | - clearMarkAndOverlays : function() { | ||
| 985 | - | ||
| 986 | - // 清楚地图覆盖物 | ||
| 987 | - mapBValue.clearOverlays(); | ||
| 988 | - | ||
| 989 | - mapBValue.removeOverlay(); | ||
| 990 | - | ||
| 991 | - } | ||
| 992 | - | ||
| 993 | - } | ||
| 994 | - | ||
| 995 | - return Bmap; | ||
| 996 | - | 1 | +/** |
| 2 | + * 百度地图 | ||
| 3 | + * | ||
| 4 | + * - - - - - -》init:地图初始化 | ||
| 5 | + * | ||
| 6 | + * - - - - - -》getDistanceAndDuration:获取距离与时间 | ||
| 7 | + * | ||
| 8 | + * - - - - - -》drawingUpline:在地图上画出上行线路走向 | ||
| 9 | + * | ||
| 10 | + * - - - - - -》stationsPointsToLibraryPoint:根据站点坐标匹配库中的公交站点(手动规划) | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +var WorldsBMapLine = function () { | ||
| 14 | + | ||
| 15 | + /** WorldsBMapLine 全局变量定义 mapBValue:地图对象;polyUpline:走向折线;sectionList:截取过的路段 ;pointIndex:计算路段被切的次数; | ||
| 16 | + * firstPoint:截取路段的第一个点;iseditStatus:路段是否在编辑状态;isCutSection : 获取路段是否在截取状态*/ | ||
| 17 | + var mapBValue = '', polyUpline='', sectionList = [], pointIndex = 0, iseditStatus = false, firstPoint = null, isCutSection = false; | ||
| 18 | + | ||
| 19 | + var Bmap = { | ||
| 20 | + | ||
| 21 | + init : function() { | ||
| 22 | + | ||
| 23 | + // 设置中心点, | ||
| 24 | + var CENTER_POINT = {lng : 121.528733,lat : 31.237425}; | ||
| 25 | + | ||
| 26 | + // 百度API Key | ||
| 27 | + var bdKey = 'IGGrr4UjwIYzatoCRFKEL8sT'; | ||
| 28 | + | ||
| 29 | + // 初始化百度地图 | ||
| 30 | + mapBValue = new BMap.Map("bmap_basic"); | ||
| 31 | + | ||
| 32 | + //中心点和缩放级别 | ||
| 33 | + mapBValue.centerAndZoom(new BMap.Point(CENTER_POINT.lng,CENTER_POINT.lat), 20); | ||
| 34 | + | ||
| 35 | + //启用地图拖拽事件,默认启用(可不写) | ||
| 36 | + mapBValue.enableDragging(); | ||
| 37 | + | ||
| 38 | + //启用地图滚轮放大缩小 | ||
| 39 | + mapBValue.enableScrollWheelZoom(); | ||
| 40 | + | ||
| 41 | + //禁用鼠标双击放大 | ||
| 42 | + mapBValue.disableDoubleClickZoom(); | ||
| 43 | + | ||
| 44 | + //启用键盘上下左右键移动地图 | ||
| 45 | + mapBValue.enableKeyboard(); | ||
| 46 | + | ||
| 47 | + return mapBValue; | ||
| 48 | + }, | ||
| 49 | + /** 获取第一个切路段的点 @return Point*/ | ||
| 50 | + getFirstPoint : function() { | ||
| 51 | + return firstPoint; | ||
| 52 | + }, | ||
| 53 | + /** 第一个切路段的点 */ | ||
| 54 | + setFirstPoint : function(Point) { | ||
| 55 | + firstPoint = Point; | ||
| 56 | + }, | ||
| 57 | + /** 获取地图对象 @return 地图对象map */ | ||
| 58 | + getmapBValue : function() { | ||
| 59 | + | ||
| 60 | + return mapBValue; | ||
| 61 | + | ||
| 62 | + }, | ||
| 63 | + | ||
| 64 | + getPolyUpline : function() { | ||
| 65 | + | ||
| 66 | + return polyUpline; | ||
| 67 | + }, | ||
| 68 | + | ||
| 69 | + /** 获取截取过的路段 @return 路段对象List */ | ||
| 70 | + getSectionList : function() { | ||
| 71 | + | ||
| 72 | + return sectionList; | ||
| 73 | + | ||
| 74 | + }, | ||
| 75 | + setSectionList : function(list) { | ||
| 76 | + | ||
| 77 | + sectionList = list; | ||
| 78 | + }, | ||
| 79 | + initCutSectionPoint : function() { | ||
| 80 | + sectionList = []; | ||
| 81 | + var tbodyHtml = template('section_list',{list : sectionList}); | ||
| 82 | + $('#section_table tbody').html(tbodyHtml); | ||
| 83 | + }, | ||
| 84 | + /** 获取切路段的点下标 @return int*/ | ||
| 85 | + setPointIndex : function(index) { | ||
| 86 | + pointIndex = index; | ||
| 87 | + }, | ||
| 88 | + getPointIndex : function() { | ||
| 89 | + | ||
| 90 | + return pointIndex; | ||
| 91 | + | ||
| 92 | + }, | ||
| 93 | + /** 获取路段是否在编辑状态 @return boolean*/ | ||
| 94 | + getIsEditStatus : function() { | ||
| 95 | + return iseditStatus; | ||
| 96 | + }, | ||
| 97 | + setIsEditStatus : function(v) { | ||
| 98 | + iseditStatus = v ; | ||
| 99 | + }, | ||
| 100 | + | ||
| 101 | + /** 获取路段是否在截取状态 @return boolean*/ | ||
| 102 | + getIsCutSection : function() { | ||
| 103 | + return isCutSection; | ||
| 104 | + }, | ||
| 105 | + setIsCutSection : function(v) { | ||
| 106 | + isCutSection = v ; | ||
| 107 | + }, | ||
| 108 | + | ||
| 109 | + /** 获取距离与时间 @param <points:坐标点集合> */ | ||
| 110 | + getDistanceAndDuration : function(points,callback){ | ||
| 111 | + | ||
| 112 | + // 获取长度 | ||
| 113 | + var len = points.length; | ||
| 114 | + (function(){ | ||
| 115 | + | ||
| 116 | + if (!arguments.callee.count) { | ||
| 117 | + | ||
| 118 | + arguments.callee.count = 0; | ||
| 119 | + | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + arguments.callee.count++; | ||
| 123 | + | ||
| 124 | + var index = parseInt(arguments.callee.count) - 1; | ||
| 125 | + | ||
| 126 | + if (index >= len-1) { | ||
| 127 | + callback && callback(points); | ||
| 128 | + | ||
| 129 | + return; | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + // 当函数被调用时,它的arguments.callee对象就会指向自身,也就是一个对自己的引用。(当前正在执行的函数。) | ||
| 133 | + var f = arguments.callee; | ||
| 134 | + // 起点坐标 <坐标格式:40.056878,116.30815> | ||
| 135 | + var origin = points[index].potion.lat + ',' + points[index].potion.lng; | ||
| 136 | + | ||
| 137 | + // 终点坐标 <坐标格式:40.056878,116.30815> | ||
| 138 | + var destination = points[index+1].potion.lat + ',' + points[index+1].potion.lng; | ||
| 139 | + var region = '上海'; | ||
| 140 | + | ||
| 141 | + var origin_region = '上海'; | ||
| 142 | + | ||
| 143 | + var destination_region = '上海'; | ||
| 144 | + | ||
| 145 | + var output = 'json'; | ||
| 146 | + | ||
| 147 | + var ak_My = 'wjlITmXeCek5MxyU3ZUBkTeU8B0o0npk'; | ||
| 148 | + | ||
| 149 | + /** | ||
| 150 | + * origin:起点名称或经纬度; | ||
| 151 | + * | ||
| 152 | + * destination:终点名称或经纬度; | ||
| 153 | + * | ||
| 154 | + * origin_region:起始点所在城市,驾车导航时必填。 | ||
| 155 | + * | ||
| 156 | + * destination_region:终点所在城市,驾车导航时必填。 | ||
| 157 | + * | ||
| 158 | + * output :表示输出类型,可设置为xml或json,默认为xml。 | ||
| 159 | + * | ||
| 160 | + **/ | ||
| 161 | + var paramsB = {origin:origin,destination:destination,region:region,origin_region:origin_region,destination_region:destination_region,output:output,ak:ak_My}; | ||
| 162 | + | ||
| 163 | + /** @description :未认证开发者默认配额为:2000次/天。 */ | ||
| 164 | + $.ajax({ | ||
| 165 | + | ||
| 166 | + // 百度地图根据坐标获取两点之间的时间与距离 | ||
| 167 | + url: '//api.map.baidu.com/direction/v1?mode=transit', | ||
| 168 | + | ||
| 169 | + data: paramsB, | ||
| 170 | + | ||
| 171 | + dataType: 'jsonp', | ||
| 172 | + | ||
| 173 | + success: function(r){ | ||
| 174 | + | ||
| 175 | + if(r) { | ||
| 176 | + | ||
| 177 | + if(r.message=='ok') { | ||
| 178 | + | ||
| 179 | + if(r.result.taxi==null) { | ||
| 180 | + | ||
| 181 | + // 获取距离(单位:米) | ||
| 182 | + points[index+1].distance = 0; | ||
| 183 | + | ||
| 184 | + // 获取时间(单位:秒) | ||
| 185 | + points[index+1].duration = 0; | ||
| 186 | + | ||
| 187 | + }else { | ||
| 188 | + | ||
| 189 | + // 获取距离(单位:米) | ||
| 190 | + points[index+1].distance = r.result.taxi.distance; | ||
| 191 | + | ||
| 192 | + // 获取时间(单位:秒) | ||
| 193 | + points[index+1].duration = r.result.taxi.duration; | ||
| 194 | + | ||
| 195 | + } | ||
| 196 | + | ||
| 197 | + | ||
| 198 | + } | ||
| 199 | + | ||
| 200 | + } | ||
| 201 | + | ||
| 202 | + f(); | ||
| 203 | + } | ||
| 204 | + }); | ||
| 205 | + | ||
| 206 | + })(); | ||
| 207 | + | ||
| 208 | + }, | ||
| 209 | + drawingSection: function(data){ | ||
| 210 | + /** 获取站点路由信息 @param:<Line.id:线路Id;0:上行> @return:<resultdata:站点路由数据> */ | ||
| 211 | + WorldsBMapLine.clearMarkAndOverlays(); | ||
| 212 | + // 编辑路段数据 | ||
| 213 | + if(data) { | ||
| 214 | + // 地图折线坐标点集合 | ||
| 215 | + var polylineArray = []; | ||
| 216 | + // 获取路段折线坐标字符串 | ||
| 217 | + var sectionBsectionVectorStr = data.sectionBsectionVector; | ||
| 218 | + if(sectionBsectionVectorStr==null) { | ||
| 219 | + return; | ||
| 220 | + } | ||
| 221 | + // 切割段折线坐标字符串 | ||
| 222 | + var tempStr = sectionBsectionVectorStr.substring(11,sectionBsectionVectorStr.length-1); | ||
| 223 | + // 分割折线坐标字符串 | ||
| 224 | + var lineArray = tempStr.split(','); | ||
| 225 | + for(var i = 0;i<lineArray.length;i++) { | ||
| 226 | + polylineArray.push(new BMap.Point(lineArray[i].split(' ')[0],lineArray[i].split(' ')[1])); | ||
| 227 | + } | ||
| 228 | + var index = parseInt(polylineArray.length/2); | ||
| 229 | + var center = polylineArray[index]; | ||
| 230 | + /** 在地图上画出线路走向 @param:<polylineArray:地图折线坐标点集合;resultdata:站点路由数据> */ | ||
| 231 | + WorldsBMapLine.drawingUpline(polylineArray,center); | ||
| 232 | + /** 在地图上画点 @param:<point_center:中心坐标点> */ | ||
| 233 | + WorldsBMapLine.drawingUpStationPoint(center,data.sectionName,1); | ||
| 234 | + } | ||
| 235 | + }, | ||
| 236 | + // 在地图上画出上行线路走向(单路段) | ||
| 237 | + drawingUpline : function (polylineArray,polyline_center,data) { | ||
| 238 | + /*WorldsBMap.clearMarkAndOverlays();*/ | ||
| 239 | + polyUpline = ''; | ||
| 240 | + // 创建线路走向 | ||
| 241 | + polyUpline = new BMap.Polyline(polylineArray, {strokeColor : "blue",strokeWeight : 6,strokeOpacity : 0.5}); | ||
| 242 | + // polyUpline.data = data; | ||
| 243 | + // 把折线添加到地图上 | ||
| 244 | + mapBValue.addOverlay(polyUpline); | ||
| 245 | + var PanOptions_ ={noAnimation :true}; | ||
| 246 | + mapBValue.reset(); | ||
| 247 | + mapBValue.panTo(polyline_center,PanOptions_); | ||
| 248 | + mapBValue.panBy(500,-510,PanOptions_); | ||
| 249 | + mapBValue.setZoom(14); | ||
| 250 | + }, | ||
| 251 | + | ||
| 252 | + // 在地图上画出上行线路走向(多路段) | ||
| 253 | + drawingUpline01 : function (polylineArray,polyline_center,data) { | ||
| 254 | + var polyUpline01 = 'polyline' + '_' + data.sectionrouteId; | ||
| 255 | + // 创建线路走向 | ||
| 256 | + polyUpline01 = new BMap.Polyline(polylineArray, {strokeColor : "blue",strokeWeight : 6,strokeOpacity : 0.5}); | ||
| 257 | + polyUpline01.data = data; | ||
| 258 | + // 把折线添加到地图上 | ||
| 259 | + mapBValue.addOverlay(polyUpline01); | ||
| 260 | + var sectionPoint = []; | ||
| 261 | + // 线路单击事件 | ||
| 262 | + polyUpline01.addEventListener('click',function(e) { | ||
| 263 | + if(WorldsBMapLine.getIsEditStatus()) { | ||
| 264 | + layer.msg('请先保存正在编辑的路段信息...'); | ||
| 265 | + return false; | ||
| 266 | + } | ||
| 267 | + if(WorldsBMapLine.getIsCutSection()) { | ||
| 268 | + layer.msg('请先撤销所有切路段的点...'); | ||
| 269 | + return false; | ||
| 270 | + } | ||
| 271 | + polyUpline01.enableEditing(); | ||
| 272 | + WorldsBMapLine.setIsEditStatus(true); | ||
| 273 | + // 关闭按钮事件 | ||
| 274 | + PublicFunctions.addAChangeCssAddDisabled(); | ||
| 275 | + }); | ||
| 276 | + | ||
| 277 | + // 添加路段双击事件 | ||
| 278 | + polyUpline01.addEventListener("dblclick",function(e){ | ||
| 279 | + if(WorldsBMapLine.getIsCutSection()) { | ||
| 280 | + layer.msg('请先撤销所有切路段的点...'); | ||
| 281 | + return false; | ||
| 282 | + } | ||
| 283 | + WorldsBMapLine.setIsEditStatus(false); | ||
| 284 | + // 关闭 | ||
| 285 | + layer.closeAll(); | ||
| 286 | + polyUpline01.disableEditing(); | ||
| 287 | + EditSectionObj.setEitdSection(polyUpline01.data); | ||
| 288 | + // 获取折线坐标集合 | ||
| 289 | + var editPloyLineArray = polyUpline01.getPath(); | ||
| 290 | + EditSectionObj.setEitdBsectionVector(JSON.stringify(editPloyLineArray)); | ||
| 291 | + sectionList = []; | ||
| 292 | + var tbodyHtml = template('section_list',{list : sectionList}); | ||
| 293 | + // 截取路段 | ||
| 294 | + $('#section_table tbody').html(tbodyHtml); | ||
| 295 | + // 加载修改路段弹出层mobal页面 | ||
| 296 | + $.get('editsection.html', function(m){ | ||
| 297 | + $(pjaxContainer).append(m); | ||
| 298 | + $('#edit_section_mobal_cache').trigger('editSectionMobalCache_show', [WorldsBMapLine,MapGetAjaxData,EditSectionObj,PublicFunctions]); | ||
| 299 | + }); | ||
| 300 | + // 打开按钮事件 | ||
| 301 | + PublicFunctions.editAChangeCssRemoveDisabled(); | ||
| 302 | + }); | ||
| 303 | + | ||
| 304 | + // 路段右击事件 | ||
| 305 | + var editSection = function(e,ee,marker){ | ||
| 306 | + if(WorldsBMapLine.getIsEditStatus()) { | ||
| 307 | + layer.msg('请先保存正在编辑的路段信息...'); | ||
| 308 | + return false; | ||
| 309 | + } | ||
| 310 | + var lng = e.lng; | ||
| 311 | + var lat = e.lat; | ||
| 312 | + var sectionName = null; | ||
| 313 | + var marker = new BMap.Marker(new BMap.Point(lng, lat)); // 创建点 | ||
| 314 | + var label = new BMap.Label(pointIndex+1,{offset:new BMap.Size(pointIndex>8?0:4,0)}); | ||
| 315 | + label.setStyle({border :"0", color : "white",backgroundColor:"rgba(0,0,0,0)"}); | ||
| 316 | + marker.setLabel(label); | ||
| 317 | + marker.isFlag = true; | ||
| 318 | + if(pointIndex == 0) { | ||
| 319 | + sectionPoint[pointIndex] = {lng:lng , lat:lat}; | ||
| 320 | + layer.msg('进入切路段状态,请选择本路段的终点!'); | ||
| 321 | + mapBValue.addOverlay(marker);// 添加覆盖物 | ||
| 322 | + firstPoint = {lng:lng, lat:lat}; | ||
| 323 | + pointIndex++; | ||
| 324 | + EditSectionObj.setEitdSection(polyUpline01.data); | ||
| 325 | + // 获取折线坐标集合 | ||
| 326 | + var editPloyLineArray = polyUpline01.getPath(); | ||
| 327 | + EditSectionObj.setEitdBsectionVector(JSON.stringify(editPloyLineArray)); | ||
| 328 | + } else if (pointIndex > 0) { | ||
| 329 | + layer.prompt({title: '请输入路段名!'}, function(sectionName, index){ | ||
| 330 | + pointList = []; | ||
| 331 | + sectionPoint[pointIndex] = {lng:lng , lat:lat}; | ||
| 332 | + pointList[0] = sectionPoint[pointIndex-1]; | ||
| 333 | + pointList[1] = sectionPoint[pointIndex]; | ||
| 334 | + sectionList.push({name:sectionName, section:pointList}); | ||
| 335 | + layer.close(index); | ||
| 336 | + layer.msg('路段截取成功,请选择下一个路段的终点'); | ||
| 337 | + mapBValue.addOverlay(marker);// 添加覆盖物 | ||
| 338 | + var tbodyHtml = template('section_list',{list : sectionList}); | ||
| 339 | + // 截取路段 | ||
| 340 | + $('#section_table tbody').html(tbodyHtml); | ||
| 341 | + pointIndex++; | ||
| 342 | + }); | ||
| 343 | + } | ||
| 344 | + WorldsBMapLine.setIsCutSection(true); | ||
| 345 | + } | ||
| 346 | + // 路段生成类型位gps上传时才开启右击事件 | ||
| 347 | + if(EditRoute.getLineGenerationType() == 'uploadGPS') { | ||
| 348 | + var markerMenu=new BMap.ContextMenu(); | ||
| 349 | + markerMenu.addItem(new BMap.MenuItem('切路段',editSection.bind(polyUpline01))); | ||
| 350 | + polyUpline01.addContextMenu(markerMenu); | ||
| 351 | + } | ||
| 352 | + | ||
| 353 | + | ||
| 354 | + var PanOptions_ ={noAnimation :true}; | ||
| 355 | + mapBValue.reset(); | ||
| 356 | + mapBValue.panTo(polyline_center,PanOptions_); | ||
| 357 | + mapBValue.panBy(500,-510,PanOptions_); | ||
| 358 | + mapBValue.setZoom(14); | ||
| 359 | + }, | ||
| 360 | + // 删除点刷新cutSectionTable | ||
| 361 | + refreshCutSectionTable : function() { | ||
| 362 | + var tbodyHtml = template('section_list',{list : sectionList}); | ||
| 363 | + $('#section_table tbody').html(tbodyHtml); | ||
| 364 | + }, | ||
| 365 | + // 删除点刷新覆盖物 | ||
| 366 | + deleteCutSectionPoint : function(point) { | ||
| 367 | + var lng = point.lng; | ||
| 368 | + var lat = point.lat; | ||
| 369 | + var allOverlay = mapBValue.getOverlays(); | ||
| 370 | + // 删除最后一个点 | ||
| 371 | + for (var i = 0; i < allOverlay.length -1; i++){ | ||
| 372 | + if(allOverlay[i].isFlag) { | ||
| 373 | + if(allOverlay[i].point.lng == lng && allOverlay[i].point.lat == lat){ | ||
| 374 | + mapBValue.removeOverlay(allOverlay[i]); | ||
| 375 | + break; | ||
| 376 | + } | ||
| 377 | + } | ||
| 378 | + } | ||
| 379 | + }, | ||
| 380 | + // 批量画点 | ||
| 381 | + batchPaintingPoint : function() { | ||
| 382 | + // 画第一个点 | ||
| 383 | + var Point = WorldsBMapLine.getFirstPoint(); | ||
| 384 | + if(Point){ | ||
| 385 | + var marker = new BMap.Marker(new BMap.Point(Point.lng, Point.lat)); // 创建点 | ||
| 386 | + var label = new BMap.Label(1,{offset:new BMap.Size(4,0)}); | ||
| 387 | + label.setStyle({border :"0", color : "white",backgroundColor:"rgba(0,0,0,0)"}); | ||
| 388 | + marker.setLabel(label); | ||
| 389 | + marker.isFlag = true; | ||
| 390 | + mapBValue.addOverlay(marker);// 添加覆盖物 | ||
| 391 | + | ||
| 392 | + WorldsBMapLine.getFirstPoint(); | ||
| 393 | + } | ||
| 394 | + $.each(sectionList, function(index, value) { | ||
| 395 | + var section = value.section; | ||
| 396 | + | ||
| 397 | + var marker = new BMap.Marker(new BMap.Point(section[1].lng, section[1].lat)); // 创建点 | ||
| 398 | + var label = new BMap.Label(index+2,{offset:new BMap.Size(index>7?0:4,0)}); | ||
| 399 | + label.setStyle({border :"0", color : "white",backgroundColor:"rgba(0,0,0,0)"}); | ||
| 400 | + marker.setLabel(label); | ||
| 401 | + marker.isFlag = true; | ||
| 402 | + mapBValue.addOverlay(marker);// 添加覆盖物 | ||
| 403 | + }); | ||
| 404 | + | ||
| 405 | + }, | ||
| 406 | + /** 在地图上画点 @param:<point_center:中心坐标点> */ | ||
| 407 | + drawingUpStationPoint : function(point_center,stationName,s) { | ||
| 408 | + | ||
| 409 | + // 自定义标注物图片 | ||
| 410 | + var icon_target = new BMap.Icon('/pages/base/stationroute/css/img/gjzd.png',new BMap.Size(10, 10)); | ||
| 411 | + | ||
| 412 | + var html2 = '<div style="position: absolute; margin: 0pt; padding: 0pt; width: 160px; height: 26px; left: -10px; top: -35px; overflow: hidden;">' | ||
| 413 | + + '<img class="rm3_image" style="border:none;left:0px; top:0px; position:absolute;" src="/pages/base/stationroute/css/img/back160.png">' | ||
| 414 | + + '</div>' | ||
| 415 | + + '<label class=" BMapLabel" unselectable="on" style="position: absolute; -moz-user-select: none; display: inline; cursor: inherit; border: 0px none; padding: 2px 1px 1px; white-space: nowrap; font: 12px arial,simsun; z-index: 80; color: rgb(255, 102, 0); left: 15px; top: -35px;"><span style="float: left; color: #fdfdfd; margin-left: -22px; font-size: 6px;">'+ s+'</span>'+ stationName+'</label>'; | ||
| 416 | + | ||
| 417 | + | ||
| 418 | + var myRichMarker1 = new BMapLib.RichMarker(html2, point_center,{ | ||
| 419 | + "anchor" : new BMap.Size(-10,8), | ||
| 420 | + "enableDragging" : true}); | ||
| 421 | + | ||
| 422 | + | ||
| 423 | + myRichMarker1.disableDragging(); | ||
| 424 | + mapBValue.addOverlay(myRichMarker1); | ||
| 425 | + | ||
| 426 | + | ||
| 427 | + // 创建标注物 | ||
| 428 | + marker = new BMap.Marker(point_center,{icon : icon_target}); | ||
| 429 | + | ||
| 430 | + // 允许覆盖物在map.clearOverlays方法中被清除。 | ||
| 431 | + marker.enableMassClear(); | ||
| 432 | + | ||
| 433 | + mapBValue.addOverlay(marker); | ||
| 434 | + }, | ||
| 435 | + | ||
| 436 | + // 根据站点坐标匹配库中的公交站点 | ||
| 437 | + stationsPointsToLibraryPoint : function(arra,callback) { | ||
| 438 | + // 获取长度 | ||
| 439 | + var len = arra.length; | ||
| 440 | + var station = {}; | ||
| 441 | + var stationList = []; | ||
| 442 | + (function(){ | ||
| 443 | + if (!arguments.callee.count) { | ||
| 444 | + arguments.callee.count = 0; | ||
| 445 | + } | ||
| 446 | + arguments.callee.count++; | ||
| 447 | + var index = parseInt(arguments.callee.count) - 1; | ||
| 448 | + if (index >= len) { | ||
| 449 | + callback && callback(stationList); | ||
| 450 | + return ; | ||
| 451 | + } | ||
| 452 | + var f = arguments.callee; | ||
| 453 | + station = arra[index]; | ||
| 454 | + if(arra[index].name!=''){ | ||
| 455 | + | ||
| 456 | + $.get('/station/matchStation',station,function(resultStation) { | ||
| 457 | + stationList.push({name:resultStation.name ,wgs:arra[index].wgs,potion:{lng:resultStation.potion_lng, lat:resultStation.potion_lat}, isHave:resultStation.isHave , id:resultStation.id}); | ||
| 458 | + f(); | ||
| 459 | + }); | ||
| 460 | + }else { | ||
| 461 | + f(); | ||
| 462 | + } | ||
| 463 | + })() | ||
| 464 | + }, | ||
| 465 | + // 地图画多边形 | ||
| 466 | + pointsPolygon : function(objStation) { | ||
| 467 | + | ||
| 468 | + // 将视图切换到指定的缩放等级,中心点坐标不变。注意:当有信息窗口在地图上打开时,地图缩放将保证信息窗口所在的坐标位置不动。(自1.2新增) | ||
| 469 | + mapBValue.setZoom(15); | ||
| 470 | + | ||
| 471 | + // 如果不为空 | ||
| 472 | + if(objStation) { | ||
| 473 | + | ||
| 474 | + // 清除地图覆盖物 | ||
| 475 | + mapBValue.clearOverlays(); | ||
| 476 | + | ||
| 477 | + // 获取中心点坐标字符串 | ||
| 478 | + var testpointStr = objStation.stationBJwpoints; | ||
| 479 | + | ||
| 480 | + // 按空格切割中心点坐标字符串 | ||
| 481 | + var BJwpointsPolygon = testpointStr.split(' '); | ||
| 482 | + | ||
| 483 | + // 中心点坐标 | ||
| 484 | + var pointPolygon = new BMap.Point(BJwpointsPolygon[0], BJwpointsPolygon[1]); | ||
| 485 | + | ||
| 486 | + // 获取多边形坐标字符串 | ||
| 487 | + var stationBPolygonGrid = objStation.stationBPolygonGrid; | ||
| 488 | + | ||
| 489 | + // 截取多边形坐标字符串 | ||
| 490 | + var stationBPolygonGridStr = stationBPolygonGrid.substring(9,stationBPolygonGrid.length-2); | ||
| 491 | + | ||
| 492 | + // 按逗号切割 | ||
| 493 | + var pointPolygonArray = stationBPolygonGridStr.split(','); | ||
| 494 | + | ||
| 495 | + // 多边形坐标集合 | ||
| 496 | + var polygonP = []; | ||
| 497 | + | ||
| 498 | + for(var v = 0;v<pointPolygonArray.length;v++) { | ||
| 499 | + | ||
| 500 | + polygonP.push(new BMap.Point(pointPolygonArray[v].split(" ")[0],pointPolygonArray[v].split(" ")[1])); | ||
| 501 | + | ||
| 502 | + } | ||
| 503 | + | ||
| 504 | + // 画多边形 | ||
| 505 | + polygon = new BMap.Polygon(polygonP, { | ||
| 506 | + | ||
| 507 | + // 线条显色 | ||
| 508 | + strokeColor : "blue", | ||
| 509 | + | ||
| 510 | + // 边线的宽度,以像素为单位。 | ||
| 511 | + strokeWeight : 2, | ||
| 512 | + | ||
| 513 | + // 边线透明度,取值范围0 - 1。 | ||
| 514 | + strokeOpacity : 0.5 | ||
| 515 | + }); | ||
| 516 | + | ||
| 517 | + // 增加地图覆盖物多边形 | ||
| 518 | + mapBValue.addOverlay(polygon); | ||
| 519 | + | ||
| 520 | + // 信息窗口属性 | ||
| 521 | + var opts_polygon = { | ||
| 522 | + | ||
| 523 | + // 信息窗口宽度 | ||
| 524 | + width : 200, | ||
| 525 | + | ||
| 526 | + // 信息窗口高度 | ||
| 527 | + height : 400, | ||
| 528 | + | ||
| 529 | + // 信息窗位置偏移值。 | ||
| 530 | + offset: new BMap.Size(500,20), | ||
| 531 | + | ||
| 532 | + //标题 | ||
| 533 | + title : '<h4 style="color:#FFFFFF">'+objStation.stationStationName+'站详情</h4>', | ||
| 534 | + | ||
| 535 | + //设置不允许信窗发送短息 | ||
| 536 | + enableMessage : false, | ||
| 537 | + | ||
| 538 | + //是否开启点击地图关闭信息窗口 | ||
| 539 | + enableCloseOnClick : false | ||
| 540 | + }; | ||
| 541 | + | ||
| 542 | + var markTypeStr = ''; | ||
| 543 | + | ||
| 544 | + if(objStation.stationRouteStationMark=='B') { | ||
| 545 | + | ||
| 546 | + markTypeStr='起点站'; | ||
| 547 | + | ||
| 548 | + }else if(objStation.stationRouteStationMark=='Z') { | ||
| 549 | + | ||
| 550 | + markTypeStr ='中途站'; | ||
| 551 | + | ||
| 552 | + | ||
| 553 | + }else if(objStation.stationRouteStationMark=='E') { | ||
| 554 | + | ||
| 555 | + markTypeStr='终点站'; | ||
| 556 | + | ||
| 557 | + } | ||
| 558 | + | ||
| 559 | + var htm = '<HR style="border:1 dashed #987cb9" width="100%" color=#987cb9 SIZE=1>'+ | ||
| 560 | + '<span style="color:#DDD;font-size: 15px;">站点名称:' + objStation.stationStationName + '</span>' + | ||
| 561 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">站点编码:' + objStation.stationStationCod + '</span>' + | ||
| 562 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">行业编码:' + (objStation.industryCode == null ? "":objStation.industryCode) + '</span>' + | ||
| 563 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">站点序号:' + objStation.stationRouteStationRouteCode + '</span>' + | ||
| 564 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">站点类型:' + markTypeStr + '</span>' + | ||
| 565 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">纬度坐标:' + objStation.stationBJwpoints + '</span>' + | ||
| 566 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">到站时间:' + objStation.stationRouteToTime + ' 分钟</span>' + | ||
| 567 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">到站距离:' + objStation.stationRouteDistances + ' 公里</span>' + | ||
| 568 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">版本号  :' + objStation.stationRouteVersions + '</span>' + | ||
| 569 | + '<span class="help-block" style="width: 100%;font-size: 15px;;color:#DDD;'+ | ||
| 570 | + 'overflow: hidden; white-space: nowrap; text-overflow: ellipsis; " title="'+ | ||
| 571 | + objStation.stationRouteDescriptions +'" >说明/描述:' + (objStation.stationRouteDescriptions == null ? "":objStation.stationRouteDescriptions)+ '</span>' ; | ||
| 572 | + | ||
| 573 | + // 创建信息窗口 | ||
| 574 | + var infoWindow_target = new BMap.InfoWindow(htm, opts_polygon); | ||
| 575 | + // 自定义标注物图片 | ||
| 576 | + var icon_target = new BMap.Icon('/pages/base/stationroute/css/img/cz.png',new BMap.Size(20, 20)); | ||
| 577 | + | ||
| 578 | + // 创建点 | ||
| 579 | + marker = new BMap.Marker(pointPolygon,{icon : icon_target}); | ||
| 580 | + | ||
| 581 | + // 把标注添物加到地图上 | ||
| 582 | + mapBValue.addOverlay(marker); | ||
| 583 | + | ||
| 584 | + // 是否在平移过程中禁止动画。(自1.2新增) | ||
| 585 | + var PanOptions_ ={noAnimation :true}; | ||
| 586 | + | ||
| 587 | + // 将地图的中心点更改为给定的点。 | ||
| 588 | + mapBValue.panTo(pointPolygon,PanOptions_); | ||
| 589 | + | ||
| 590 | + // 将地图在水平位置上移动x像素,垂直位置上移动y像素。 | ||
| 591 | + mapBValue.panBy(10,-150,PanOptions_); | ||
| 592 | + | ||
| 593 | + //开启信息窗口 | ||
| 594 | + mapBValue.openInfoWindow(infoWindow_target,pointPolygon); | ||
| 595 | + | ||
| 596 | + } | ||
| 597 | + | ||
| 598 | + }, | ||
| 599 | + | ||
| 600 | + // 画圆 | ||
| 601 | + pointsCircle : function(objStation) { | ||
| 602 | + | ||
| 603 | + // 将视图切换到指定的缩放等级,中心点坐标不变。注意:当有信息窗口在地图上打开时,地图缩放将保证信息窗口所在的坐标位置不动。(自1.2新增) | ||
| 604 | + mapBValue.setZoom(16); | ||
| 605 | + | ||
| 606 | + if(objStation) { | ||
| 607 | + | ||
| 608 | + // 清除地图覆盖物 | ||
| 609 | + mapBValue.clearOverlays(); | ||
| 610 | + | ||
| 611 | + // 获取中心坐标点字符串分割 | ||
| 612 | + var BJwpoints = objStation.stationBJwpoints.split(' '); | ||
| 613 | + | ||
| 614 | + // 中心坐标点 | ||
| 615 | + var point = new BMap.Point(BJwpoints[0], BJwpoints[1]); | ||
| 616 | + | ||
| 617 | + //创建圆 | ||
| 618 | + circle = new BMap.Circle(point,objStation.stationRadius,{strokeColor:"blue", strokeWeight:2, strokeOpacity:0.5}); | ||
| 619 | + | ||
| 620 | + // 允许覆盖物在map.clearOverlays方法中被清除 | ||
| 621 | + circle.enableMassClear(); | ||
| 622 | + | ||
| 623 | + // 百度地图添加覆盖物圆 | ||
| 624 | + mapBValue.addOverlay(circle); | ||
| 625 | + | ||
| 626 | + // 信息窗口参数属性 | ||
| 627 | + var opts = { | ||
| 628 | + | ||
| 629 | + // 信息窗口宽度 | ||
| 630 | + width : 200, | ||
| 631 | + | ||
| 632 | + // 信息窗口高度 | ||
| 633 | + height : 450, | ||
| 634 | + | ||
| 635 | + // 信息窗位置偏移值。 | ||
| 636 | + offset: new BMap.Size(500,120), | ||
| 637 | + | ||
| 638 | + //标题 | ||
| 639 | + title : '<h4 style="color:#FFFFFF">'+objStation.stationStationName+'站详情</h4>', | ||
| 640 | + | ||
| 641 | + //设置不允许信窗发送短息 | ||
| 642 | + enableMessage : false, | ||
| 643 | + | ||
| 644 | + //是否开启点击地图关闭信息窗口 | ||
| 645 | + enableCloseOnClick : false, | ||
| 646 | + | ||
| 647 | + // 是否开启信息窗口打开时地图自动移动(默认开启)。(自 1.1 新增) | ||
| 648 | + enableAutoPan:false | ||
| 649 | + }; | ||
| 650 | + | ||
| 651 | + var markTypeStr = ''; | ||
| 652 | + | ||
| 653 | + if(objStation.stationRouteStationMark=='B') { | ||
| 654 | + | ||
| 655 | + markTypeStr='起点站'; | ||
| 656 | + | ||
| 657 | + }else if(objStation.stationRouteStationMark=='Z') { | ||
| 658 | + | ||
| 659 | + markTypeStr ='中途站'; | ||
| 660 | + | ||
| 661 | + | ||
| 662 | + }else if(objStation.stationRouteStationMark=='E') { | ||
| 663 | + | ||
| 664 | + markTypeStr='终点站'; | ||
| 665 | + | ||
| 666 | + } | ||
| 667 | + | ||
| 668 | + var htm = '<HR style="border:1 dashed #987cb9" width="100%" color=#987cb9 SIZE=1>'+ | ||
| 669 | + '<span style="color:#DDD;font-size: 15px;">站点名称:' + objStation.stationStationName + '</span>' + | ||
| 670 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">站点编码:' + objStation.stationStationCod + '</span>' + | ||
| 671 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">行业编码:' + (objStation.industryCode == null ? "":objStation.industryCode)+ '</span>' + | ||
| 672 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">站点序号:' + objStation.stationRouteStationRouteCode + '</span>' + | ||
| 673 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">站点类型:' + markTypeStr + '</span>' + | ||
| 674 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">纬度坐标:' + objStation.stationBJwpoints + '</span>' + | ||
| 675 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">到站时间:' + objStation.stationRouteToTime + ' 分钟</span>' + | ||
| 676 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">到站距离:' + objStation.stationRouteDistances + ' 公里</span>' + | ||
| 677 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">范围半径:' + objStation.stationRadius + '</span>' + | ||
| 678 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">版本号  :' + objStation.stationRouteVersions + '</span>' + | ||
| 679 | + '<span class="help-block" style="width: 100%;font-size: 15px;;color:#DDD;'+ | ||
| 680 | + 'overflow: hidden; white-space: nowrap; text-overflow: ellipsis; " title="'+ | ||
| 681 | + objStation.stationRouteDescriptions +'" >说明/描述:' + (objStation.stationRouteDescriptions == null ? "":objStation.stationRouteDescriptions) + '</span>' ; | ||
| 682 | + | ||
| 683 | + // 创建信息窗口 | ||
| 684 | + var infoWindow_target = new BMap.InfoWindow(htm, opts); | ||
| 685 | + // 自定义标注物图片 | ||
| 686 | + var icon_target = new BMap.Icon('/pages/base/stationroute/css/img/cz.png',new BMap.Size(20, 20)); | ||
| 687 | + | ||
| 688 | + // 创建点 | ||
| 689 | + marker = new BMap.Marker(point,{icon : icon_target}); | ||
| 690 | + | ||
| 691 | + // 把标注添物加到地图上 | ||
| 692 | + mapBValue.addOverlay(marker); | ||
| 693 | + | ||
| 694 | + setTimeout(function(){ | ||
| 695 | + //开启信息窗口 | ||
| 696 | + marker.openInfoWindow(infoWindow_target,point); | ||
| 697 | + | ||
| 698 | + },100); | ||
| 699 | + | ||
| 700 | + // 是否在平移过程中禁止动画。(自1.2新增) | ||
| 701 | + var PanOptions_ ={noAnimation :true}; | ||
| 702 | + | ||
| 703 | + // 将地图的中心点更改为给定的点。 | ||
| 704 | + mapBValue.panTo(point,PanOptions_); | ||
| 705 | + | ||
| 706 | + mapBValue.panBy(10,-200,PanOptions_); | ||
| 707 | + | ||
| 708 | + // 添加标志物监听事件 | ||
| 709 | + marker.addEventListener("click",function() { | ||
| 710 | + | ||
| 711 | + //开启信息窗口 | ||
| 712 | + marker.openInfoWindow(infoWindow_target,point); | ||
| 713 | + | ||
| 714 | + }); | ||
| 715 | + | ||
| 716 | + } | ||
| 717 | + | ||
| 718 | + }, | ||
| 719 | + // 编辑图形 | ||
| 720 | + editShapes : function(objStation) { | ||
| 721 | + | ||
| 722 | + // 清空地图 | ||
| 723 | + WorldsBMapLine.clearMarkAndOverlays(); | ||
| 724 | + | ||
| 725 | + // 站点对象不为空 | ||
| 726 | + if(objStation) { | ||
| 727 | + var stationShapesType = objStation.stationShapesType; | ||
| 728 | + | ||
| 729 | + // 将视图切换到指定的缩放等级,中心点坐标不变。注意:当有信息窗口在地图上打开时,地图缩放将保证信息窗口所在的坐标位置不动。(自1.2新增) | ||
| 730 | + mapBValue.setZoom(16); | ||
| 731 | + | ||
| 732 | + // 编辑圆 | ||
| 733 | + if(stationShapesType =='r') { | ||
| 734 | + | ||
| 735 | + // 获取中心坐标点字符串分割 | ||
| 736 | + var BJwpoints = objStation.stationBJwpoints.split(' '); | ||
| 737 | + | ||
| 738 | + // 中心坐标点 | ||
| 739 | + var point = new BMap.Point(BJwpoints[0], BJwpoints[1]); | ||
| 740 | + | ||
| 741 | + //创建圆 | ||
| 742 | + circle = new BMap.Circle(point,objStation.stationRadius,{strokeColor:"blue", strokeWeight:2, strokeOpacity:0.5}); | ||
| 743 | + | ||
| 744 | + // 允许覆盖物在map.clearOverlays方法中被清除 | ||
| 745 | + circle.enableMassClear(); | ||
| 746 | + | ||
| 747 | + // 百度地图添加覆盖物圆 | ||
| 748 | + mapBValue.addOverlay(circle); | ||
| 749 | + | ||
| 750 | + // 开启编辑功能 | ||
| 751 | + circle.enableEditing(); | ||
| 752 | + | ||
| 753 | + // 是否在平移过程中禁止动画。(自1.2新增) | ||
| 754 | + var PanOptions_ ={noAnimation :true}; | ||
| 755 | + | ||
| 756 | + // 将地图的中心点更改为给定的点。 | ||
| 757 | + mapBValue.panTo(point,PanOptions_); | ||
| 758 | + | ||
| 759 | + mapBValue.panBy(10,-200,PanOptions_); | ||
| 760 | + | ||
| 761 | + // 编辑圆监听事件 | ||
| 762 | + circle.addEventListener('dblclick',function() { | ||
| 763 | + | ||
| 764 | + // 返回圆形的半径,单位为米。 | ||
| 765 | + var newRadius = circle.getRadius(); | ||
| 766 | + | ||
| 767 | + // 返回圆形的中心点坐标。 | ||
| 768 | + var newCenter = circle.getCenter().lng + ' ' + circle.getCenter().lat; | ||
| 769 | + | ||
| 770 | + /** 设置修改站点集合对象站点中心点百度坐标属性值 @param:<bJwpoints:中心点百度坐标) */ | ||
| 771 | + objStation.stationBJwpoints = newCenter; | ||
| 772 | + | ||
| 773 | + /** 设置修改站点集合对象范围图形类型属性值 @param:<shapesType:范围图形类型) */ | ||
| 774 | +// objStation.stationBJwpoints = 'r'; | ||
| 775 | + | ||
| 776 | + /** 设置修改站点集合对象圆形半径属性值 @param:<radius:圆形半径) */ | ||
| 777 | + objStation.stationRadius = Math.round(newRadius); | ||
| 778 | + | ||
| 779 | + /** 设置修改站点集合对象图形百度坐标集合属性值 @param:<bPolygonGrid:图形百度坐标集合) */ | ||
| 780 | + objStation.stationBPolygonGrid = ''; | ||
| 781 | + | ||
| 782 | + // 加载编辑页面 | ||
| 783 | + $.get('editstation.html', function(m){ | ||
| 784 | + | ||
| 785 | + $(pjaxContainer).append(m); | ||
| 786 | + | ||
| 787 | + $('#edit_station_mobal').trigger('editSelectMobal_show', [WorldsBMapLine,MapGetAjaxData,PublicFunctions,objStation]); | ||
| 788 | + | ||
| 789 | + }); | ||
| 790 | + | ||
| 791 | + // 打开按钮事件 | ||
| 792 | + PublicFunctions.editAChangeCssRemoveDisabled(); | ||
| 793 | + }); | ||
| 794 | + | ||
| 795 | + // 编辑多边行 | ||
| 796 | + }else if(stationShapesType =='d') { | ||
| 797 | + | ||
| 798 | + // 清除地图覆盖物 | ||
| 799 | + mapBValue.clearOverlays(); | ||
| 800 | + | ||
| 801 | + // 获取中心点坐标字符串 | ||
| 802 | + var testpointStr = objStation.stationBJwpoints; | ||
| 803 | + | ||
| 804 | + // 按空格切割中心点坐标字符串 | ||
| 805 | + var BJwpointsPolygon = testpointStr.split(' '); | ||
| 806 | + | ||
| 807 | + // 中心点坐标 | ||
| 808 | + var pointPolygon = new BMap.Point(BJwpointsPolygon[0], BJwpointsPolygon[1]); | ||
| 809 | + | ||
| 810 | + // 获取多边形坐标字符串 | ||
| 811 | + var stationBPolygonGrid = objStation.stationBPolygonGrid; | ||
| 812 | + | ||
| 813 | + // 截取多边形坐标字符串 | ||
| 814 | + var stationBPolygonGridStr = stationBPolygonGrid.substring(9,stationBPolygonGrid.length-2); | ||
| 815 | + | ||
| 816 | + // 按逗号切割 | ||
| 817 | + var pointPolygonArray = stationBPolygonGridStr.split(','); | ||
| 818 | + | ||
| 819 | + // 多边形坐标集合 | ||
| 820 | + var polygonP = []; | ||
| 821 | + | ||
| 822 | + for(var v = 0;v<pointPolygonArray.length;v++) { | ||
| 823 | + | ||
| 824 | + polygonP.push(new BMap.Point(pointPolygonArray[v].split(" ")[0],pointPolygonArray[v].split(" ")[1])); | ||
| 825 | + | ||
| 826 | + } | ||
| 827 | + | ||
| 828 | + // 画多边形 | ||
| 829 | + polygon = new BMap.Polygon(polygonP, { | ||
| 830 | + | ||
| 831 | + // 线条显色 | ||
| 832 | + strokeColor : "blue", | ||
| 833 | + | ||
| 834 | + // 边线的宽度,以像素为单位。 | ||
| 835 | + strokeWeight : 2, | ||
| 836 | + | ||
| 837 | + // 边线透明度,取值范围0 - 1。 | ||
| 838 | + strokeOpacity : 0.5 | ||
| 839 | + }); | ||
| 840 | + | ||
| 841 | + // 增加地图覆盖物多边形 | ||
| 842 | + mapBValue.addOverlay(polygon); | ||
| 843 | + | ||
| 844 | + // 开启编辑功能(自 1.1 新增) | ||
| 845 | + polygon.enableEditing(); | ||
| 846 | + | ||
| 847 | + // 是否在平移过程中禁止动画。(自1.2新增) | ||
| 848 | + var PanOptions_ ={noAnimation :true}; | ||
| 849 | + | ||
| 850 | + // 将地图的中心点更改为给定的点。 | ||
| 851 | + mapBValue.panTo(pointPolygon,PanOptions_); | ||
| 852 | + | ||
| 853 | + // 将地图在水平位置上移动x像素,垂直位置上移动y像素。 | ||
| 854 | + mapBValue.panBy(10,-150,PanOptions_); | ||
| 855 | + | ||
| 856 | + // 添加多变行编辑事件 | ||
| 857 | + polygon.addEventListener('dblclick',function(e) { | ||
| 858 | + | ||
| 859 | + // 获取编辑的多边形对象 | ||
| 860 | + var edit_pointE = polygon; | ||
| 861 | + | ||
| 862 | + var edit_bPloygonGrid = ""; | ||
| 863 | + | ||
| 864 | + var editPolyGonLen_ = edit_pointE.getPath().length; | ||
| 865 | + | ||
| 866 | + for(var k =0;k<editPolyGonLen_;k++) { | ||
| 867 | + | ||
| 868 | + if(k==0) { | ||
| 869 | + | ||
| 870 | + edit_bPloygonGrid = edit_pointE.getPath()[k].lng + ' ' + edit_pointE.getPath()[k].lat; | ||
| 871 | + | ||
| 872 | + }else { | ||
| 873 | + | ||
| 874 | + edit_bPloygonGrid = edit_bPloygonGrid + ',' + edit_pointE.getPath()[k].lng + ' ' + edit_pointE.getPath()[k].lat; | ||
| 875 | + | ||
| 876 | + } | ||
| 877 | + | ||
| 878 | + } | ||
| 879 | + | ||
| 880 | + edit_bPloygonGrid = edit_bPloygonGrid + ',' + edit_pointE.getPath()[0].lng + ' ' + edit_pointE.getPath()[0].lat; | ||
| 881 | + | ||
| 882 | + // 多边形中心点 | ||
| 883 | + var centre_points = edit_pointE.getBounds().getCenter().lng + ' ' + edit_pointE.getBounds().getCenter().lat; | ||
| 884 | + | ||
| 885 | + /** 设置修改站点集合对象站点中心点百度坐标属性值 @param:<bJwpoints:中心点百度坐标) */ | ||
| 886 | + objStation.stationBJwpoints = centre_points; | ||
| 887 | + | ||
| 888 | + /** 设置修改站点集合对象范围图形类型属性值 @param:<shapesType:范围图形类型) */ | ||
| 889 | + objStation.stationShapesType = 'd';; | ||
| 890 | + | ||
| 891 | + /** 设置修改站点集合对象圆形半径属性值 @param:<radius:圆形半径) */ | ||
| 892 | + objStation.stationRadius = ''; | ||
| 893 | + | ||
| 894 | + /** 设置修改站点集合对象图形百度坐标集合属性值 @param:<bPolygonGrid:图形百度坐标集合) */ | ||
| 895 | + objStation.stationBPolygonGrid = edit_bPloygonGrid; | ||
| 896 | + | ||
| 897 | + $.get('editstation.html', function(m){ | ||
| 898 | + | ||
| 899 | + $(pjaxContainer).append(m); | ||
| 900 | + | ||
| 901 | + $('#edit_station_mobal').trigger('editSelectMobal_show', [WorldsBMapLine,MapGetAjaxData,PublicFunctions,objStation]); | ||
| 902 | + | ||
| 903 | + }); | ||
| 904 | + | ||
| 905 | + // 打开按钮事件 | ||
| 906 | + PublicFunctions.editAChangeCssRemoveDisabled(); | ||
| 907 | + }); | ||
| 908 | + | ||
| 909 | + } | ||
| 910 | + } | ||
| 911 | + }, | ||
| 912 | + | ||
| 913 | + localtionPoint : function(stationNameV) { | ||
| 914 | + | ||
| 915 | + WorldsBMapLine.localSearchFromAdreesToPoint(stationNameV,function(Points) { | ||
| 916 | + | ||
| 917 | + if(Points) { | ||
| 918 | + | ||
| 919 | + var BJwpointsArray = Points.split(' '); | ||
| 920 | + | ||
| 921 | + var stationNameChangePoint = new BMap.Point(BJwpointsArray[0], BJwpointsArray[1]); | ||
| 922 | + | ||
| 923 | + var marker_stargt2 = new BMap.Marker(stationNameChangePoint); | ||
| 924 | + | ||
| 925 | + var PanOptions ={noAnimation :true}; | ||
| 926 | + | ||
| 927 | + mapBValue.panTo(stationNameChangePoint,PanOptions); | ||
| 928 | + | ||
| 929 | + mapBValue.panBy(0,-100); | ||
| 930 | + | ||
| 931 | + // 将标注添加到地图中 | ||
| 932 | + mapBValue.addOverlay(marker_stargt2); | ||
| 933 | + | ||
| 934 | + //跳动的动画 | ||
| 935 | + marker_stargt2.setAnimation(BMAP_ANIMATION_BOUNCE); | ||
| 936 | + | ||
| 937 | + } | ||
| 938 | + | ||
| 939 | + }); | ||
| 940 | + | ||
| 941 | + }, | ||
| 942 | + | ||
| 943 | + // 根据地理名称获取百度经纬度坐标 | ||
| 944 | + localSearchFromAdreesToPoint: function(Address,callback) { | ||
| 945 | + | ||
| 946 | + // 创建一个搜索类实例 | ||
| 947 | + var localSearch = new BMap.LocalSearch(mapBValue); | ||
| 948 | + | ||
| 949 | + // 检索完成后的回调函数。 | ||
| 950 | + localSearch.setSearchCompleteCallback(function (searchResult) { | ||
| 951 | + | ||
| 952 | + var resultPoints = ''; | ||
| 953 | + | ||
| 954 | + if(searchResult) { | ||
| 955 | + | ||
| 956 | + // 返回索引指定的结果。索引0表示第1条结果 | ||
| 957 | + var poi = searchResult.getPoi(0); | ||
| 958 | + | ||
| 959 | + if(poi) { | ||
| 960 | + | ||
| 961 | + //获取经度和纬度 | ||
| 962 | + resultPoints = poi.point.lng + ' ' + poi.point.lat; | ||
| 963 | + | ||
| 964 | + callback && callback(resultPoints); | ||
| 965 | + | ||
| 966 | + }else { | ||
| 967 | + | ||
| 968 | + callback && callback(false); | ||
| 969 | + | ||
| 970 | + } | ||
| 971 | + | ||
| 972 | + }else { | ||
| 973 | + | ||
| 974 | + callback && callback(false); | ||
| 975 | + } | ||
| 976 | + | ||
| 977 | + }); | ||
| 978 | + | ||
| 979 | + // 根据检索词发起检索。 | ||
| 980 | + localSearch.search(Address); | ||
| 981 | + | ||
| 982 | + }, | ||
| 983 | + | ||
| 984 | + clearMarkAndOverlays : function() { | ||
| 985 | + | ||
| 986 | + // 清楚地图覆盖物 | ||
| 987 | + mapBValue.clearOverlays(); | ||
| 988 | + | ||
| 989 | + mapBValue.removeOverlay(); | ||
| 990 | + | ||
| 991 | + } | ||
| 992 | + | ||
| 993 | + } | ||
| 994 | + | ||
| 995 | + return Bmap; | ||
| 996 | + | ||
| 997 | }(); | 997 | }(); |
| 998 | \ No newline at end of file | 998 | \ No newline at end of file |
src/main/resources/static/pages/base/roadspeed/js/add-vmap-world.js
| 1 | -var SectionVmapWorlds = function() { | ||
| 2 | - var mapB = '', drawingManager = ''; | ||
| 3 | - var Bmap = { | ||
| 4 | - init : function() { | ||
| 5 | - var CENTER_POINT = {lng : 121.528733,lat : 31.237425};// 设置中心点. | ||
| 6 | - var bdKey = 'IGGrr4UjwIYzatoCRFKEL8sT';// 百度API Key | ||
| 7 | - mapB = new BMap.Map("roadBmap_basic");// 初始化百度地图 | ||
| 8 | - mapB.centerAndZoom(new BMap.Point(CENTER_POINT.lng,CENTER_POINT.lat), 15);//中心点和缩放级别 | ||
| 9 | - mapB.enableDragging(); //启用地图拖拽事件,默认启用(可不写) | ||
| 10 | - mapB.enableScrollWheelZoom(); //启用地图滚轮放大缩小 | ||
| 11 | - mapB.disableDoubleClickZoom();//禁用鼠标双击放大 | ||
| 12 | - mapB.enableKeyboard();//启用键盘上下左右键移动地图 | ||
| 13 | - var styleOptions = { | ||
| 14 | - strokeColor : "blue",//边线颜色。 | ||
| 15 | - fillColor : "blue",//填充颜色。当参数为空时,圆形将没有填充效果。 | ||
| 16 | - strokeWeight : 3,//边线的宽度,以像素为单位。 | ||
| 17 | - strokeOpacity : 0.8,//边线的宽度,以像素为单位。 | ||
| 18 | - fillOpacity : 0.6,//填充的透明度,取值范围0 - 1。 | ||
| 19 | - strokeStyle : 'solid' //边线的样式,solid或dashed。 | ||
| 20 | - }; | ||
| 21 | - // 创建鼠标绘制管理类 | ||
| 22 | - drawingManager = new BMapLib.DrawingManager(mapB, { | ||
| 23 | - isOpen : false,//是否开启绘制模式 | ||
| 24 | - enableDrawingTool : false,//是否显示工具栏 | ||
| 25 | - drawingToolOptions : { | ||
| 26 | - anchor : BMAP_ANCHOR_TOP_RIGHT,//位置 | ||
| 27 | - offset : new BMap.Size(5, 5),//偏离值 | ||
| 28 | - scale : 0.8//工具栏缩放比例 | ||
| 29 | - | ||
| 30 | - }, | ||
| 31 | - polylineOptions : styleOptions//线的样式 | ||
| 32 | - }); | ||
| 33 | - // 添加绘画完成事件 | ||
| 34 | - drawingManager.addEventListener('polylinecomplete', function(e) { | ||
| 35 | - drawingManager.close(); | ||
| 36 | - var editPloyLineArray = e.getPath();// 获取折线坐标集合 | ||
| 37 | - $('#bRoadVectorInput').val(JSON.stringify(editPloyLineArray)); | ||
| 38 | - }); | ||
| 39 | - return mapB; | ||
| 40 | - }, | ||
| 41 | - // 根据地理名称获取百度经纬度坐标进行定位. | ||
| 42 | - localSearchFromAdreesToPoint: function(Address) { | ||
| 43 | - // 创建一个搜索类实例 | ||
| 44 | - var localSearch = new BMap.LocalSearch(mapB); | ||
| 45 | - // 检索完成后的回调函数。 | ||
| 46 | - localSearch.setSearchCompleteCallback(function (searchResult) { | ||
| 47 | - var resultPoints = ''; | ||
| 48 | - if(searchResult) { | ||
| 49 | - // 返回索引指定的结果。索引0表示第1条结果 | ||
| 50 | - var poi = searchResult.getPoi(0); | ||
| 51 | - if(poi) { | ||
| 52 | - //获取经度和纬度 | ||
| 53 | - var stationNameChangePoint = new BMap.Point( poi.point.lng, poi.point.lat); | ||
| 54 | - marker = new BMap.Marker(stationNameChangePoint); | ||
| 55 | - var PanOptions ={noAnimation :true}; | ||
| 56 | - mapB.panTo(stationNameChangePoint,PanOptions); | ||
| 57 | - // 将视图切换到指定的缩放等级,中心点坐标不变。注意:当有信息窗口在地图上打开时,地图缩放将保证信息窗口所在的坐标位置不动。(自1.2新增) | ||
| 58 | - mapB.setZoom(16); | ||
| 59 | - mapB.panBy(-300,-50); | ||
| 60 | - // 将标注添加到地图中 | ||
| 61 | - mapB.addOverlay(marker); | ||
| 62 | - //跳动的动画 | ||
| 63 | - marker.setAnimation(BMAP_ANIMATION_BOUNCE); | ||
| 64 | - }else { | ||
| 65 | - // 弹出添加成功提示消息 | ||
| 66 | - layer.msg('无法获取【'+Address+'】地理位置!'); | ||
| 67 | - } | ||
| 68 | - }else { | ||
| 69 | - // 弹出添加成功提示消息 | ||
| 70 | - layer.msg('无法获取【'+Address+'】地理位置!'); | ||
| 71 | - } | ||
| 72 | - }); | ||
| 73 | - // 根据检索词发起检索。 | ||
| 74 | - localSearch.search(Address); | ||
| 75 | - }, | ||
| 76 | - // 根据名称获取坐标. | ||
| 77 | - stationsNameToPoints : function(arra,callback) { | ||
| 78 | - // 获取长度 | ||
| 79 | - var len = arra.length; | ||
| 80 | - var stationList = []; | ||
| 81 | - (function(){ | ||
| 82 | - if (!arguments.callee.count) { | ||
| 83 | - arguments.callee.count = 0; | ||
| 84 | - } | ||
| 85 | - arguments.callee.count++; | ||
| 86 | - var index = parseInt(arguments.callee.count) - 1; | ||
| 87 | - if (index >= len) { | ||
| 88 | - callback && callback(stationList); | ||
| 89 | - return; | ||
| 90 | - } | ||
| 91 | - var f = arguments.callee; | ||
| 92 | - if(arra[index]!=''){ | ||
| 93 | - var localSearch = new BMap.LocalSearch(mapB); | ||
| 94 | - localSearch.search(arra[index]); | ||
| 95 | - localSearch.setSearchCompleteCallback(function (searchResult) { | ||
| 96 | - var poi = searchResult.getPoi(0); | ||
| 97 | - if(poi) { | ||
| 98 | - stationList.push({name:arra[index],potion:{lng:poi.point.lng,lat:poi.point.lat}}); | ||
| 99 | - f(); | ||
| 100 | - } | ||
| 101 | - }); | ||
| 102 | - }else { | ||
| 103 | - f(); | ||
| 104 | - } | ||
| 105 | - })(); | ||
| 106 | - }, | ||
| 107 | - /** 获取距离与时间 @param <points:坐标点集合> */ | ||
| 108 | - getDistanceAndDuration : function(points,callback){ | ||
| 109 | - // 获取长度 | ||
| 110 | - var len = points.length; | ||
| 111 | - (function(){ | ||
| 112 | - if (!arguments.callee.count) { | ||
| 113 | - arguments.callee.count = 0; | ||
| 114 | - } | ||
| 115 | - arguments.callee.count++; | ||
| 116 | - var index = parseInt(arguments.callee.count) - 1; | ||
| 117 | - if (index >= len-1) { | ||
| 118 | - callback && callback(points); | ||
| 119 | - return; | ||
| 120 | - } | ||
| 121 | - // 当函数被调用时,它的arguments.callee对象就会指向自身,也就是一个对自己的引用。(当前正在执行的函数。) | ||
| 122 | - var f = arguments.callee; | ||
| 123 | - // 起点坐标 <坐标格式:40.056878,116.30815> | ||
| 124 | - var origin = points[index].potion.lat + ',' + points[index].potion.lng; | ||
| 125 | - // 终点坐标 <坐标格式:40.056878,116.30815> | ||
| 126 | - var destination = points[index+1].potion.lat + ',' + points[index+1].potion.lng; | ||
| 127 | - var region = '上海'; | ||
| 128 | - var origin_region = '上海'; | ||
| 129 | - var destination_region = '上海'; | ||
| 130 | - var output = 'json'; | ||
| 131 | - var ak_My = 'wjlITmXeCek5MxyU3ZUBkTeU8B0o0npk'; | ||
| 132 | - /** | ||
| 133 | - * @param :< origin:起点名称或经纬度;destination:终点名称或经纬度;origin_region:起始点所在城市,驾车导航时必填。 | ||
| 134 | - * | ||
| 135 | - * destination_region:终点所在城市,驾车导航时必填。output :表示输出类型,可设置为xml或json,默认为xml。> | ||
| 136 | - * | ||
| 137 | - * @returns :r <jsonp格式> | ||
| 138 | - **/ | ||
| 139 | - var paramsB = {origin:origin,destination:destination,region:region,origin_region:origin_region,destination_region:destination_region,output:output,ak:ak_My}; | ||
| 140 | - /** @description :未认证开发者默认配额为:2000次/天。 */ | ||
| 141 | - $.ajax({ | ||
| 142 | - // 百度地图根据坐标获取两点之间的时间与距离 | ||
| 143 | - url: 'http://api.map.baidu.com/direction/v1?mode=transit', | ||
| 144 | - data: paramsB, | ||
| 145 | - dataType: 'jsonp', | ||
| 146 | - success: function(r){ | ||
| 147 | - if(r) { | ||
| 148 | - if(r.message=='ok') { | ||
| 149 | - // 获取距离(单位:米) | ||
| 150 | - points[index+1].distance = r.result.taxi.distance; | ||
| 151 | - // 获取时间(单位:秒) | ||
| 152 | - points[index+1].duration = r.result.taxi.duration; | ||
| 153 | - } | ||
| 154 | - } | ||
| 155 | - f(); | ||
| 156 | - } | ||
| 157 | - }); | ||
| 158 | - })(); | ||
| 159 | - }, | ||
| 160 | - // 获取路段几何图形坐标集合. | ||
| 161 | - getSectionListPlonly : function(stationsPoint,cb) { | ||
| 162 | - var len = stationsPoint.length; | ||
| 163 | - var sectionList = []; | ||
| 164 | - (function(){ | ||
| 165 | - if (!arguments.callee.count) { | ||
| 166 | - arguments.callee.count = 0; | ||
| 167 | - } | ||
| 168 | - arguments.callee.count++; | ||
| 169 | - var index = parseInt(arguments.callee.count) - 1; | ||
| 170 | - if (index >= len-1 ) { | ||
| 171 | - cb && cb(sectionList); | ||
| 172 | - return; | ||
| 173 | - } | ||
| 174 | - var f = arguments.callee; | ||
| 175 | - var poiOne = new BMap.Point(stationsPoint[index].potion.lng,stationsPoint[index].potion.lat); | ||
| 176 | - var poiTwo = new BMap.Point(stationsPoint[index+1].potion.lng,stationsPoint[index+1].potion.lat); | ||
| 177 | - var transit = new BMap.DrivingRoute(mapB, {renderOptions: {map: mapB,enableDragging : true},onPolylinesSet: searchPolylinesSet}); | ||
| 178 | - function searchPolylinesSet(results){ | ||
| 179 | - if (transit.getStatus() != BMAP_STATUS_SUCCESS){ | ||
| 180 | - }else { | ||
| 181 | - var sectionArrayList = []; | ||
| 182 | - for (i = 0; i < results.length; i++){ | ||
| 183 | - sectionArrayList = sectionArrayList.concat(results[i].getPolyline().getPath()); | ||
| 184 | - } | ||
| 185 | - sectionList = sectionArrayList; | ||
| 186 | - } | ||
| 187 | - f(); | ||
| 188 | - } | ||
| 189 | - transit.search(poiOne,poiTwo); | ||
| 190 | - })(); | ||
| 191 | - }, | ||
| 192 | - // 清楚地图覆盖物 | ||
| 193 | - clearMarkAndOverlays : function() { | ||
| 194 | - mapB.clearOverlays(); | ||
| 195 | - }, | ||
| 196 | - // 关闭绘画工具. | ||
| 197 | - drawingManagerClose : function() { | ||
| 198 | - drawingManager.close(); | ||
| 199 | - }, | ||
| 200 | - // 打开绘画工具. | ||
| 201 | - drawingManagerOpen : function() { | ||
| 202 | - drawingManager.open();// 打开鼠标绘画工具. | ||
| 203 | - drawingManager.setDrawingMode(BMAP_DRAWING_POLYLINE);// 设置属性. | ||
| 204 | - } | ||
| 205 | - } | ||
| 206 | - | ||
| 207 | - return Bmap; | ||
| 208 | - | 1 | +var SectionVmapWorlds = function() { |
| 2 | + var mapB = '', drawingManager = ''; | ||
| 3 | + var Bmap = { | ||
| 4 | + init : function() { | ||
| 5 | + var CENTER_POINT = {lng : 121.528733,lat : 31.237425};// 设置中心点. | ||
| 6 | + var bdKey = 'IGGrr4UjwIYzatoCRFKEL8sT';// 百度API Key | ||
| 7 | + mapB = new BMap.Map("roadBmap_basic");// 初始化百度地图 | ||
| 8 | + mapB.centerAndZoom(new BMap.Point(CENTER_POINT.lng,CENTER_POINT.lat), 15);//中心点和缩放级别 | ||
| 9 | + mapB.enableDragging(); //启用地图拖拽事件,默认启用(可不写) | ||
| 10 | + mapB.enableScrollWheelZoom(); //启用地图滚轮放大缩小 | ||
| 11 | + mapB.disableDoubleClickZoom();//禁用鼠标双击放大 | ||
| 12 | + mapB.enableKeyboard();//启用键盘上下左右键移动地图 | ||
| 13 | + var styleOptions = { | ||
| 14 | + strokeColor : "blue",//边线颜色。 | ||
| 15 | + fillColor : "blue",//填充颜色。当参数为空时,圆形将没有填充效果。 | ||
| 16 | + strokeWeight : 3,//边线的宽度,以像素为单位。 | ||
| 17 | + strokeOpacity : 0.8,//边线的宽度,以像素为单位。 | ||
| 18 | + fillOpacity : 0.6,//填充的透明度,取值范围0 - 1。 | ||
| 19 | + strokeStyle : 'solid' //边线的样式,solid或dashed。 | ||
| 20 | + }; | ||
| 21 | + // 创建鼠标绘制管理类 | ||
| 22 | + drawingManager = new BMapLib.DrawingManager(mapB, { | ||
| 23 | + isOpen : false,//是否开启绘制模式 | ||
| 24 | + enableDrawingTool : false,//是否显示工具栏 | ||
| 25 | + drawingToolOptions : { | ||
| 26 | + anchor : BMAP_ANCHOR_TOP_RIGHT,//位置 | ||
| 27 | + offset : new BMap.Size(5, 5),//偏离值 | ||
| 28 | + scale : 0.8//工具栏缩放比例 | ||
| 29 | + | ||
| 30 | + }, | ||
| 31 | + polylineOptions : styleOptions//线的样式 | ||
| 32 | + }); | ||
| 33 | + // 添加绘画完成事件 | ||
| 34 | + drawingManager.addEventListener('polylinecomplete', function(e) { | ||
| 35 | + drawingManager.close(); | ||
| 36 | + var editPloyLineArray = e.getPath();// 获取折线坐标集合 | ||
| 37 | + $('#bRoadVectorInput').val(JSON.stringify(editPloyLineArray)); | ||
| 38 | + }); | ||
| 39 | + return mapB; | ||
| 40 | + }, | ||
| 41 | + // 根据地理名称获取百度经纬度坐标进行定位. | ||
| 42 | + localSearchFromAdreesToPoint: function(Address) { | ||
| 43 | + // 创建一个搜索类实例 | ||
| 44 | + var localSearch = new BMap.LocalSearch(mapB); | ||
| 45 | + // 检索完成后的回调函数。 | ||
| 46 | + localSearch.setSearchCompleteCallback(function (searchResult) { | ||
| 47 | + var resultPoints = ''; | ||
| 48 | + if(searchResult) { | ||
| 49 | + // 返回索引指定的结果。索引0表示第1条结果 | ||
| 50 | + var poi = searchResult.getPoi(0); | ||
| 51 | + if(poi) { | ||
| 52 | + //获取经度和纬度 | ||
| 53 | + var stationNameChangePoint = new BMap.Point( poi.point.lng, poi.point.lat); | ||
| 54 | + marker = new BMap.Marker(stationNameChangePoint); | ||
| 55 | + var PanOptions ={noAnimation :true}; | ||
| 56 | + mapB.panTo(stationNameChangePoint,PanOptions); | ||
| 57 | + // 将视图切换到指定的缩放等级,中心点坐标不变。注意:当有信息窗口在地图上打开时,地图缩放将保证信息窗口所在的坐标位置不动。(自1.2新增) | ||
| 58 | + mapB.setZoom(16); | ||
| 59 | + mapB.panBy(-300,-50); | ||
| 60 | + // 将标注添加到地图中 | ||
| 61 | + mapB.addOverlay(marker); | ||
| 62 | + //跳动的动画 | ||
| 63 | + marker.setAnimation(BMAP_ANIMATION_BOUNCE); | ||
| 64 | + }else { | ||
| 65 | + // 弹出添加成功提示消息 | ||
| 66 | + layer.msg('无法获取【'+Address+'】地理位置!'); | ||
| 67 | + } | ||
| 68 | + }else { | ||
| 69 | + // 弹出添加成功提示消息 | ||
| 70 | + layer.msg('无法获取【'+Address+'】地理位置!'); | ||
| 71 | + } | ||
| 72 | + }); | ||
| 73 | + // 根据检索词发起检索。 | ||
| 74 | + localSearch.search(Address); | ||
| 75 | + }, | ||
| 76 | + // 根据名称获取坐标. | ||
| 77 | + stationsNameToPoints : function(arra,callback) { | ||
| 78 | + // 获取长度 | ||
| 79 | + var len = arra.length; | ||
| 80 | + var stationList = []; | ||
| 81 | + (function(){ | ||
| 82 | + if (!arguments.callee.count) { | ||
| 83 | + arguments.callee.count = 0; | ||
| 84 | + } | ||
| 85 | + arguments.callee.count++; | ||
| 86 | + var index = parseInt(arguments.callee.count) - 1; | ||
| 87 | + if (index >= len) { | ||
| 88 | + callback && callback(stationList); | ||
| 89 | + return; | ||
| 90 | + } | ||
| 91 | + var f = arguments.callee; | ||
| 92 | + if(arra[index]!=''){ | ||
| 93 | + var localSearch = new BMap.LocalSearch(mapB); | ||
| 94 | + localSearch.search(arra[index]); | ||
| 95 | + localSearch.setSearchCompleteCallback(function (searchResult) { | ||
| 96 | + var poi = searchResult.getPoi(0); | ||
| 97 | + if(poi) { | ||
| 98 | + stationList.push({name:arra[index],potion:{lng:poi.point.lng,lat:poi.point.lat}}); | ||
| 99 | + f(); | ||
| 100 | + } | ||
| 101 | + }); | ||
| 102 | + }else { | ||
| 103 | + f(); | ||
| 104 | + } | ||
| 105 | + })(); | ||
| 106 | + }, | ||
| 107 | + /** 获取距离与时间 @param <points:坐标点集合> */ | ||
| 108 | + getDistanceAndDuration : function(points,callback){ | ||
| 109 | + // 获取长度 | ||
| 110 | + var len = points.length; | ||
| 111 | + (function(){ | ||
| 112 | + if (!arguments.callee.count) { | ||
| 113 | + arguments.callee.count = 0; | ||
| 114 | + } | ||
| 115 | + arguments.callee.count++; | ||
| 116 | + var index = parseInt(arguments.callee.count) - 1; | ||
| 117 | + if (index >= len-1) { | ||
| 118 | + callback && callback(points); | ||
| 119 | + return; | ||
| 120 | + } | ||
| 121 | + // 当函数被调用时,它的arguments.callee对象就会指向自身,也就是一个对自己的引用。(当前正在执行的函数。) | ||
| 122 | + var f = arguments.callee; | ||
| 123 | + // 起点坐标 <坐标格式:40.056878,116.30815> | ||
| 124 | + var origin = points[index].potion.lat + ',' + points[index].potion.lng; | ||
| 125 | + // 终点坐标 <坐标格式:40.056878,116.30815> | ||
| 126 | + var destination = points[index+1].potion.lat + ',' + points[index+1].potion.lng; | ||
| 127 | + var region = '上海'; | ||
| 128 | + var origin_region = '上海'; | ||
| 129 | + var destination_region = '上海'; | ||
| 130 | + var output = 'json'; | ||
| 131 | + var ak_My = 'wjlITmXeCek5MxyU3ZUBkTeU8B0o0npk'; | ||
| 132 | + /** | ||
| 133 | + * @param :< origin:起点名称或经纬度;destination:终点名称或经纬度;origin_region:起始点所在城市,驾车导航时必填。 | ||
| 134 | + * | ||
| 135 | + * destination_region:终点所在城市,驾车导航时必填。output :表示输出类型,可设置为xml或json,默认为xml。> | ||
| 136 | + * | ||
| 137 | + * @returns :r <jsonp格式> | ||
| 138 | + **/ | ||
| 139 | + var paramsB = {origin:origin,destination:destination,region:region,origin_region:origin_region,destination_region:destination_region,output:output,ak:ak_My}; | ||
| 140 | + /** @description :未认证开发者默认配额为:2000次/天。 */ | ||
| 141 | + $.ajax({ | ||
| 142 | + // 百度地图根据坐标获取两点之间的时间与距离 | ||
| 143 | + url: '//api.map.baidu.com/direction/v1?mode=transit', | ||
| 144 | + data: paramsB, | ||
| 145 | + dataType: 'jsonp', | ||
| 146 | + success: function(r){ | ||
| 147 | + if(r) { | ||
| 148 | + if(r.message=='ok') { | ||
| 149 | + // 获取距离(单位:米) | ||
| 150 | + points[index+1].distance = r.result.taxi.distance; | ||
| 151 | + // 获取时间(单位:秒) | ||
| 152 | + points[index+1].duration = r.result.taxi.duration; | ||
| 153 | + } | ||
| 154 | + } | ||
| 155 | + f(); | ||
| 156 | + } | ||
| 157 | + }); | ||
| 158 | + })(); | ||
| 159 | + }, | ||
| 160 | + // 获取路段几何图形坐标集合. | ||
| 161 | + getSectionListPlonly : function(stationsPoint,cb) { | ||
| 162 | + var len = stationsPoint.length; | ||
| 163 | + var sectionList = []; | ||
| 164 | + (function(){ | ||
| 165 | + if (!arguments.callee.count) { | ||
| 166 | + arguments.callee.count = 0; | ||
| 167 | + } | ||
| 168 | + arguments.callee.count++; | ||
| 169 | + var index = parseInt(arguments.callee.count) - 1; | ||
| 170 | + if (index >= len-1 ) { | ||
| 171 | + cb && cb(sectionList); | ||
| 172 | + return; | ||
| 173 | + } | ||
| 174 | + var f = arguments.callee; | ||
| 175 | + var poiOne = new BMap.Point(stationsPoint[index].potion.lng,stationsPoint[index].potion.lat); | ||
| 176 | + var poiTwo = new BMap.Point(stationsPoint[index+1].potion.lng,stationsPoint[index+1].potion.lat); | ||
| 177 | + var transit = new BMap.DrivingRoute(mapB, {renderOptions: {map: mapB,enableDragging : true},onPolylinesSet: searchPolylinesSet}); | ||
| 178 | + function searchPolylinesSet(results){ | ||
| 179 | + if (transit.getStatus() != BMAP_STATUS_SUCCESS){ | ||
| 180 | + }else { | ||
| 181 | + var sectionArrayList = []; | ||
| 182 | + for (i = 0; i < results.length; i++){ | ||
| 183 | + sectionArrayList = sectionArrayList.concat(results[i].getPolyline().getPath()); | ||
| 184 | + } | ||
| 185 | + sectionList = sectionArrayList; | ||
| 186 | + } | ||
| 187 | + f(); | ||
| 188 | + } | ||
| 189 | + transit.search(poiOne,poiTwo); | ||
| 190 | + })(); | ||
| 191 | + }, | ||
| 192 | + // 清楚地图覆盖物 | ||
| 193 | + clearMarkAndOverlays : function() { | ||
| 194 | + mapB.clearOverlays(); | ||
| 195 | + }, | ||
| 196 | + // 关闭绘画工具. | ||
| 197 | + drawingManagerClose : function() { | ||
| 198 | + drawingManager.close(); | ||
| 199 | + }, | ||
| 200 | + // 打开绘画工具. | ||
| 201 | + drawingManagerOpen : function() { | ||
| 202 | + drawingManager.open();// 打开鼠标绘画工具. | ||
| 203 | + drawingManager.setDrawingMode(BMAP_DRAWING_POLYLINE);// 设置属性. | ||
| 204 | + } | ||
| 205 | + } | ||
| 206 | + | ||
| 207 | + return Bmap; | ||
| 208 | + | ||
| 209 | }(); | 209 | }(); |
| 210 | \ No newline at end of file | 210 | \ No newline at end of file |
src/main/resources/static/pages/base/section/js/add-vmap-world.js
| 1 | -var SectionVmapWorlds = function() { | ||
| 2 | - var mapB = '', drawingManager = ''; | ||
| 3 | - var Bmap = { | ||
| 4 | - init : function() { | ||
| 5 | - var CENTER_POINT = {lng : 121.528733,lat : 31.237425};// 设置中心点. | ||
| 6 | - var bdKey = 'IGGrr4UjwIYzatoCRFKEL8sT';// 百度API Key | ||
| 7 | - mapB = new BMap.Map("sectionBmap_basic");// 初始化百度地图 | ||
| 8 | - mapB.centerAndZoom(new BMap.Point(CENTER_POINT.lng,CENTER_POINT.lat), 15);//中心点和缩放级别 | ||
| 9 | - mapB.enableDragging(); //启用地图拖拽事件,默认启用(可不写) | ||
| 10 | - mapB.enableScrollWheelZoom(); //启用地图滚轮放大缩小 | ||
| 11 | - mapB.disableDoubleClickZoom();//禁用鼠标双击放大 | ||
| 12 | - mapB.enableKeyboard();//启用键盘上下左右键移动地图 | ||
| 13 | - var styleOptions = { | ||
| 14 | - strokeColor : "blue",//边线颜色。 | ||
| 15 | - fillColor : "blue",//填充颜色。当参数为空时,圆形将没有填充效果。 | ||
| 16 | - strokeWeight : 3,//边线的宽度,以像素为单位。 | ||
| 17 | - strokeOpacity : 0.8,//边线的宽度,以像素为单位。 | ||
| 18 | - fillOpacity : 0.6,//填充的透明度,取值范围0 - 1。 | ||
| 19 | - strokeStyle : 'solid' //边线的样式,solid或dashed。 | ||
| 20 | - }; | ||
| 21 | - // 创建鼠标绘制管理类 | ||
| 22 | - drawingManager = new BMapLib.DrawingManager(mapB, { | ||
| 23 | - isOpen : false,//是否开启绘制模式 | ||
| 24 | - enableDrawingTool : false,//是否显示工具栏 | ||
| 25 | - drawingToolOptions : { | ||
| 26 | - anchor : BMAP_ANCHOR_TOP_RIGHT,//位置 | ||
| 27 | - offset : new BMap.Size(5, 5),//偏离值 | ||
| 28 | - scale : 0.8//工具栏缩放比例 | ||
| 29 | - | ||
| 30 | - }, | ||
| 31 | - polylineOptions : styleOptions//线的样式 | ||
| 32 | - }); | ||
| 33 | - // 添加绘画完成事件 | ||
| 34 | - drawingManager.addEventListener('polylinecomplete', function(e) { | ||
| 35 | - drawingManager.close(); | ||
| 36 | - var editPloyLineArray = e.getPath();// 获取折线坐标集合 | ||
| 37 | - $('#bsectionVectorInput').val(JSON.stringify(editPloyLineArray)); | ||
| 38 | - }); | ||
| 39 | - return mapB; | ||
| 40 | - }, | ||
| 41 | - // 根据地理名称获取百度经纬度坐标进行定位. | ||
| 42 | - localSearchFromAdreesToPoint: function(Address) { | ||
| 43 | - // 创建一个搜索类实例 | ||
| 44 | - var localSearch = new BMap.LocalSearch(mapB); | ||
| 45 | - // 检索完成后的回调函数。 | ||
| 46 | - localSearch.setSearchCompleteCallback(function (searchResult) { | ||
| 47 | - var resultPoints = ''; | ||
| 48 | - if(searchResult) { | ||
| 49 | - // 返回索引指定的结果。索引0表示第1条结果 | ||
| 50 | - var poi = searchResult.getPoi(0); | ||
| 51 | - if(poi) { | ||
| 52 | - //获取经度和纬度 | ||
| 53 | - var stationNameChangePoint = new BMap.Point( poi.point.lng, poi.point.lat); | ||
| 54 | - marker = new BMap.Marker(stationNameChangePoint); | ||
| 55 | - var PanOptions ={noAnimation :true}; | ||
| 56 | - mapB.panTo(stationNameChangePoint,PanOptions); | ||
| 57 | - // 将视图切换到指定的缩放等级,中心点坐标不变。注意:当有信息窗口在地图上打开时,地图缩放将保证信息窗口所在的坐标位置不动。(自1.2新增) | ||
| 58 | - mapB.setZoom(16); | ||
| 59 | - mapB.panBy(-300,-50); | ||
| 60 | - // 将标注添加到地图中 | ||
| 61 | - mapB.addOverlay(marker); | ||
| 62 | - //跳动的动画 | ||
| 63 | - marker.setAnimation(BMAP_ANIMATION_BOUNCE); | ||
| 64 | - }else { | ||
| 65 | - // 弹出添加成功提示消息 | ||
| 66 | - layer.msg('无法获取【'+Address+'】地理位置!'); | ||
| 67 | - } | ||
| 68 | - }else { | ||
| 69 | - // 弹出添加成功提示消息 | ||
| 70 | - layer.msg('无法获取【'+Address+'】地理位置!'); | ||
| 71 | - } | ||
| 72 | - }); | ||
| 73 | - // 根据检索词发起检索。 | ||
| 74 | - localSearch.search(Address); | ||
| 75 | - }, | ||
| 76 | - // 根据名称获取坐标. | ||
| 77 | - stationsNameToPoints : function(arra,callback) { | ||
| 78 | - // 获取长度 | ||
| 79 | - var len = arra.length; | ||
| 80 | - var stationList = []; | ||
| 81 | - (function(){ | ||
| 82 | - if (!arguments.callee.count) { | ||
| 83 | - arguments.callee.count = 0; | ||
| 84 | - } | ||
| 85 | - arguments.callee.count++; | ||
| 86 | - var index = parseInt(arguments.callee.count) - 1; | ||
| 87 | - if (index >= len) { | ||
| 88 | - callback && callback(stationList); | ||
| 89 | - return; | ||
| 90 | - } | ||
| 91 | - var f = arguments.callee; | ||
| 92 | - if(arra[index]!=''){ | ||
| 93 | - var localSearch = new BMap.LocalSearch(mapB); | ||
| 94 | - localSearch.search(arra[index]); | ||
| 95 | - localSearch.setSearchCompleteCallback(function (searchResult) { | ||
| 96 | - var poi = searchResult.getPoi(0); | ||
| 97 | - if(poi) { | ||
| 98 | - stationList.push({name:arra[index],potion:{lng:poi.point.lng,lat:poi.point.lat}}); | ||
| 99 | - f(); | ||
| 100 | - } | ||
| 101 | - }); | ||
| 102 | - }else { | ||
| 103 | - f(); | ||
| 104 | - } | ||
| 105 | - })(); | ||
| 106 | - }, | ||
| 107 | - /** 获取距离与时间 @param <points:坐标点集合> */ | ||
| 108 | - getDistanceAndDuration : function(points,callback){ | ||
| 109 | - // 获取长度 | ||
| 110 | - var len = points.length; | ||
| 111 | - (function(){ | ||
| 112 | - if (!arguments.callee.count) { | ||
| 113 | - arguments.callee.count = 0; | ||
| 114 | - } | ||
| 115 | - arguments.callee.count++; | ||
| 116 | - var index = parseInt(arguments.callee.count) - 1; | ||
| 117 | - if (index >= len-1) { | ||
| 118 | - callback && callback(points); | ||
| 119 | - return; | ||
| 120 | - } | ||
| 121 | - // 当函数被调用时,它的arguments.callee对象就会指向自身,也就是一个对自己的引用。(当前正在执行的函数。) | ||
| 122 | - var f = arguments.callee; | ||
| 123 | - // 起点坐标 <坐标格式:40.056878,116.30815> | ||
| 124 | - var origin = points[index].potion.lat + ',' + points[index].potion.lng; | ||
| 125 | - // 终点坐标 <坐标格式:40.056878,116.30815> | ||
| 126 | - var destination = points[index+1].potion.lat + ',' + points[index+1].potion.lng; | ||
| 127 | - var region = '上海'; | ||
| 128 | - var origin_region = '上海'; | ||
| 129 | - var destination_region = '上海'; | ||
| 130 | - var output = 'json'; | ||
| 131 | - var ak_My = 'wjlITmXeCek5MxyU3ZUBkTeU8B0o0npk'; | ||
| 132 | - /** | ||
| 133 | - * @param :< origin:起点名称或经纬度;destination:终点名称或经纬度;origin_region:起始点所在城市,驾车导航时必填。 | ||
| 134 | - * | ||
| 135 | - * destination_region:终点所在城市,驾车导航时必填。output :表示输出类型,可设置为xml或json,默认为xml。> | ||
| 136 | - * | ||
| 137 | - * @returns :r <jsonp格式> | ||
| 138 | - **/ | ||
| 139 | - var paramsB = {origin:origin,destination:destination,region:region,origin_region:origin_region,destination_region:destination_region,output:output,ak:ak_My}; | ||
| 140 | - /** @description :未认证开发者默认配额为:2000次/天。 */ | ||
| 141 | - $.ajax({ | ||
| 142 | - // 百度地图根据坐标获取两点之间的时间与距离 | ||
| 143 | - url: 'http://api.map.baidu.com/direction/v1?mode=transit', | ||
| 144 | - data: paramsB, | ||
| 145 | - dataType: 'jsonp', | ||
| 146 | - success: function(r){ | ||
| 147 | - if(r) { | ||
| 148 | - if(r.message=='ok') { | ||
| 149 | - // 获取距离(单位:米) | ||
| 150 | - points[index+1].distance = r.result.taxi.distance; | ||
| 151 | - // 获取时间(单位:秒) | ||
| 152 | - points[index+1].duration = r.result.taxi.duration; | ||
| 153 | - } | ||
| 154 | - } | ||
| 155 | - f(); | ||
| 156 | - } | ||
| 157 | - }); | ||
| 158 | - })(); | ||
| 159 | - }, | ||
| 160 | - // 获取路段几何图形坐标集合. | ||
| 161 | - getSectionListPlonly : function(stationsPoint,cb) { | ||
| 162 | - var len = stationsPoint.length; | ||
| 163 | - var sectionList = []; | ||
| 164 | - (function(){ | ||
| 165 | - if (!arguments.callee.count) { | ||
| 166 | - arguments.callee.count = 0; | ||
| 167 | - } | ||
| 168 | - arguments.callee.count++; | ||
| 169 | - var index = parseInt(arguments.callee.count) - 1; | ||
| 170 | - if (index >= len-1 ) { | ||
| 171 | - cb && cb(sectionList); | ||
| 172 | - return; | ||
| 173 | - } | ||
| 174 | - var f = arguments.callee; | ||
| 175 | - var poiOne = new BMap.Point(stationsPoint[index].potion.lng,stationsPoint[index].potion.lat); | ||
| 176 | - var poiTwo = new BMap.Point(stationsPoint[index+1].potion.lng,stationsPoint[index+1].potion.lat); | ||
| 177 | - var transit = new BMap.DrivingRoute(mapB, {renderOptions: {map: mapB,enableDragging : true},onPolylinesSet: searchPolylinesSet}); | ||
| 178 | - function searchPolylinesSet(results){ | ||
| 179 | - if (transit.getStatus() != BMAP_STATUS_SUCCESS){ | ||
| 180 | - }else { | ||
| 181 | - var sectionArrayList = []; | ||
| 182 | - for (i = 0; i < results.length; i++){ | ||
| 183 | - sectionArrayList = sectionArrayList.concat(results[i].getPolyline().getPath()); | ||
| 184 | - } | ||
| 185 | - sectionList = sectionArrayList; | ||
| 186 | - } | ||
| 187 | - f(); | ||
| 188 | - } | ||
| 189 | - transit.search(poiOne,poiTwo); | ||
| 190 | - })(); | ||
| 191 | - }, | ||
| 192 | - // 清楚地图覆盖物 | ||
| 193 | - clearMarkAndOverlays : function() { | ||
| 194 | - mapB.clearOverlays(); | ||
| 195 | - }, | ||
| 196 | - // 关闭绘画工具. | ||
| 197 | - drawingManagerClose : function() { | ||
| 198 | - drawingManager.close(); | ||
| 199 | - }, | ||
| 200 | - // 打开绘画工具. | ||
| 201 | - drawingManagerOpen : function() { | ||
| 202 | - drawingManager.open();// 打开鼠标绘画工具. | ||
| 203 | - drawingManager.setDrawingMode(BMAP_DRAWING_POLYLINE);// 设置属性. | ||
| 204 | - } | ||
| 205 | - } | ||
| 206 | - | ||
| 207 | - return Bmap; | ||
| 208 | - | 1 | +var SectionVmapWorlds = function() { |
| 2 | + var mapB = '', drawingManager = ''; | ||
| 3 | + var Bmap = { | ||
| 4 | + init : function() { | ||
| 5 | + var CENTER_POINT = {lng : 121.528733,lat : 31.237425};// 设置中心点. | ||
| 6 | + var bdKey = 'IGGrr4UjwIYzatoCRFKEL8sT';// 百度API Key | ||
| 7 | + mapB = new BMap.Map("sectionBmap_basic");// 初始化百度地图 | ||
| 8 | + mapB.centerAndZoom(new BMap.Point(CENTER_POINT.lng,CENTER_POINT.lat), 15);//中心点和缩放级别 | ||
| 9 | + mapB.enableDragging(); //启用地图拖拽事件,默认启用(可不写) | ||
| 10 | + mapB.enableScrollWheelZoom(); //启用地图滚轮放大缩小 | ||
| 11 | + mapB.disableDoubleClickZoom();//禁用鼠标双击放大 | ||
| 12 | + mapB.enableKeyboard();//启用键盘上下左右键移动地图 | ||
| 13 | + var styleOptions = { | ||
| 14 | + strokeColor : "blue",//边线颜色。 | ||
| 15 | + fillColor : "blue",//填充颜色。当参数为空时,圆形将没有填充效果。 | ||
| 16 | + strokeWeight : 3,//边线的宽度,以像素为单位。 | ||
| 17 | + strokeOpacity : 0.8,//边线的宽度,以像素为单位。 | ||
| 18 | + fillOpacity : 0.6,//填充的透明度,取值范围0 - 1。 | ||
| 19 | + strokeStyle : 'solid' //边线的样式,solid或dashed。 | ||
| 20 | + }; | ||
| 21 | + // 创建鼠标绘制管理类 | ||
| 22 | + drawingManager = new BMapLib.DrawingManager(mapB, { | ||
| 23 | + isOpen : false,//是否开启绘制模式 | ||
| 24 | + enableDrawingTool : false,//是否显示工具栏 | ||
| 25 | + drawingToolOptions : { | ||
| 26 | + anchor : BMAP_ANCHOR_TOP_RIGHT,//位置 | ||
| 27 | + offset : new BMap.Size(5, 5),//偏离值 | ||
| 28 | + scale : 0.8//工具栏缩放比例 | ||
| 29 | + | ||
| 30 | + }, | ||
| 31 | + polylineOptions : styleOptions//线的样式 | ||
| 32 | + }); | ||
| 33 | + // 添加绘画完成事件 | ||
| 34 | + drawingManager.addEventListener('polylinecomplete', function(e) { | ||
| 35 | + drawingManager.close(); | ||
| 36 | + var editPloyLineArray = e.getPath();// 获取折线坐标集合 | ||
| 37 | + $('#bsectionVectorInput').val(JSON.stringify(editPloyLineArray)); | ||
| 38 | + }); | ||
| 39 | + return mapB; | ||
| 40 | + }, | ||
| 41 | + // 根据地理名称获取百度经纬度坐标进行定位. | ||
| 42 | + localSearchFromAdreesToPoint: function(Address) { | ||
| 43 | + // 创建一个搜索类实例 | ||
| 44 | + var localSearch = new BMap.LocalSearch(mapB); | ||
| 45 | + // 检索完成后的回调函数。 | ||
| 46 | + localSearch.setSearchCompleteCallback(function (searchResult) { | ||
| 47 | + var resultPoints = ''; | ||
| 48 | + if(searchResult) { | ||
| 49 | + // 返回索引指定的结果。索引0表示第1条结果 | ||
| 50 | + var poi = searchResult.getPoi(0); | ||
| 51 | + if(poi) { | ||
| 52 | + //获取经度和纬度 | ||
| 53 | + var stationNameChangePoint = new BMap.Point( poi.point.lng, poi.point.lat); | ||
| 54 | + marker = new BMap.Marker(stationNameChangePoint); | ||
| 55 | + var PanOptions ={noAnimation :true}; | ||
| 56 | + mapB.panTo(stationNameChangePoint,PanOptions); | ||
| 57 | + // 将视图切换到指定的缩放等级,中心点坐标不变。注意:当有信息窗口在地图上打开时,地图缩放将保证信息窗口所在的坐标位置不动。(自1.2新增) | ||
| 58 | + mapB.setZoom(16); | ||
| 59 | + mapB.panBy(-300,-50); | ||
| 60 | + // 将标注添加到地图中 | ||
| 61 | + mapB.addOverlay(marker); | ||
| 62 | + //跳动的动画 | ||
| 63 | + marker.setAnimation(BMAP_ANIMATION_BOUNCE); | ||
| 64 | + }else { | ||
| 65 | + // 弹出添加成功提示消息 | ||
| 66 | + layer.msg('无法获取【'+Address+'】地理位置!'); | ||
| 67 | + } | ||
| 68 | + }else { | ||
| 69 | + // 弹出添加成功提示消息 | ||
| 70 | + layer.msg('无法获取【'+Address+'】地理位置!'); | ||
| 71 | + } | ||
| 72 | + }); | ||
| 73 | + // 根据检索词发起检索。 | ||
| 74 | + localSearch.search(Address); | ||
| 75 | + }, | ||
| 76 | + // 根据名称获取坐标. | ||
| 77 | + stationsNameToPoints : function(arra,callback) { | ||
| 78 | + // 获取长度 | ||
| 79 | + var len = arra.length; | ||
| 80 | + var stationList = []; | ||
| 81 | + (function(){ | ||
| 82 | + if (!arguments.callee.count) { | ||
| 83 | + arguments.callee.count = 0; | ||
| 84 | + } | ||
| 85 | + arguments.callee.count++; | ||
| 86 | + var index = parseInt(arguments.callee.count) - 1; | ||
| 87 | + if (index >= len) { | ||
| 88 | + callback && callback(stationList); | ||
| 89 | + return; | ||
| 90 | + } | ||
| 91 | + var f = arguments.callee; | ||
| 92 | + if(arra[index]!=''){ | ||
| 93 | + var localSearch = new BMap.LocalSearch(mapB); | ||
| 94 | + localSearch.search(arra[index]); | ||
| 95 | + localSearch.setSearchCompleteCallback(function (searchResult) { | ||
| 96 | + var poi = searchResult.getPoi(0); | ||
| 97 | + if(poi) { | ||
| 98 | + stationList.push({name:arra[index],potion:{lng:poi.point.lng,lat:poi.point.lat}}); | ||
| 99 | + f(); | ||
| 100 | + } | ||
| 101 | + }); | ||
| 102 | + }else { | ||
| 103 | + f(); | ||
| 104 | + } | ||
| 105 | + })(); | ||
| 106 | + }, | ||
| 107 | + /** 获取距离与时间 @param <points:坐标点集合> */ | ||
| 108 | + getDistanceAndDuration : function(points,callback){ | ||
| 109 | + // 获取长度 | ||
| 110 | + var len = points.length; | ||
| 111 | + (function(){ | ||
| 112 | + if (!arguments.callee.count) { | ||
| 113 | + arguments.callee.count = 0; | ||
| 114 | + } | ||
| 115 | + arguments.callee.count++; | ||
| 116 | + var index = parseInt(arguments.callee.count) - 1; | ||
| 117 | + if (index >= len-1) { | ||
| 118 | + callback && callback(points); | ||
| 119 | + return; | ||
| 120 | + } | ||
| 121 | + // 当函数被调用时,它的arguments.callee对象就会指向自身,也就是一个对自己的引用。(当前正在执行的函数。) | ||
| 122 | + var f = arguments.callee; | ||
| 123 | + // 起点坐标 <坐标格式:40.056878,116.30815> | ||
| 124 | + var origin = points[index].potion.lat + ',' + points[index].potion.lng; | ||
| 125 | + // 终点坐标 <坐标格式:40.056878,116.30815> | ||
| 126 | + var destination = points[index+1].potion.lat + ',' + points[index+1].potion.lng; | ||
| 127 | + var region = '上海'; | ||
| 128 | + var origin_region = '上海'; | ||
| 129 | + var destination_region = '上海'; | ||
| 130 | + var output = 'json'; | ||
| 131 | + var ak_My = 'wjlITmXeCek5MxyU3ZUBkTeU8B0o0npk'; | ||
| 132 | + /** | ||
| 133 | + * @param :< origin:起点名称或经纬度;destination:终点名称或经纬度;origin_region:起始点所在城市,驾车导航时必填。 | ||
| 134 | + * | ||
| 135 | + * destination_region:终点所在城市,驾车导航时必填。output :表示输出类型,可设置为xml或json,默认为xml。> | ||
| 136 | + * | ||
| 137 | + * @returns :r <jsonp格式> | ||
| 138 | + **/ | ||
| 139 | + var paramsB = {origin:origin,destination:destination,region:region,origin_region:origin_region,destination_region:destination_region,output:output,ak:ak_My}; | ||
| 140 | + /** @description :未认证开发者默认配额为:2000次/天。 */ | ||
| 141 | + $.ajax({ | ||
| 142 | + // 百度地图根据坐标获取两点之间的时间与距离 | ||
| 143 | + url: '//api.map.baidu.com/direction/v1?mode=transit', | ||
| 144 | + data: paramsB, | ||
| 145 | + dataType: 'jsonp', | ||
| 146 | + success: function(r){ | ||
| 147 | + if(r) { | ||
| 148 | + if(r.message=='ok') { | ||
| 149 | + // 获取距离(单位:米) | ||
| 150 | + points[index+1].distance = r.result.taxi.distance; | ||
| 151 | + // 获取时间(单位:秒) | ||
| 152 | + points[index+1].duration = r.result.taxi.duration; | ||
| 153 | + } | ||
| 154 | + } | ||
| 155 | + f(); | ||
| 156 | + } | ||
| 157 | + }); | ||
| 158 | + })(); | ||
| 159 | + }, | ||
| 160 | + // 获取路段几何图形坐标集合. | ||
| 161 | + getSectionListPlonly : function(stationsPoint,cb) { | ||
| 162 | + var len = stationsPoint.length; | ||
| 163 | + var sectionList = []; | ||
| 164 | + (function(){ | ||
| 165 | + if (!arguments.callee.count) { | ||
| 166 | + arguments.callee.count = 0; | ||
| 167 | + } | ||
| 168 | + arguments.callee.count++; | ||
| 169 | + var index = parseInt(arguments.callee.count) - 1; | ||
| 170 | + if (index >= len-1 ) { | ||
| 171 | + cb && cb(sectionList); | ||
| 172 | + return; | ||
| 173 | + } | ||
| 174 | + var f = arguments.callee; | ||
| 175 | + var poiOne = new BMap.Point(stationsPoint[index].potion.lng,stationsPoint[index].potion.lat); | ||
| 176 | + var poiTwo = new BMap.Point(stationsPoint[index+1].potion.lng,stationsPoint[index+1].potion.lat); | ||
| 177 | + var transit = new BMap.DrivingRoute(mapB, {renderOptions: {map: mapB,enableDragging : true},onPolylinesSet: searchPolylinesSet}); | ||
| 178 | + function searchPolylinesSet(results){ | ||
| 179 | + if (transit.getStatus() != BMAP_STATUS_SUCCESS){ | ||
| 180 | + }else { | ||
| 181 | + var sectionArrayList = []; | ||
| 182 | + for (i = 0; i < results.length; i++){ | ||
| 183 | + sectionArrayList = sectionArrayList.concat(results[i].getPolyline().getPath()); | ||
| 184 | + } | ||
| 185 | + sectionList = sectionArrayList; | ||
| 186 | + } | ||
| 187 | + f(); | ||
| 188 | + } | ||
| 189 | + transit.search(poiOne,poiTwo); | ||
| 190 | + })(); | ||
| 191 | + }, | ||
| 192 | + // 清楚地图覆盖物 | ||
| 193 | + clearMarkAndOverlays : function() { | ||
| 194 | + mapB.clearOverlays(); | ||
| 195 | + }, | ||
| 196 | + // 关闭绘画工具. | ||
| 197 | + drawingManagerClose : function() { | ||
| 198 | + drawingManager.close(); | ||
| 199 | + }, | ||
| 200 | + // 打开绘画工具. | ||
| 201 | + drawingManagerOpen : function() { | ||
| 202 | + drawingManager.open();// 打开鼠标绘画工具. | ||
| 203 | + drawingManager.setDrawingMode(BMAP_DRAWING_POLYLINE);// 设置属性. | ||
| 204 | + } | ||
| 205 | + } | ||
| 206 | + | ||
| 207 | + return Bmap; | ||
| 208 | + | ||
| 209 | }(); | 209 | }(); |
| 210 | \ No newline at end of file | 210 | \ No newline at end of file |
src/main/resources/static/pages/base/stationroute/js/stationroute-list-map.js
| @@ -192,7 +192,7 @@ window.WorldsBMap = function () { | @@ -192,7 +192,7 @@ window.WorldsBMap = function () { | ||
| 192 | /** @description :未认证开发者默认配额为:2000次/天。 */ | 192 | /** @description :未认证开发者默认配额为:2000次/天。 */ |
| 193 | $.ajax({ | 193 | $.ajax({ |
| 194 | // 百度地图根据坐标获取两点之间的时间与距离 | 194 | // 百度地图根据坐标获取两点之间的时间与距离 |
| 195 | - url: 'http://api.map.baidu.com/direction/v1?mode=transit', | 195 | + url: '//api.map.baidu.com/direction/v1?mode=transit', |
| 196 | data: paramsB, | 196 | data: paramsB, |
| 197 | dataType: 'jsonp', | 197 | dataType: 'jsonp', |
| 198 | success: function (r) { | 198 | success: function (r) { |
| @@ -1447,7 +1447,7 @@ window.WorldsBMap = function () { | @@ -1447,7 +1447,7 @@ window.WorldsBMap = function () { | ||
| 1447 | $.ajax({ | 1447 | $.ajax({ |
| 1448 | 1448 | ||
| 1449 | // 百度地图根据坐标获取两点之间的时间与距离 | 1449 | // 百度地图根据坐标获取两点之间的时间与距离 |
| 1450 | - url: 'http://api.map.baidu.com/direction/v1?mode=transit', | 1450 | + url: '//api.map.baidu.com/direction/v1?mode=transit', |
| 1451 | 1451 | ||
| 1452 | data: paramsB, | 1452 | data: paramsB, |
| 1453 | 1453 | ||
| @@ -1547,7 +1547,6 @@ window.WorldsBMap = function () { | @@ -1547,7 +1547,6 @@ window.WorldsBMap = function () { | ||
| 1547 | }, | 1547 | }, |
| 1548 | 1548 | ||
| 1549 | drawPolyLine: function (points, data, start, end) { | 1549 | drawPolyLine: function (points, data, start, end) { |
| 1550 | - debugger | ||
| 1551 | let bdPoints = new Array(), i = 0, point, polyline; | 1550 | let bdPoints = new Array(), i = 0, point, polyline; |
| 1552 | for (i = 0;i < points.length;i++) { | 1551 | for (i = 0;i < points.length;i++) { |
| 1553 | point = points[i].split(' '); | 1552 | point = points[i].split(' '); |
src/main/resources/static/pages/excep/js/map.js
| 1 | -/** | ||
| 2 | - * 百度地图 | ||
| 3 | - * | ||
| 4 | - * - - - - - -》init:地图初始化 | ||
| 5 | - * | ||
| 6 | - * - - - - - -》getDistanceAndDuration:获取距离与时间 | ||
| 7 | - * | ||
| 8 | - * - - - - - -》drawingUpline:在地图上画出上行线路走向 | ||
| 9 | - * | ||
| 10 | - * - - - - - -》stationsPointsToLibraryPoint:根据站点坐标匹配库中的公交站点(手动规划) | ||
| 11 | - */ | ||
| 12 | - | ||
| 13 | -var BasicMap = function () { | ||
| 14 | - | ||
| 15 | - /** BasicMap 全局变量定义 mapBValue:地图对象;polyUpline:走向折线;sectionList:截取过的路段 ;pointIndex:计算路段被切的次数; | ||
| 16 | - * firstPoint:截取路段的第一个点;iseditStatus:路段是否在编辑状态;isCutSection : 获取路段是否在截取状态*/ | ||
| 17 | - var mapBValue = '', polyUpline='', sectionList = [], pointIndex = 0, iseditStatus = false, firstPoint = {}, isCutSection = false; | ||
| 18 | - | ||
| 19 | - var Bmap = { | ||
| 20 | - | ||
| 21 | - init : function() { | ||
| 22 | - | ||
| 23 | - // 设置中心点, | ||
| 24 | - var CENTER_POINT = {lng : 121.528733,lat : 31.237425}; | ||
| 25 | - | ||
| 26 | - // 百度API Key | ||
| 27 | - var bdKey = 'IGGrr4UjwIYzatoCRFKEL8sT'; | ||
| 28 | - | ||
| 29 | - // 初始化百度地图 | ||
| 30 | - mapBValue = new BMap.Map("BasicMap"); | ||
| 31 | - | ||
| 32 | - //中心点和缩放级别 | ||
| 33 | - mapBValue.centerAndZoom(new BMap.Point(CENTER_POINT.lng,CENTER_POINT.lat),15); | ||
| 34 | - | ||
| 35 | - //启用地图拖拽事件,默认启用(可不写) | ||
| 36 | - mapBValue.enableDragging(); | ||
| 37 | - | ||
| 38 | - //启用地图滚轮放大缩小 | ||
| 39 | - mapBValue.enableScrollWheelZoom(); | ||
| 40 | - | ||
| 41 | - //禁用鼠标双击放大 | ||
| 42 | - mapBValue.disableDoubleClickZoom(); | ||
| 43 | - | ||
| 44 | - //启用键盘上下左右键移动地图 | ||
| 45 | - mapBValue.enableKeyboard(); | ||
| 46 | - | ||
| 47 | - return mapBValue; | ||
| 48 | - }, | ||
| 49 | - /** 获取第一个切路段的点 @return Point*/ | ||
| 50 | - getFirstPoint : function() { | ||
| 51 | - return firstPoint; | ||
| 52 | - }, | ||
| 53 | - /** 获取地图对象 @return 地图对象map */ | ||
| 54 | - getmapBValue : function() { | ||
| 55 | - | ||
| 56 | - return mapBValue; | ||
| 57 | - | ||
| 58 | - }, | ||
| 59 | - | ||
| 60 | - getPolyUpline : function() { | ||
| 61 | - | ||
| 62 | - return polyUpline; | ||
| 63 | - }, | ||
| 64 | - | ||
| 65 | - /** 获取截取过的路段 @return 路段对象List */ | ||
| 66 | - getSectionList : function() { | ||
| 67 | - | ||
| 68 | - return sectionList; | ||
| 69 | - | ||
| 70 | - }, | ||
| 71 | - setSectionList : function(list) { | ||
| 72 | - | ||
| 73 | - sectionList = list; | ||
| 74 | - }, | ||
| 75 | - initCutSectionPoint : function() { | ||
| 76 | - sectionList = []; | ||
| 77 | - var tbodyHtml = template('section_list',{list : sectionList}); | ||
| 78 | - $('#section_table tbody').html(tbodyHtml); | ||
| 79 | - }, | ||
| 80 | - /** 获取切路段的点下标 @return int*/ | ||
| 81 | - setPointIndex : function(index) { | ||
| 82 | - pointIndex = index; | ||
| 83 | - }, | ||
| 84 | - getPointIndex : function() { | ||
| 85 | - | ||
| 86 | - return pointIndex; | ||
| 87 | - | ||
| 88 | - }, | ||
| 89 | - /** 获取路段是否在编辑状态 @return boolean*/ | ||
| 90 | - getIsEditStatus : function() { | ||
| 91 | - return iseditStatus; | ||
| 92 | - }, | ||
| 93 | - setIsEditStatus : function(v) { | ||
| 94 | - iseditStatus = v ; | ||
| 95 | - }, | ||
| 96 | - | ||
| 97 | - /** 获取路段是否在截取状态 @return boolean*/ | ||
| 98 | - getIsCutSection : function() { | ||
| 99 | - return isCutSection; | ||
| 100 | - }, | ||
| 101 | - setIsCutSection : function(v) { | ||
| 102 | - isCutSection = v ; | ||
| 103 | - }, | ||
| 104 | - | ||
| 105 | - /** 获取距离与时间 @param <points:坐标点集合> */ | ||
| 106 | - getDistanceAndDuration : function(points,callback){ | ||
| 107 | - | ||
| 108 | - // 获取长度 | ||
| 109 | - var len = points.length; | ||
| 110 | - (function(){ | ||
| 111 | - | ||
| 112 | - if (!arguments.callee.count) { | ||
| 113 | - | ||
| 114 | - arguments.callee.count = 0; | ||
| 115 | - | ||
| 116 | - } | ||
| 117 | - | ||
| 118 | - arguments.callee.count++; | ||
| 119 | - | ||
| 120 | - var index = parseInt(arguments.callee.count) - 1; | ||
| 121 | - | ||
| 122 | - if (index >= len-1) { | ||
| 123 | - | ||
| 124 | - callback && callback(points); | ||
| 125 | - | ||
| 126 | - return; | ||
| 127 | - } | ||
| 128 | - | ||
| 129 | - // 当函数被调用时,它的arguments.callee对象就会指向自身,也就是一个对自己的引用。(当前正在执行的函数。) | ||
| 130 | - var f = arguments.callee; | ||
| 131 | - // 起点坐标 <坐标格式:40.056878,116.30815> | ||
| 132 | - var origin = points[index].potion.lat + ',' + points[index].potion.lng; | ||
| 133 | - | ||
| 134 | - // 终点坐标 <坐标格式:40.056878,116.30815> | ||
| 135 | - var destination = points[index+1].potion.lat + ',' + points[index+1].potion.lng; | ||
| 136 | - var region = '上海'; | ||
| 137 | - | ||
| 138 | - var origin_region = '上海'; | ||
| 139 | - | ||
| 140 | - var destination_region = '上海'; | ||
| 141 | - | ||
| 142 | - var output = 'json'; | ||
| 143 | - | ||
| 144 | - var ak_My = 'wjlITmXeCek5MxyU3ZUBkTeU8B0o0npk'; | ||
| 145 | - | ||
| 146 | - /** | ||
| 147 | - * origin:起点名称或经纬度; | ||
| 148 | - * | ||
| 149 | - * destination:终点名称或经纬度; | ||
| 150 | - * | ||
| 151 | - * origin_region:起始点所在城市,驾车导航时必填。 | ||
| 152 | - * | ||
| 153 | - * destination_region:终点所在城市,驾车导航时必填。 | ||
| 154 | - * | ||
| 155 | - * output :表示输出类型,可设置为xml或json,默认为xml。 | ||
| 156 | - * | ||
| 157 | - **/ | ||
| 158 | - var paramsB = {origin:origin,destination:destination,region:region,origin_region:origin_region,destination_region:destination_region,output:output,ak:ak_My}; | ||
| 159 | - | ||
| 160 | - /** @description :未认证开发者默认配额为:2000次/天。 */ | ||
| 161 | - $.ajax({ | ||
| 162 | - | ||
| 163 | - // 百度地图根据坐标获取两点之间的时间与距离 | ||
| 164 | - url: 'http://api.map.baidu.com/direction/v1?mode=transit', | ||
| 165 | - | ||
| 166 | - data: paramsB, | ||
| 167 | - | ||
| 168 | - dataType: 'jsonp', | ||
| 169 | - | ||
| 170 | - success: function(r){ | ||
| 171 | - | ||
| 172 | - if(r) { | ||
| 173 | - | ||
| 174 | - if(r.message=='ok') { | ||
| 175 | - | ||
| 176 | - if(r.result.taxi==null) { | ||
| 177 | - | ||
| 178 | - // 获取距离(单位:米) | ||
| 179 | - points[index+1].distance = 0; | ||
| 180 | - | ||
| 181 | - // 获取时间(单位:秒) | ||
| 182 | - points[index+1].duration = 0; | ||
| 183 | - | ||
| 184 | - }else { | ||
| 185 | - | ||
| 186 | - // 获取距离(单位:米) | ||
| 187 | - points[index+1].distance = r.result.taxi.distance; | ||
| 188 | - | ||
| 189 | - // 获取时间(单位:秒) | ||
| 190 | - points[index+1].duration = r.result.taxi.duration; | ||
| 191 | - | ||
| 192 | - } | ||
| 193 | - | ||
| 194 | - | ||
| 195 | - } | ||
| 196 | - | ||
| 197 | - } | ||
| 198 | - | ||
| 199 | - f(); | ||
| 200 | - } | ||
| 201 | - }); | ||
| 202 | - | ||
| 203 | - })(); | ||
| 204 | - | ||
| 205 | - }, | ||
| 206 | - // 在地图上画出上行线路走向 | ||
| 207 | - drawingUpline01 : function (polylineArray,polyline_center,data) { | ||
| 208 | - var polyUpline01 = 'polyline' + '_' + data.sectionrouteId; | ||
| 209 | - // 创建线路走向 | ||
| 210 | - polyUpline01 = new BMap.Polyline(polylineArray, {strokeColor : "blue",strokeWeight : 6,strokeOpacity : 0.5}); | ||
| 211 | - polyUpline01.data = data; | ||
| 212 | - // 把折线添加到地图上 | ||
| 213 | - mapBValue.addOverlay(polyUpline01); | ||
| 214 | - var sectionPoint = []; | ||
| 215 | - // 线路单击事件 | ||
| 216 | - polyUpline01.addEventListener('click',function(e) { | ||
| 217 | - if(BasicMap.getIsEditStatus()) { | ||
| 218 | - layer.msg('请先保存正在编辑的路段信息...'); | ||
| 219 | - return false; | ||
| 220 | - } | ||
| 221 | - if(BasicMap.getIsCutSection()) { | ||
| 222 | - layer.msg('请先撤销所有切路段的点...'); | ||
| 223 | - return false; | ||
| 224 | - } | ||
| 225 | - polyUpline01.enableEditing(); | ||
| 226 | - BasicMap.setIsEditStatus(true); | ||
| 227 | - }); | ||
| 228 | - | ||
| 229 | - // 添加路段双击事件 | ||
| 230 | - polyUpline01.addEventListener("dblclick",function(e){ | ||
| 231 | - if(BasicMap.getIsCutSection()) { | ||
| 232 | - layer.msg('请先撤销所有切路段的点...'); | ||
| 233 | - return false; | ||
| 234 | - } | ||
| 235 | - BasicMap.setIsEditStatus(false); | ||
| 236 | - // 关闭 | ||
| 237 | - layer.closeAll(); | ||
| 238 | - polyUpline01.disableEditing(); | ||
| 239 | - EditSectionObj.setEitdSection(polyUpline01.data); | ||
| 240 | - // 获取折线坐标集合 | ||
| 241 | - var editPloyLineArray = polyUpline01.getPath(); | ||
| 242 | - EditSectionObj.setEitdBsectionVector(JSON.stringify(editPloyLineArray)); | ||
| 243 | - sectionList = []; | ||
| 244 | - var tbodyHtml = template('section_list',{list : sectionList}); | ||
| 245 | - // 截取路段 | ||
| 246 | - $('#section_table tbody').html(tbodyHtml); | ||
| 247 | - // 加载修改路段弹出层mobal页面 | ||
| 248 | - $.get('editsection.html', function(m){ | ||
| 249 | - $(pjaxContainer).append(m); | ||
| 250 | - $('#edit_section_mobal_cache').trigger('editSectionMobalCache_show', [BasicMap,GetAjaxData,EditSectionObj,PublicFunctions]); | ||
| 251 | - }); | ||
| 252 | - }); | ||
| 253 | - | ||
| 254 | - // 路段右击事件 | ||
| 255 | - var editSection = function(e,ee,marker){ | ||
| 256 | - if(BasicMap.getIsEditStatus()) { | ||
| 257 | - layer.msg('请先保存正在编辑的路段信息...'); | ||
| 258 | - return false; | ||
| 259 | - } | ||
| 260 | - var lng = e.lng; | ||
| 261 | - var lat = e.lat; | ||
| 262 | - var sectionName = null; | ||
| 263 | - var marker = new BMap.Marker(new BMap.Point(lng, lat)); // 创建点 | ||
| 264 | - marker.isFlag = true; | ||
| 265 | - if(pointIndex == 0) { | ||
| 266 | - sectionPoint[pointIndex] = {lng:lng , lat:lat}; | ||
| 267 | - layer.msg('进入切路段状态,请选择本路段的终点!'); | ||
| 268 | - mapBValue.addOverlay(marker);// 添加覆盖物 | ||
| 269 | - firstPoint = {lng:lng, lat:lat}; | ||
| 270 | - pointIndex++; | ||
| 271 | - EditSectionObj.setEitdSection(polyUpline01.data); | ||
| 272 | - // 获取折线坐标集合 | ||
| 273 | - var editPloyLineArray = polyUpline01.getPath(); | ||
| 274 | - EditSectionObj.setEitdBsectionVector(JSON.stringify(editPloyLineArray)); | ||
| 275 | - } else if (pointIndex > 0) { | ||
| 276 | - layer.prompt({title: '请输入路段名!'}, function(sectionName, index){ | ||
| 277 | - pointList = []; | ||
| 278 | - sectionPoint[pointIndex] = {lng:lng , lat:lat}; | ||
| 279 | - pointList[0] = sectionPoint[pointIndex-1]; | ||
| 280 | - pointList[1] = sectionPoint[pointIndex]; | ||
| 281 | - sectionList.push({name:sectionName, section:pointList}); | ||
| 282 | - layer.close(index); | ||
| 283 | - layer.msg('路段截取成功,请选择下一个路段的终点'); | ||
| 284 | - mapBValue.addOverlay(marker);// 添加覆盖物 | ||
| 285 | - var tbodyHtml = template('section_list',{list : sectionList}); | ||
| 286 | - // 截取路段 | ||
| 287 | - $('#section_table tbody').html(tbodyHtml); | ||
| 288 | - pointIndex++; | ||
| 289 | - }); | ||
| 290 | - } | ||
| 291 | - BasicMap.setIsCutSection(true); | ||
| 292 | - } | ||
| 293 | - var markerMenu=new BMap.ContextMenu(); | ||
| 294 | - markerMenu.addItem(new BMap.MenuItem('切路段',editSection.bind(polyUpline01))); | ||
| 295 | - polyUpline01.addContextMenu(markerMenu); | ||
| 296 | - | ||
| 297 | - | ||
| 298 | - var PanOptions_ ={noAnimation :true}; | ||
| 299 | - mapBValue.reset(); | ||
| 300 | - mapBValue.panTo(polyline_center,PanOptions_); | ||
| 301 | - mapBValue.panBy(500,-510,PanOptions_); | ||
| 302 | - mapBValue.setZoom(14); | ||
| 303 | - }, | ||
| 304 | - // 删除点刷新cutSectionTable | ||
| 305 | - refreshCutSectionTable : function() { | ||
| 306 | - var tbodyHtml = template('section_list',{list : sectionList}); | ||
| 307 | - $('#section_table tbody').html(tbodyHtml); | ||
| 308 | - }, | ||
| 309 | - // 删除点刷新覆盖物 | ||
| 310 | - deleteCutSectionPoint : function(point) { | ||
| 311 | - var lng = point.lng; | ||
| 312 | - var lat = point.lat; | ||
| 313 | - var allOverlay = mapBValue.getOverlays(); | ||
| 314 | - // 删除最后一个点 | ||
| 315 | - for (var i = 0; i < allOverlay.length -1; i++){ | ||
| 316 | - if(allOverlay[i].isFlag) { | ||
| 317 | - if(allOverlay[i].point.lng == lng && allOverlay[i].point.lat == lat){ | ||
| 318 | - mapBValue.removeOverlay(allOverlay[i]); | ||
| 319 | - break; | ||
| 320 | - } | ||
| 321 | - } | ||
| 322 | - } | ||
| 323 | - }, | ||
| 324 | - /** 在地图上画点 @param:<point_center:中心坐标点> */ | ||
| 325 | - drawingUpStationPoint : function(point_center,stationName,s) { | ||
| 326 | - | ||
| 327 | - // 自定义标注物图片 | ||
| 328 | - var icon_target = new BMap.Icon('/pages/base/stationroute/css/img/gjzd.png',new BMap.Size(10, 10)); | ||
| 329 | - | ||
| 330 | - var html2 = '<div style="position: absolute; margin: 0pt; padding: 0pt; width: 160px; height: 26px; left: -10px; top: -35px; overflow: hidden;">' | ||
| 331 | - + '<img class="rm3_image" style="border:none;left:0px; top:0px; position:absolute;" src="/pages/base/stationroute/css/img/back160.png">' | ||
| 332 | - + '</div>' | ||
| 333 | - + '<label class=" BMapLabel" unselectable="on" style="position: absolute; -moz-user-select: none; display: inline; cursor: inherit; border: 0px none; padding: 2px 1px 1px; white-space: nowrap; font: 12px arial,simsun; z-index: 80; color: rgb(255, 102, 0); left: 15px; top: -35px;"><span style="float: left; color: #fdfdfd; margin-left: -22px; font-size: 6px;">'+ s+'</span>'+ stationName+'</label>'; | ||
| 334 | - | ||
| 335 | - | ||
| 336 | - var myRichMarker1 = new BMapLib.RichMarker(html2, point_center,{ | ||
| 337 | - "anchor" : new BMap.Size(-10,8), | ||
| 338 | - "enableDragging" : true}); | ||
| 339 | - | ||
| 340 | - | ||
| 341 | - myRichMarker1.disableDragging(); | ||
| 342 | - mapBValue.addOverlay(myRichMarker1); | ||
| 343 | - | ||
| 344 | - | ||
| 345 | - // 创建标注物 | ||
| 346 | - marker = new BMap.Marker(point_center,{icon : icon_target}); | ||
| 347 | - | ||
| 348 | - // 允许覆盖物在map.clearOverlays方法中被清除。 | ||
| 349 | - marker.enableMassClear(); | ||
| 350 | - | ||
| 351 | - mapBValue.addOverlay(marker); | ||
| 352 | - }, | ||
| 353 | - | ||
| 354 | - // 根据站点坐标匹配库中的公交站点(手动规划) | ||
| 355 | - stationsPointsToLibraryPoint : function(arra,callback) { | ||
| 356 | - // 获取长度 | ||
| 357 | - var len = arra.length; | ||
| 358 | - var station = {}; | ||
| 359 | - var stationList = []; | ||
| 360 | - (function(){ | ||
| 361 | - if (!arguments.callee.count) { | ||
| 362 | - arguments.callee.count = 0; | ||
| 363 | - } | ||
| 364 | - arguments.callee.count++; | ||
| 365 | - var index = parseInt(arguments.callee.count) - 1; | ||
| 366 | - if (index >= len) { | ||
| 367 | - callback && callback(stationList); | ||
| 368 | - return ; | ||
| 369 | - } | ||
| 370 | - var f = arguments.callee; | ||
| 371 | - station = arra[index]; | ||
| 372 | - if(arra[index].name!=''){ | ||
| 373 | - | ||
| 374 | - $.get('/station/matchStation',station,function(resultStation) { | ||
| 375 | - stationList.push({name:resultStation.name ,wgs:arra[index].wgs,potion:{lng:resultStation.potion_lng, lat:resultStation.potion_lat}, isHave:resultStation.isHave , id:resultStation.id}); | ||
| 376 | - f(); | ||
| 377 | - }); | ||
| 378 | - }else { | ||
| 379 | - f(); | ||
| 380 | - } | ||
| 381 | - })() | ||
| 382 | - }, | ||
| 383 | - clearMarkAndOverlays : function() { | ||
| 384 | - | ||
| 385 | - // 清楚地图覆盖物 | ||
| 386 | - mapBValue.clearOverlays(); | ||
| 387 | - | ||
| 388 | - mapBValue.removeOverlay(); | ||
| 389 | - | ||
| 390 | - } | ||
| 391 | - | ||
| 392 | - } | ||
| 393 | - | ||
| 394 | - return Bmap; | ||
| 395 | - | 1 | +/** |
| 2 | + * 百度地图 | ||
| 3 | + * | ||
| 4 | + * - - - - - -》init:地图初始化 | ||
| 5 | + * | ||
| 6 | + * - - - - - -》getDistanceAndDuration:获取距离与时间 | ||
| 7 | + * | ||
| 8 | + * - - - - - -》drawingUpline:在地图上画出上行线路走向 | ||
| 9 | + * | ||
| 10 | + * - - - - - -》stationsPointsToLibraryPoint:根据站点坐标匹配库中的公交站点(手动规划) | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +var BasicMap = function () { | ||
| 14 | + | ||
| 15 | + /** BasicMap 全局变量定义 mapBValue:地图对象;polyUpline:走向折线;sectionList:截取过的路段 ;pointIndex:计算路段被切的次数; | ||
| 16 | + * firstPoint:截取路段的第一个点;iseditStatus:路段是否在编辑状态;isCutSection : 获取路段是否在截取状态*/ | ||
| 17 | + var mapBValue = '', polyUpline='', sectionList = [], pointIndex = 0, iseditStatus = false, firstPoint = {}, isCutSection = false; | ||
| 18 | + | ||
| 19 | + var Bmap = { | ||
| 20 | + | ||
| 21 | + init : function() { | ||
| 22 | + | ||
| 23 | + // 设置中心点, | ||
| 24 | + var CENTER_POINT = {lng : 121.528733,lat : 31.237425}; | ||
| 25 | + | ||
| 26 | + // 百度API Key | ||
| 27 | + var bdKey = 'IGGrr4UjwIYzatoCRFKEL8sT'; | ||
| 28 | + | ||
| 29 | + // 初始化百度地图 | ||
| 30 | + mapBValue = new BMap.Map("BasicMap"); | ||
| 31 | + | ||
| 32 | + //中心点和缩放级别 | ||
| 33 | + mapBValue.centerAndZoom(new BMap.Point(CENTER_POINT.lng,CENTER_POINT.lat),15); | ||
| 34 | + | ||
| 35 | + //启用地图拖拽事件,默认启用(可不写) | ||
| 36 | + mapBValue.enableDragging(); | ||
| 37 | + | ||
| 38 | + //启用地图滚轮放大缩小 | ||
| 39 | + mapBValue.enableScrollWheelZoom(); | ||
| 40 | + | ||
| 41 | + //禁用鼠标双击放大 | ||
| 42 | + mapBValue.disableDoubleClickZoom(); | ||
| 43 | + | ||
| 44 | + //启用键盘上下左右键移动地图 | ||
| 45 | + mapBValue.enableKeyboard(); | ||
| 46 | + | ||
| 47 | + return mapBValue; | ||
| 48 | + }, | ||
| 49 | + /** 获取第一个切路段的点 @return Point*/ | ||
| 50 | + getFirstPoint : function() { | ||
| 51 | + return firstPoint; | ||
| 52 | + }, | ||
| 53 | + /** 获取地图对象 @return 地图对象map */ | ||
| 54 | + getmapBValue : function() { | ||
| 55 | + | ||
| 56 | + return mapBValue; | ||
| 57 | + | ||
| 58 | + }, | ||
| 59 | + | ||
| 60 | + getPolyUpline : function() { | ||
| 61 | + | ||
| 62 | + return polyUpline; | ||
| 63 | + }, | ||
| 64 | + | ||
| 65 | + /** 获取截取过的路段 @return 路段对象List */ | ||
| 66 | + getSectionList : function() { | ||
| 67 | + | ||
| 68 | + return sectionList; | ||
| 69 | + | ||
| 70 | + }, | ||
| 71 | + setSectionList : function(list) { | ||
| 72 | + | ||
| 73 | + sectionList = list; | ||
| 74 | + }, | ||
| 75 | + initCutSectionPoint : function() { | ||
| 76 | + sectionList = []; | ||
| 77 | + var tbodyHtml = template('section_list',{list : sectionList}); | ||
| 78 | + $('#section_table tbody').html(tbodyHtml); | ||
| 79 | + }, | ||
| 80 | + /** 获取切路段的点下标 @return int*/ | ||
| 81 | + setPointIndex : function(index) { | ||
| 82 | + pointIndex = index; | ||
| 83 | + }, | ||
| 84 | + getPointIndex : function() { | ||
| 85 | + | ||
| 86 | + return pointIndex; | ||
| 87 | + | ||
| 88 | + }, | ||
| 89 | + /** 获取路段是否在编辑状态 @return boolean*/ | ||
| 90 | + getIsEditStatus : function() { | ||
| 91 | + return iseditStatus; | ||
| 92 | + }, | ||
| 93 | + setIsEditStatus : function(v) { | ||
| 94 | + iseditStatus = v ; | ||
| 95 | + }, | ||
| 96 | + | ||
| 97 | + /** 获取路段是否在截取状态 @return boolean*/ | ||
| 98 | + getIsCutSection : function() { | ||
| 99 | + return isCutSection; | ||
| 100 | + }, | ||
| 101 | + setIsCutSection : function(v) { | ||
| 102 | + isCutSection = v ; | ||
| 103 | + }, | ||
| 104 | + | ||
| 105 | + /** 获取距离与时间 @param <points:坐标点集合> */ | ||
| 106 | + getDistanceAndDuration : function(points,callback){ | ||
| 107 | + | ||
| 108 | + // 获取长度 | ||
| 109 | + var len = points.length; | ||
| 110 | + (function(){ | ||
| 111 | + | ||
| 112 | + if (!arguments.callee.count) { | ||
| 113 | + | ||
| 114 | + arguments.callee.count = 0; | ||
| 115 | + | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + arguments.callee.count++; | ||
| 119 | + | ||
| 120 | + var index = parseInt(arguments.callee.count) - 1; | ||
| 121 | + | ||
| 122 | + if (index >= len-1) { | ||
| 123 | + | ||
| 124 | + callback && callback(points); | ||
| 125 | + | ||
| 126 | + return; | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + // 当函数被调用时,它的arguments.callee对象就会指向自身,也就是一个对自己的引用。(当前正在执行的函数。) | ||
| 130 | + var f = arguments.callee; | ||
| 131 | + // 起点坐标 <坐标格式:40.056878,116.30815> | ||
| 132 | + var origin = points[index].potion.lat + ',' + points[index].potion.lng; | ||
| 133 | + | ||
| 134 | + // 终点坐标 <坐标格式:40.056878,116.30815> | ||
| 135 | + var destination = points[index+1].potion.lat + ',' + points[index+1].potion.lng; | ||
| 136 | + var region = '上海'; | ||
| 137 | + | ||
| 138 | + var origin_region = '上海'; | ||
| 139 | + | ||
| 140 | + var destination_region = '上海'; | ||
| 141 | + | ||
| 142 | + var output = 'json'; | ||
| 143 | + | ||
| 144 | + var ak_My = 'wjlITmXeCek5MxyU3ZUBkTeU8B0o0npk'; | ||
| 145 | + | ||
| 146 | + /** | ||
| 147 | + * origin:起点名称或经纬度; | ||
| 148 | + * | ||
| 149 | + * destination:终点名称或经纬度; | ||
| 150 | + * | ||
| 151 | + * origin_region:起始点所在城市,驾车导航时必填。 | ||
| 152 | + * | ||
| 153 | + * destination_region:终点所在城市,驾车导航时必填。 | ||
| 154 | + * | ||
| 155 | + * output :表示输出类型,可设置为xml或json,默认为xml。 | ||
| 156 | + * | ||
| 157 | + **/ | ||
| 158 | + var paramsB = {origin:origin,destination:destination,region:region,origin_region:origin_region,destination_region:destination_region,output:output,ak:ak_My}; | ||
| 159 | + | ||
| 160 | + /** @description :未认证开发者默认配额为:2000次/天。 */ | ||
| 161 | + $.ajax({ | ||
| 162 | + | ||
| 163 | + // 百度地图根据坐标获取两点之间的时间与距离 | ||
| 164 | + url: '//api.map.baidu.com/direction/v1?mode=transit', | ||
| 165 | + | ||
| 166 | + data: paramsB, | ||
| 167 | + | ||
| 168 | + dataType: 'jsonp', | ||
| 169 | + | ||
| 170 | + success: function(r){ | ||
| 171 | + | ||
| 172 | + if(r) { | ||
| 173 | + | ||
| 174 | + if(r.message=='ok') { | ||
| 175 | + | ||
| 176 | + if(r.result.taxi==null) { | ||
| 177 | + | ||
| 178 | + // 获取距离(单位:米) | ||
| 179 | + points[index+1].distance = 0; | ||
| 180 | + | ||
| 181 | + // 获取时间(单位:秒) | ||
| 182 | + points[index+1].duration = 0; | ||
| 183 | + | ||
| 184 | + }else { | ||
| 185 | + | ||
| 186 | + // 获取距离(单位:米) | ||
| 187 | + points[index+1].distance = r.result.taxi.distance; | ||
| 188 | + | ||
| 189 | + // 获取时间(单位:秒) | ||
| 190 | + points[index+1].duration = r.result.taxi.duration; | ||
| 191 | + | ||
| 192 | + } | ||
| 193 | + | ||
| 194 | + | ||
| 195 | + } | ||
| 196 | + | ||
| 197 | + } | ||
| 198 | + | ||
| 199 | + f(); | ||
| 200 | + } | ||
| 201 | + }); | ||
| 202 | + | ||
| 203 | + })(); | ||
| 204 | + | ||
| 205 | + }, | ||
| 206 | + // 在地图上画出上行线路走向 | ||
| 207 | + drawingUpline01 : function (polylineArray,polyline_center,data) { | ||
| 208 | + var polyUpline01 = 'polyline' + '_' + data.sectionrouteId; | ||
| 209 | + // 创建线路走向 | ||
| 210 | + polyUpline01 = new BMap.Polyline(polylineArray, {strokeColor : "blue",strokeWeight : 6,strokeOpacity : 0.5}); | ||
| 211 | + polyUpline01.data = data; | ||
| 212 | + // 把折线添加到地图上 | ||
| 213 | + mapBValue.addOverlay(polyUpline01); | ||
| 214 | + var sectionPoint = []; | ||
| 215 | + // 线路单击事件 | ||
| 216 | + polyUpline01.addEventListener('click',function(e) { | ||
| 217 | + if(BasicMap.getIsEditStatus()) { | ||
| 218 | + layer.msg('请先保存正在编辑的路段信息...'); | ||
| 219 | + return false; | ||
| 220 | + } | ||
| 221 | + if(BasicMap.getIsCutSection()) { | ||
| 222 | + layer.msg('请先撤销所有切路段的点...'); | ||
| 223 | + return false; | ||
| 224 | + } | ||
| 225 | + polyUpline01.enableEditing(); | ||
| 226 | + BasicMap.setIsEditStatus(true); | ||
| 227 | + }); | ||
| 228 | + | ||
| 229 | + // 添加路段双击事件 | ||
| 230 | + polyUpline01.addEventListener("dblclick",function(e){ | ||
| 231 | + if(BasicMap.getIsCutSection()) { | ||
| 232 | + layer.msg('请先撤销所有切路段的点...'); | ||
| 233 | + return false; | ||
| 234 | + } | ||
| 235 | + BasicMap.setIsEditStatus(false); | ||
| 236 | + // 关闭 | ||
| 237 | + layer.closeAll(); | ||
| 238 | + polyUpline01.disableEditing(); | ||
| 239 | + EditSectionObj.setEitdSection(polyUpline01.data); | ||
| 240 | + // 获取折线坐标集合 | ||
| 241 | + var editPloyLineArray = polyUpline01.getPath(); | ||
| 242 | + EditSectionObj.setEitdBsectionVector(JSON.stringify(editPloyLineArray)); | ||
| 243 | + sectionList = []; | ||
| 244 | + var tbodyHtml = template('section_list',{list : sectionList}); | ||
| 245 | + // 截取路段 | ||
| 246 | + $('#section_table tbody').html(tbodyHtml); | ||
| 247 | + // 加载修改路段弹出层mobal页面 | ||
| 248 | + $.get('editsection.html', function(m){ | ||
| 249 | + $(pjaxContainer).append(m); | ||
| 250 | + $('#edit_section_mobal_cache').trigger('editSectionMobalCache_show', [BasicMap,GetAjaxData,EditSectionObj,PublicFunctions]); | ||
| 251 | + }); | ||
| 252 | + }); | ||
| 253 | + | ||
| 254 | + // 路段右击事件 | ||
| 255 | + var editSection = function(e,ee,marker){ | ||
| 256 | + if(BasicMap.getIsEditStatus()) { | ||
| 257 | + layer.msg('请先保存正在编辑的路段信息...'); | ||
| 258 | + return false; | ||
| 259 | + } | ||
| 260 | + var lng = e.lng; | ||
| 261 | + var lat = e.lat; | ||
| 262 | + var sectionName = null; | ||
| 263 | + var marker = new BMap.Marker(new BMap.Point(lng, lat)); // 创建点 | ||
| 264 | + marker.isFlag = true; | ||
| 265 | + if(pointIndex == 0) { | ||
| 266 | + sectionPoint[pointIndex] = {lng:lng , lat:lat}; | ||
| 267 | + layer.msg('进入切路段状态,请选择本路段的终点!'); | ||
| 268 | + mapBValue.addOverlay(marker);// 添加覆盖物 | ||
| 269 | + firstPoint = {lng:lng, lat:lat}; | ||
| 270 | + pointIndex++; | ||
| 271 | + EditSectionObj.setEitdSection(polyUpline01.data); | ||
| 272 | + // 获取折线坐标集合 | ||
| 273 | + var editPloyLineArray = polyUpline01.getPath(); | ||
| 274 | + EditSectionObj.setEitdBsectionVector(JSON.stringify(editPloyLineArray)); | ||
| 275 | + } else if (pointIndex > 0) { | ||
| 276 | + layer.prompt({title: '请输入路段名!'}, function(sectionName, index){ | ||
| 277 | + pointList = []; | ||
| 278 | + sectionPoint[pointIndex] = {lng:lng , lat:lat}; | ||
| 279 | + pointList[0] = sectionPoint[pointIndex-1]; | ||
| 280 | + pointList[1] = sectionPoint[pointIndex]; | ||
| 281 | + sectionList.push({name:sectionName, section:pointList}); | ||
| 282 | + layer.close(index); | ||
| 283 | + layer.msg('路段截取成功,请选择下一个路段的终点'); | ||
| 284 | + mapBValue.addOverlay(marker);// 添加覆盖物 | ||
| 285 | + var tbodyHtml = template('section_list',{list : sectionList}); | ||
| 286 | + // 截取路段 | ||
| 287 | + $('#section_table tbody').html(tbodyHtml); | ||
| 288 | + pointIndex++; | ||
| 289 | + }); | ||
| 290 | + } | ||
| 291 | + BasicMap.setIsCutSection(true); | ||
| 292 | + } | ||
| 293 | + var markerMenu=new BMap.ContextMenu(); | ||
| 294 | + markerMenu.addItem(new BMap.MenuItem('切路段',editSection.bind(polyUpline01))); | ||
| 295 | + polyUpline01.addContextMenu(markerMenu); | ||
| 296 | + | ||
| 297 | + | ||
| 298 | + var PanOptions_ ={noAnimation :true}; | ||
| 299 | + mapBValue.reset(); | ||
| 300 | + mapBValue.panTo(polyline_center,PanOptions_); | ||
| 301 | + mapBValue.panBy(500,-510,PanOptions_); | ||
| 302 | + mapBValue.setZoom(14); | ||
| 303 | + }, | ||
| 304 | + // 删除点刷新cutSectionTable | ||
| 305 | + refreshCutSectionTable : function() { | ||
| 306 | + var tbodyHtml = template('section_list',{list : sectionList}); | ||
| 307 | + $('#section_table tbody').html(tbodyHtml); | ||
| 308 | + }, | ||
| 309 | + // 删除点刷新覆盖物 | ||
| 310 | + deleteCutSectionPoint : function(point) { | ||
| 311 | + var lng = point.lng; | ||
| 312 | + var lat = point.lat; | ||
| 313 | + var allOverlay = mapBValue.getOverlays(); | ||
| 314 | + // 删除最后一个点 | ||
| 315 | + for (var i = 0; i < allOverlay.length -1; i++){ | ||
| 316 | + if(allOverlay[i].isFlag) { | ||
| 317 | + if(allOverlay[i].point.lng == lng && allOverlay[i].point.lat == lat){ | ||
| 318 | + mapBValue.removeOverlay(allOverlay[i]); | ||
| 319 | + break; | ||
| 320 | + } | ||
| 321 | + } | ||
| 322 | + } | ||
| 323 | + }, | ||
| 324 | + /** 在地图上画点 @param:<point_center:中心坐标点> */ | ||
| 325 | + drawingUpStationPoint : function(point_center,stationName,s) { | ||
| 326 | + | ||
| 327 | + // 自定义标注物图片 | ||
| 328 | + var icon_target = new BMap.Icon('/pages/base/stationroute/css/img/gjzd.png',new BMap.Size(10, 10)); | ||
| 329 | + | ||
| 330 | + var html2 = '<div style="position: absolute; margin: 0pt; padding: 0pt; width: 160px; height: 26px; left: -10px; top: -35px; overflow: hidden;">' | ||
| 331 | + + '<img class="rm3_image" style="border:none;left:0px; top:0px; position:absolute;" src="/pages/base/stationroute/css/img/back160.png">' | ||
| 332 | + + '</div>' | ||
| 333 | + + '<label class=" BMapLabel" unselectable="on" style="position: absolute; -moz-user-select: none; display: inline; cursor: inherit; border: 0px none; padding: 2px 1px 1px; white-space: nowrap; font: 12px arial,simsun; z-index: 80; color: rgb(255, 102, 0); left: 15px; top: -35px;"><span style="float: left; color: #fdfdfd; margin-left: -22px; font-size: 6px;">'+ s+'</span>'+ stationName+'</label>'; | ||
| 334 | + | ||
| 335 | + | ||
| 336 | + var myRichMarker1 = new BMapLib.RichMarker(html2, point_center,{ | ||
| 337 | + "anchor" : new BMap.Size(-10,8), | ||
| 338 | + "enableDragging" : true}); | ||
| 339 | + | ||
| 340 | + | ||
| 341 | + myRichMarker1.disableDragging(); | ||
| 342 | + mapBValue.addOverlay(myRichMarker1); | ||
| 343 | + | ||
| 344 | + | ||
| 345 | + // 创建标注物 | ||
| 346 | + marker = new BMap.Marker(point_center,{icon : icon_target}); | ||
| 347 | + | ||
| 348 | + // 允许覆盖物在map.clearOverlays方法中被清除。 | ||
| 349 | + marker.enableMassClear(); | ||
| 350 | + | ||
| 351 | + mapBValue.addOverlay(marker); | ||
| 352 | + }, | ||
| 353 | + | ||
| 354 | + // 根据站点坐标匹配库中的公交站点(手动规划) | ||
| 355 | + stationsPointsToLibraryPoint : function(arra,callback) { | ||
| 356 | + // 获取长度 | ||
| 357 | + var len = arra.length; | ||
| 358 | + var station = {}; | ||
| 359 | + var stationList = []; | ||
| 360 | + (function(){ | ||
| 361 | + if (!arguments.callee.count) { | ||
| 362 | + arguments.callee.count = 0; | ||
| 363 | + } | ||
| 364 | + arguments.callee.count++; | ||
| 365 | + var index = parseInt(arguments.callee.count) - 1; | ||
| 366 | + if (index >= len) { | ||
| 367 | + callback && callback(stationList); | ||
| 368 | + return ; | ||
| 369 | + } | ||
| 370 | + var f = arguments.callee; | ||
| 371 | + station = arra[index]; | ||
| 372 | + if(arra[index].name!=''){ | ||
| 373 | + | ||
| 374 | + $.get('/station/matchStation',station,function(resultStation) { | ||
| 375 | + stationList.push({name:resultStation.name ,wgs:arra[index].wgs,potion:{lng:resultStation.potion_lng, lat:resultStation.potion_lat}, isHave:resultStation.isHave , id:resultStation.id}); | ||
| 376 | + f(); | ||
| 377 | + }); | ||
| 378 | + }else { | ||
| 379 | + f(); | ||
| 380 | + } | ||
| 381 | + })() | ||
| 382 | + }, | ||
| 383 | + clearMarkAndOverlays : function() { | ||
| 384 | + | ||
| 385 | + // 清楚地图覆盖物 | ||
| 386 | + mapBValue.clearOverlays(); | ||
| 387 | + | ||
| 388 | + mapBValue.removeOverlay(); | ||
| 389 | + | ||
| 390 | + } | ||
| 391 | + | ||
| 392 | + } | ||
| 393 | + | ||
| 394 | + return Bmap; | ||
| 395 | + | ||
| 396 | }(); | 396 | }(); |
| 397 | \ No newline at end of file | 397 | \ No newline at end of file |
src/main/resources/static/pages/excep/js/outbound-map.js
| 1 | -/** | ||
| 2 | - * 百度地图 | ||
| 3 | - * | ||
| 4 | - * - - - - - -》init:地图初始化 | ||
| 5 | - * | ||
| 6 | - * - - - - - -》lineInfoPanl:从百度地图抓去站点与路段数据 | ||
| 7 | - * | ||
| 8 | - * - - - - - -》getDistanceAndDuration:获取距离与时间 | ||
| 9 | - * | ||
| 10 | - * - - - - - -》pointsPolygon:地图画多边行 | ||
| 11 | - * | ||
| 12 | - * - - - - - -》pointsCircle:画圆 | ||
| 13 | - * | ||
| 14 | - * - - - - - -》localSearchFromAdreesToPoint:根据地理名称获取百度经纬度坐标 | ||
| 15 | - * | ||
| 16 | - * - - - - - -》drawingUpline:在地图上画出上行线路走向 | ||
| 17 | - * | ||
| 18 | - * - - - - - -》stationsNameToPoints:站点名称获取百度坐标(手动规划) | ||
| 19 | - * | ||
| 20 | - * - - - - - -》getDistanceAndTotime:根据坐标点获取两点之间的时间与距离(手动规划) | ||
| 21 | - * | ||
| 22 | - * - - - - - -》getSectionListPlonly:根据坐标点获取两点之间的折线路段(手动规划) | ||
| 23 | - */ | ||
| 24 | - | ||
| 25 | -var WorldsBMap = function () { | ||
| 26 | - | ||
| 27 | - /** WorldsBMap 全局变量定义 mapBValue:地图对象;polygon:多边形;polyUpline:走向折线;circle:圆 */ | ||
| 28 | - var mapBValue = '';polygon='',polyUpline='',circle='',iseditStatus = false; | ||
| 29 | - | ||
| 30 | - var Bmap = { | ||
| 31 | - | ||
| 32 | - init : function() { | ||
| 33 | - | ||
| 34 | - // 设置中心点, | ||
| 35 | - var CENTER_POINT = {lng : 121.528733,lat : 31.237425}; | ||
| 36 | - | ||
| 37 | - // 百度API Key | ||
| 38 | - var bdKey = 'IGGrr4UjwIYzatoCRFKEL8sT'; | ||
| 39 | - | ||
| 40 | - // 初始化百度地图 | ||
| 41 | - mapBValue = new BMap.Map("bmap_basic"); | ||
| 42 | - | ||
| 43 | - //中心点和缩放级别 | ||
| 44 | - mapBValue.centerAndZoom(new BMap.Point(CENTER_POINT.lng,CENTER_POINT.lat), 15); | ||
| 45 | - | ||
| 46 | - //启用地图拖拽事件,默认启用(可不写) | ||
| 47 | - mapBValue.enableDragging(); | ||
| 48 | - | ||
| 49 | - //启用地图滚轮放大缩小 | ||
| 50 | - mapBValue.enableScrollWheelZoom(); | ||
| 51 | - | ||
| 52 | - //禁用鼠标双击放大 | ||
| 53 | - mapBValue.disableDoubleClickZoom(); | ||
| 54 | - | ||
| 55 | - //启用键盘上下左右键移动地图 | ||
| 56 | - mapBValue.enableKeyboard(); | ||
| 57 | - | ||
| 58 | - return mapBValue; | ||
| 59 | - }, | ||
| 60 | - | ||
| 61 | - /** 获取地图对象 @return 地图对象map */ | ||
| 62 | - getmapBValue : function() { | ||
| 63 | - | ||
| 64 | - return mapBValue; | ||
| 65 | - | ||
| 66 | - }, | ||
| 67 | - | ||
| 68 | - getPolygon : function(){ | ||
| 69 | - | ||
| 70 | - return polygon; | ||
| 71 | - }, | ||
| 72 | - | ||
| 73 | - getPolyUpline : function() { | ||
| 74 | - | ||
| 75 | - return polyUpline; | ||
| 76 | - }, | ||
| 77 | - | ||
| 78 | - getCircle : function() { | ||
| 79 | - | ||
| 80 | - return circle; | ||
| 81 | - }, | ||
| 82 | - | ||
| 83 | - getIsEditStatus : function() { | ||
| 84 | - return iseditStatus; | ||
| 85 | - }, | ||
| 86 | - | ||
| 87 | - setIsEditStatus : function(v) { | ||
| 88 | - iseditStatus = v ; | ||
| 89 | - }, | ||
| 90 | - | ||
| 91 | - initDrawingManager: function(map,styleOptions) { | ||
| 92 | - | ||
| 93 | - }, | ||
| 94 | - | ||
| 95 | - getDrawingManagerObj : function() { | ||
| 96 | - | ||
| 97 | - return drawingManagerInitV; | ||
| 98 | - }, | ||
| 99 | - | ||
| 100 | - // 从百度地图抓去站点与路段数据 | ||
| 101 | - lineInfoPanl : function(lineNameValue,i,cb) { | ||
| 102 | - | ||
| 103 | - /** 根据线路名称与方向从百度地图获取站点与路段 @param lineNameValue:线路名称;i:方向<0:上行;1:下行> */ | ||
| 104 | - WorldsBMap.getBmapStationNames(lineNameValue,i,function(BusLine){ | ||
| 105 | - | ||
| 106 | - return cb && cb(BusLine); | ||
| 107 | - | ||
| 108 | - }); | ||
| 109 | - | ||
| 110 | - }, | ||
| 111 | - | ||
| 112 | - /** 获取距离与时间 @param <points:坐标点集合> */ | ||
| 113 | - getDistanceAndDuration : function(points,callback){ | ||
| 114 | - | ||
| 115 | - // 获取长度 | ||
| 116 | - var len = points.length; | ||
| 117 | - | ||
| 118 | - (function(){ | ||
| 119 | - | ||
| 120 | - if (!arguments.callee.count) { | ||
| 121 | - | ||
| 122 | - arguments.callee.count = 0; | ||
| 123 | - | ||
| 124 | - } | ||
| 125 | - | ||
| 126 | - arguments.callee.count++; | ||
| 127 | - | ||
| 128 | - var index = parseInt(arguments.callee.count) - 1; | ||
| 129 | - | ||
| 130 | - if (index >= len-1) { | ||
| 131 | - | ||
| 132 | - callback && callback(points); | ||
| 133 | - | ||
| 134 | - return; | ||
| 135 | - } | ||
| 136 | - | ||
| 137 | - // 当函数被调用时,它的arguments.callee对象就会指向自身,也就是一个对自己的引用。(当前正在执行的函数。) | ||
| 138 | - var f = arguments.callee; | ||
| 139 | - | ||
| 140 | - // 起点坐标 <坐标格式:40.056878,116.30815> | ||
| 141 | - var origin = points[index].potion.lat + ',' + points[index].potion.lng; | ||
| 142 | - | ||
| 143 | - // 终点坐标 <坐标格式:40.056878,116.30815> | ||
| 144 | - var destination = points[index+1].potion.lat + ',' + points[index+1].potion.lng; | ||
| 145 | - | ||
| 146 | - var region = '上海'; | ||
| 147 | - | ||
| 148 | - var origin_region = '上海'; | ||
| 149 | - | ||
| 150 | - var destination_region = '上海'; | ||
| 151 | - | ||
| 152 | - var output = 'json'; | ||
| 153 | - | ||
| 154 | - var ak_My = 'wjlITmXeCek5MxyU3ZUBkTeU8B0o0npk'; | ||
| 155 | - | ||
| 156 | - /** | ||
| 157 | - * origin:起点名称或经纬度; | ||
| 158 | - * | ||
| 159 | - * destination:终点名称或经纬度; | ||
| 160 | - * | ||
| 161 | - * origin_region:起始点所在城市,驾车导航时必填。 | ||
| 162 | - * | ||
| 163 | - * destination_region:终点所在城市,驾车导航时必填。 | ||
| 164 | - * | ||
| 165 | - * output :表示输出类型,可设置为xml或json,默认为xml。 | ||
| 166 | - * | ||
| 167 | - **/ | ||
| 168 | - var paramsB = {origin:origin,destination:destination,region:region,origin_region:origin_region,destination_region:destination_region,output:output,ak:ak_My}; | ||
| 169 | - | ||
| 170 | - /** @description :未认证开发者默认配额为:2000次/天。 */ | ||
| 171 | - $.ajax({ | ||
| 172 | - | ||
| 173 | - // 百度地图根据坐标获取两点之间的时间与距离 | ||
| 174 | - url: 'http://api.map.baidu.com/direction/v1?mode=transit', | ||
| 175 | - | ||
| 176 | - data: paramsB, | ||
| 177 | - | ||
| 178 | - dataType: 'jsonp', | ||
| 179 | - | ||
| 180 | - success: function(r){ | ||
| 181 | - | ||
| 182 | - if(r) { | ||
| 183 | - | ||
| 184 | - if(r.message=='ok') { | ||
| 185 | - | ||
| 186 | - if(r.result.taxi==null) { | ||
| 187 | - | ||
| 188 | - // 获取距离(单位:米) | ||
| 189 | - points[index+1].distance = 0; | ||
| 190 | - | ||
| 191 | - // 获取时间(单位:秒) | ||
| 192 | - points[index+1].duration = 0; | ||
| 193 | - | ||
| 194 | - }else { | ||
| 195 | - | ||
| 196 | - // 获取距离(单位:米) | ||
| 197 | - points[index+1].distance = r.result.taxi.distance; | ||
| 198 | - | ||
| 199 | - // 获取时间(单位:秒) | ||
| 200 | - points[index+1].duration = r.result.taxi.duration; | ||
| 201 | - | ||
| 202 | - } | ||
| 203 | - | ||
| 204 | - | ||
| 205 | - } | ||
| 206 | - | ||
| 207 | - } | ||
| 208 | - | ||
| 209 | - f(); | ||
| 210 | - } | ||
| 211 | - }); | ||
| 212 | - | ||
| 213 | - })(); | ||
| 214 | - | ||
| 215 | - }, | ||
| 216 | - | ||
| 217 | - // 地图画多边形 | ||
| 218 | - pointsPolygon : function(objStation) { | ||
| 219 | - | ||
| 220 | - // 将视图切换到指定的缩放等级,中心点坐标不变。注意:当有信息窗口在地图上打开时,地图缩放将保证信息窗口所在的坐标位置不动。(自1.2新增) | ||
| 221 | - mapBValue.setZoom(15); | ||
| 222 | - | ||
| 223 | - // 如果不为空 | ||
| 224 | - if(objStation) { | ||
| 225 | - | ||
| 226 | - // 获取中心点坐标字符串 | ||
| 227 | - var testpointStr = objStation.stationBJwpoints; | ||
| 228 | - | ||
| 229 | - // 按空格切割中心点坐标字符串 | ||
| 230 | - var BJwpointsPolygon = testpointStr.split(' '); | ||
| 231 | - | ||
| 232 | - // 中心点坐标 | ||
| 233 | - var pointPolygon = new BMap.Point(BJwpointsPolygon[0], BJwpointsPolygon[1]); | ||
| 234 | - | ||
| 235 | - // 获取多边形坐标字符串 | ||
| 236 | - var stationBPolygonGrid = objStation.stationBPolygonGrid; | ||
| 237 | - | ||
| 238 | - // 截取多边形坐标字符串 | ||
| 239 | - var stationBPolygonGridStr = stationBPolygonGrid.substring(9,stationBPolygonGrid.length-2); | ||
| 240 | - | ||
| 241 | - // 按逗号切割 | ||
| 242 | - var pointPolygonArray = stationBPolygonGridStr.split(','); | ||
| 243 | - | ||
| 244 | - // 多边形坐标集合 | ||
| 245 | - var polygonP = []; | ||
| 246 | - | ||
| 247 | - for(var v = 0;v<pointPolygonArray.length;v++) { | ||
| 248 | - | ||
| 249 | - polygonP.push(new BMap.Point(pointPolygonArray[v].split(" ")[0],pointPolygonArray[v].split(" ")[1])); | ||
| 250 | - | ||
| 251 | - } | ||
| 252 | - | ||
| 253 | - // 画多边形 | ||
| 254 | - polygon = new BMap.Polygon(polygonP, { | ||
| 255 | - | ||
| 256 | - // 线条显色 | ||
| 257 | - strokeColor : "blue", | ||
| 258 | - | ||
| 259 | - // 边线的宽度,以像素为单位。 | ||
| 260 | - strokeWeight : 2, | ||
| 261 | - | ||
| 262 | - // 边线透明度,取值范围0 - 1。 | ||
| 263 | - strokeOpacity : 0.5 | ||
| 264 | - }); | ||
| 265 | - | ||
| 266 | - // 增加地图覆盖物多边形 | ||
| 267 | - mapBValue.addOverlay(polygon); | ||
| 268 | - | ||
| 269 | - // 信息窗口属性 | ||
| 270 | - var opts_polygon = { | ||
| 271 | - | ||
| 272 | - // 信息窗口宽度 | ||
| 273 | - width : 200, | ||
| 274 | - | ||
| 275 | - // 信息窗口高度 | ||
| 276 | - height : 400, | ||
| 277 | - | ||
| 278 | - // 信息窗位置偏移值。 | ||
| 279 | - offset: new BMap.Size(500,20), | ||
| 280 | - | ||
| 281 | - //标题 | ||
| 282 | - title : '<h4 style="color:#FFFFFF">'+objStation.stationStationName+'站详情</h4>', | ||
| 283 | - | ||
| 284 | - //设置不允许信窗发送短息 | ||
| 285 | - enableMessage : false, | ||
| 286 | - | ||
| 287 | - //是否开启点击地图关闭信息窗口 | ||
| 288 | - enableCloseOnClick : false | ||
| 289 | - }; | ||
| 290 | - | ||
| 291 | - var markTypeStr = ''; | ||
| 292 | - | ||
| 293 | - if(objStation.stationRouteStationMark=='B') { | ||
| 294 | - | ||
| 295 | - markTypeStr='起点站'; | ||
| 296 | - | ||
| 297 | - }else if(objStation.stationRouteStationMark=='Z') { | ||
| 298 | - | ||
| 299 | - markTypeStr ='中途站'; | ||
| 300 | - | ||
| 301 | - | ||
| 302 | - }else if(objStation.stationRouteStationMark=='E') { | ||
| 303 | - | ||
| 304 | - markTypeStr='终点站'; | ||
| 305 | - | ||
| 306 | - } | ||
| 307 | - | ||
| 308 | - var htm = '<HR style="border:1 dashed #987cb9" width="100%" color=#987cb9 SIZE=1>'+ | ||
| 309 | - '<span style="color:#DDD;font-size: 15px;">站点名称:' + objStation.stationStationName + '</span>' + | ||
| 310 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">站点编码:' + objStation.stationStationCod + '</span>' + | ||
| 311 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">站点序号:' + objStation.stationRouteStationRouteCode + '</span>' + | ||
| 312 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">站点类型:' + markTypeStr + '</span>' + | ||
| 313 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">纬度坐标:' + objStation.stationBJwpoints + '</span>' + | ||
| 314 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">到站时间:' + objStation.stationRouteToTime + ' 分钟</span>' + | ||
| 315 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">到站距离:' + objStation.stationRouteDistances + ' 公里</span>' + | ||
| 316 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">范围半径:' + objStation.stationRadius + '</span>' + | ||
| 317 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">版本 号:' + objStation.stationRouteVersions + '</span>' + | ||
| 318 | - '<span class="help-block" style="width: 100%;font-size: 15px;;color:#DDD;'+ | ||
| 319 | - 'overflow: hidden; white-space: nowrap; text-overflow: ellipsis; " title="'+ | ||
| 320 | - objStation.stationRouteDescriptions +'" >说明/描述:' + objStation.stationRouteDescriptions + '</span>' ; | ||
| 321 | - | ||
| 322 | - // 创建信息窗口 | ||
| 323 | - var infoWindow_target = new BMap.InfoWindow(htm, opts_polygon); | ||
| 324 | - // 自定义标注物图片 | ||
| 325 | - var icon_target = new BMap.Icon('/pages/base/stationroute/css/img/cz.png',new BMap.Size(20, 20)); | ||
| 326 | - | ||
| 327 | - // 创建点 | ||
| 328 | - marker = new BMap.Marker(pointPolygon,{icon : icon_target}); | ||
| 329 | - | ||
| 330 | - // 把标注添物加到地图上 | ||
| 331 | - mapBValue.addOverlay(marker); | ||
| 332 | - | ||
| 333 | - // 是否在平移过程中禁止动画。(自1.2新增) | ||
| 334 | - var PanOptions_ ={noAnimation :true}; | ||
| 335 | - | ||
| 336 | - // 将地图的中心点更改为给定的点。 | ||
| 337 | - mapBValue.panTo(pointPolygon,PanOptions_); | ||
| 338 | - | ||
| 339 | - // 将地图在水平位置上移动x像素,垂直位置上移动y像素。 | ||
| 340 | - mapBValue.panBy(10,-150,PanOptions_); | ||
| 341 | - | ||
| 342 | - //开启信息窗口 | ||
| 343 | - mapBValue.openInfoWindow(infoWindow_target,pointPolygon); | ||
| 344 | - | ||
| 345 | - } | ||
| 346 | - | ||
| 347 | - }, | ||
| 348 | - | ||
| 349 | - editPolyUpline : function() { | ||
| 350 | - // 禁止覆盖物在map.clearOverlays方法中被清除。(自 1.1 新增) | ||
| 351 | - polyUpline.disableMassClear(); | ||
| 352 | - WorldsBMap.clearMarkAndOverlays(); | ||
| 353 | - // 允许覆盖物在map.clearOverlays方法中被清除。(自 1.1 新增) | ||
| 354 | - polyUpline.enableMassClear(); | ||
| 355 | - // 开启线路编辑 | ||
| 356 | - polyUpline.enableEditing(); | ||
| 357 | - // 添加双击折线保存事件 | ||
| 358 | - polyUpline.addEventListener('dblclick',function(e) { | ||
| 359 | - // 关闭 | ||
| 360 | - layer.closeAll(); | ||
| 361 | - polyUpline.disableEditing(); | ||
| 362 | - // 获取折线坐标集合 | ||
| 363 | - var editPloyLineArray = polyUpline.getPath(); | ||
| 364 | - EditSectionObj.setEitdBsectionVector(JSON.stringify(editPloyLineArray)); | ||
| 365 | - polyUpline= ''; | ||
| 366 | - // 加载修改路段弹出层mobal页面 | ||
| 367 | - $.get('editsection.html', function(m){ | ||
| 368 | - $(pjaxContainer).append(m); | ||
| 369 | - $('#edit_section_mobal').trigger('editSectionMobal_show', [WorldsBMap,GetAjaxData,EditSectionObj,PublicFunctions]); | ||
| 370 | - }); | ||
| 371 | - }); | ||
| 372 | - }, | ||
| 373 | - | ||
| 374 | - // 画圆 | ||
| 375 | - pointsCircle : function(objStation) { | ||
| 376 | - | ||
| 377 | - // 将视图切换到指定的缩放等级,中心点坐标不变。注意:当有信息窗口在地图上打开时,地图缩放将保证信息窗口所在的坐标位置不动。(自1.2新增) | ||
| 378 | - mapBValue.setZoom(16); | ||
| 379 | - | ||
| 380 | - if(objStation) { | ||
| 381 | - | ||
| 382 | - // 清除地图覆盖物 | ||
| 383 | - mapBValue.clearOverlays(); | ||
| 384 | - | ||
| 385 | - // 获取中心坐标点字符串分割 | ||
| 386 | - var BJwpoints = objStation.stationBJwpoints.split(' '); | ||
| 387 | - | ||
| 388 | - // 中心坐标点 | ||
| 389 | - var point = new BMap.Point(BJwpoints[0], BJwpoints[1]); | ||
| 390 | - | ||
| 391 | - //创建圆 | ||
| 392 | - circle = new BMap.Circle(point,objStation.stationRadius,{strokeColor:"blue", strokeWeight:2, strokeOpacity:0.5}); | ||
| 393 | - | ||
| 394 | - // 允许覆盖物在map.clearOverlays方法中被清除 | ||
| 395 | - circle.enableMassClear(); | ||
| 396 | - | ||
| 397 | - // 百度地图添加覆盖物圆 | ||
| 398 | - mapBValue.addOverlay(circle); | ||
| 399 | - | ||
| 400 | - // 信息窗口参数属性 | ||
| 401 | - var opts = { | ||
| 402 | - | ||
| 403 | - // 信息窗口宽度 | ||
| 404 | - width : 200, | ||
| 405 | - | ||
| 406 | - // 信息窗口高度 | ||
| 407 | - height : 450, | ||
| 408 | - | ||
| 409 | - // 信息窗位置偏移值。 | ||
| 410 | - offset: new BMap.Size(500,120), | ||
| 411 | - | ||
| 412 | - //标题 | ||
| 413 | - title : '<h4 style="color:#FFFFFF">'+objStation.stationStationName+'站详情</h4>', | ||
| 414 | - | ||
| 415 | - //设置不允许信窗发送短息 | ||
| 416 | - enableMessage : false, | ||
| 417 | - | ||
| 418 | - //是否开启点击地图关闭信息窗口 | ||
| 419 | - enableCloseOnClick : false, | ||
| 420 | - | ||
| 421 | - // 是否开启信息窗口打开时地图自动移动(默认开启)。(自 1.1 新增) | ||
| 422 | - enableAutoPan:false | ||
| 423 | - }; | ||
| 424 | - | ||
| 425 | - var markTypeStr = ''; | ||
| 426 | - | ||
| 427 | - if(objStation.stationRouteStationMark=='B') { | ||
| 428 | - | ||
| 429 | - markTypeStr='起点站'; | ||
| 430 | - | ||
| 431 | - }else if(objStation.stationRouteStationMark=='Z') { | ||
| 432 | - | ||
| 433 | - markTypeStr ='中途站'; | ||
| 434 | - | ||
| 435 | - | ||
| 436 | - }else if(objStation.stationRouteStationMark=='E') { | ||
| 437 | - | ||
| 438 | - markTypeStr='终点站'; | ||
| 439 | - | ||
| 440 | - } | ||
| 441 | - | ||
| 442 | - var htm = '<HR style="border:1 dashed #987cb9" width="100%" color=#987cb9 SIZE=1>'+ | ||
| 443 | - '<span style="color:#DDD;font-size: 15px;">站点名称:' + objStation.stationStationName + '</span>' + | ||
| 444 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">站点编码:' + objStation.stationStationCod + '</span>' + | ||
| 445 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">站点序号:' + objStation.stationRouteStationRouteCode + '</span>' + | ||
| 446 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">站点类型:' + markTypeStr + '</span>' + | ||
| 447 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">纬度坐标:' + objStation.stationBJwpoints + '</span>' + | ||
| 448 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">到站时间:' + objStation.stationRouteToTime + ' 分钟</span>' + | ||
| 449 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">到站距离:' + objStation.stationRouteDistances + ' 公里</span>' + | ||
| 450 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">范围半径:' + objStation.stationRadius + '</span>' + | ||
| 451 | - '<span class="help-block" style="color:#DDD;font-size: 15px;">版本 号:' + objStation.stationRouteVersions + '</span>' + | ||
| 452 | - '<span class="help-block" style="width: 100%;font-size: 15px;;color:#DDD;'+ | ||
| 453 | - 'overflow: hidden; white-space: nowrap; text-overflow: ellipsis; " title="'+ | ||
| 454 | - objStation.stationRouteDescriptions +'" >说明/描述:' + objStation.stationRouteDescriptions + '</span>' ; | ||
| 455 | - | ||
| 456 | - // 创建信息窗口 | ||
| 457 | - var infoWindow_target = new BMap.InfoWindow(htm, opts); | ||
| 458 | - // 自定义标注物图片 | ||
| 459 | - var icon_target = new BMap.Icon('/pages/base/stationroute/css/img/cz.png',new BMap.Size(20, 20)); | ||
| 460 | - | ||
| 461 | - // 创建点 | ||
| 462 | - marker = new BMap.Marker(point,{icon : icon_target}); | ||
| 463 | - | ||
| 464 | - // 把标注添物加到地图上 | ||
| 465 | - mapBValue.addOverlay(marker); | ||
| 466 | - | ||
| 467 | - setTimeout(function(){ | ||
| 468 | - //开启信息窗口 | ||
| 469 | - marker.openInfoWindow(infoWindow_target,point); | ||
| 470 | - | ||
| 471 | - },100); | ||
| 472 | - | ||
| 473 | - // 是否在平移过程中禁止动画。(自1.2新增) | ||
| 474 | - var PanOptions_ ={noAnimation :true}; | ||
| 475 | - | ||
| 476 | - // 将地图的中心点更改为给定的点。 | ||
| 477 | - mapBValue.panTo(point,PanOptions_); | ||
| 478 | - | ||
| 479 | - mapBValue.panBy(10,-200,PanOptions_); | ||
| 480 | - | ||
| 481 | - // 添加标志物监听事件 | ||
| 482 | - marker.addEventListener("click",function() { | ||
| 483 | - | ||
| 484 | - //开启信息窗口 | ||
| 485 | - marker.openInfoWindow(infoWindow_target,point); | ||
| 486 | - | ||
| 487 | - }); | ||
| 488 | - | ||
| 489 | - } | ||
| 490 | - | ||
| 491 | - }, | ||
| 492 | - | ||
| 493 | - // 根据地理名称获取百度经纬度坐标 | ||
| 494 | - localSearchFromAdreesToPoint: function(Address,callback) { | ||
| 495 | - | ||
| 496 | - // 创建一个搜索类实例 | ||
| 497 | - var localSearch = new BMap.LocalSearch(mapBValue); | ||
| 498 | - | ||
| 499 | - // 检索完成后的回调函数。 | ||
| 500 | - localSearch.setSearchCompleteCallback(function (searchResult) { | ||
| 501 | - | ||
| 502 | - var resultPoints = ''; | ||
| 503 | - | ||
| 504 | - if(searchResult) { | ||
| 505 | - | ||
| 506 | - // 返回索引指定的结果。索引0表示第1条结果 | ||
| 507 | - var poi = searchResult.getPoi(0); | ||
| 508 | - | ||
| 509 | - if(poi) { | ||
| 510 | - | ||
| 511 | - //获取经度和纬度 | ||
| 512 | - resultPoints = poi.point.lng + ' ' + poi.point.lat; | ||
| 513 | - | ||
| 514 | - callback && callback(resultPoints); | ||
| 515 | - | ||
| 516 | - }else { | ||
| 517 | - | ||
| 518 | - callback && callback(false); | ||
| 519 | - | ||
| 520 | - } | ||
| 521 | - | ||
| 522 | - }else { | ||
| 523 | - | ||
| 524 | - callback && callback(false); | ||
| 525 | - } | ||
| 526 | - | ||
| 527 | - }); | ||
| 528 | - | ||
| 529 | - // 根据检索词发起检索。 | ||
| 530 | - localSearch.search(Address); | ||
| 531 | - | ||
| 532 | - }, | ||
| 533 | - | ||
| 534 | - // 编辑图形 | ||
| 535 | - editShapes : function(editStationName,stationShapesTypeV,mindex) { | ||
| 536 | - | ||
| 537 | - // 关闭信息窗口 | ||
| 538 | - marker.closeInfoWindow(); | ||
| 539 | - | ||
| 540 | - // 清除marker | ||
| 541 | - mapBValue.removeOverlay(marker); | ||
| 542 | - | ||
| 543 | - // 编辑圆 | ||
| 544 | - if(stationShapesTypeV =='r') { | ||
| 545 | - | ||
| 546 | - // 开启编辑功能 | ||
| 547 | - circle.enableEditing(); | ||
| 548 | - | ||
| 549 | - // 编辑圆监听事件 | ||
| 550 | - circle.addEventListener('dblclick',function() { | ||
| 551 | - | ||
| 552 | - // 关闭提示弹出层 | ||
| 553 | - layer.close(mindex); | ||
| 554 | - | ||
| 555 | - // 返回圆形的半径,单位为米。 | ||
| 556 | - var newRadius = circle.getRadius(); | ||
| 557 | - | ||
| 558 | - // 返回圆形的中心点坐标。 | ||
| 559 | - var newCenter = circle.getCenter().lng + ' ' + circle.getCenter().lat; | ||
| 560 | - | ||
| 561 | - var centre_New = [{potion:{lng:circle.getCenter().lng,lat:circle.getCenter().lat}}]; | ||
| 562 | - | ||
| 563 | - /** 设置修改站点集合对象站点中心点百度坐标属性值 @param:<bJwpoints:中心点百度坐标) */ | ||
| 564 | - EditStationObj.setEitdStationBJwpoints(newCenter); | ||
| 565 | - | ||
| 566 | - /** 设置修改站点集合对象范围图形类型属性值 @param:<shapesType:范围图形类型) */ | ||
| 567 | - EditStationObj.setEitdStationShapesType('r'); | ||
| 568 | - | ||
| 569 | - /** 设置修改站点集合对象圆形半径属性值 @param:<radius:圆形半径) */ | ||
| 570 | - EditStationObj.setEitdStationRadius(Math.round(newRadius)); | ||
| 571 | - | ||
| 572 | - /** 设置修改站点集合对象图形百度坐标集合属性值 @param:<bPolygonGrid:图形百度坐标集合) */ | ||
| 573 | - EditStationObj.setEitdBPolygonGrid(''); | ||
| 574 | - | ||
| 575 | - // 加载编辑页面 | ||
| 576 | - $.get('edit.html', function(m){ | ||
| 577 | - | ||
| 578 | - $(pjaxContainer).append(m); | ||
| 579 | - | ||
| 580 | - $('#edit_station_mobal').trigger('editSelectMobal_show', [WorldsBMap,GetAjaxData,EditStationObj,LineObj,PublicFunctions]); | ||
| 581 | - | ||
| 582 | - }); | ||
| 583 | - | ||
| 584 | - }); | ||
| 585 | - | ||
| 586 | - // 编辑多变行 | ||
| 587 | - }else if(stationShapesTypeV =='d') { | ||
| 588 | - | ||
| 589 | - // 开启编辑功能(自 1.1 新增) | ||
| 590 | - polygon.enableEditing(); | ||
| 591 | - | ||
| 592 | - // 添加多变行编辑事件 | ||
| 593 | - polygon.addEventListener('dblclick',function(e) { | ||
| 594 | - | ||
| 595 | - // 获取编辑的多边形对象 | ||
| 596 | - var edit_pointE = polygon; | ||
| 597 | - | ||
| 598 | - var edit_bPloygonGrid = ""; | ||
| 599 | - | ||
| 600 | - var editPolyGonLen_ = edit_pointE.getPath().length; | ||
| 601 | - | ||
| 602 | - for(var k =0;k<editPolyGonLen_;k++) { | ||
| 603 | - | ||
| 604 | - if(k==0) { | ||
| 605 | - | ||
| 606 | - edit_bPloygonGrid = edit_pointE.getPath()[k].lng + ' ' + edit_pointE.getPath()[k].lat; | ||
| 607 | - | ||
| 608 | - }else { | ||
| 609 | - | ||
| 610 | - edit_bPloygonGrid = edit_bPloygonGrid + ',' + edit_pointE.getPath()[k].lng + ' ' + edit_pointE.getPath()[k].lat; | ||
| 611 | - | ||
| 612 | - } | ||
| 613 | - | ||
| 614 | - } | ||
| 615 | - | ||
| 616 | - edit_bPloygonGrid = edit_bPloygonGrid + ',' + edit_pointE.getPath()[0].lng + ' ' + edit_pointE.getPath()[0].lat; | ||
| 617 | - | ||
| 618 | - // 多边形中心点 | ||
| 619 | - var centre_points = edit_pointE.getBounds().getCenter().lng + ' ' + edit_pointE.getBounds().getCenter().lat; | ||
| 620 | - | ||
| 621 | - /** 设置修改站点集合对象站点中心点百度坐标属性值 @param:<bJwpoints:中心点百度坐标) */ | ||
| 622 | - EditStationObj.setEitdStationBJwpoints(centre_points); | ||
| 623 | - | ||
| 624 | - /** 设置修改站点集合对象范围图形类型属性值 @param:<shapesType:范围图形类型) */ | ||
| 625 | - EditStationObj.setEitdStationShapesType('d'); | ||
| 626 | - | ||
| 627 | - /** 设置修改站点集合对象圆形半径属性值 @param:<radius:圆形半径) */ | ||
| 628 | - EditStationObj.setEitdStationRadius(''); | ||
| 629 | - | ||
| 630 | - /** 设置修改站点集合对象图形百度坐标集合属性值 @param:<bPolygonGrid:图形百度坐标集合) */ | ||
| 631 | - EditStationObj.setEitdBPolygonGrid(edit_bPloygonGrid); | ||
| 632 | - | ||
| 633 | - $.get('edit.html', function(m){ | ||
| 634 | - | ||
| 635 | - $(pjaxContainer).append(m); | ||
| 636 | - | ||
| 637 | - $('#edit_station_mobal').trigger('editSelectMobal_show', [WorldsBMap,GetAjaxData,EditStationObj,LineObj,PublicFunctions]); | ||
| 638 | - | ||
| 639 | - }); | ||
| 640 | - | ||
| 641 | - }); | ||
| 642 | - | ||
| 643 | - } | ||
| 644 | - | ||
| 645 | - }, | ||
| 646 | - | ||
| 647 | - // 在地图上画出上行线路走向 | ||
| 648 | - drawingUpline : function (polylineArray,polyline_center,data) { | ||
| 649 | - /*WorldsBMap.clearMarkAndOverlays();*/ | ||
| 650 | - polyUpline = ''; | ||
| 651 | - // 创建线路走向 | ||
| 652 | - polyUpline = new BMap.Polyline(polylineArray, {strokeColor : "blue",strokeWeight : 6,strokeOpacity : 0.5}); | ||
| 653 | - // polyUpline.data = data; | ||
| 654 | - // 把折线添加到地图上 | ||
| 655 | - mapBValue.addOverlay(polyUpline); | ||
| 656 | - /*var ceter_index = Math.round(resultdata.length / 2); | ||
| 657 | - | ||
| 658 | - var ceterPointsStr = resultdata[ceter_index].bJwpoints; | ||
| 659 | - | ||
| 660 | - var ceterPointsArray = ceterPointsStr.split(' '); | ||
| 661 | - | ||
| 662 | - var polyline_center = new BMap.Point(ceterPointsArray[0],ceterPointsArray[1]);*/ | ||
| 663 | - var PanOptions_ ={noAnimation :true}; | ||
| 664 | - mapBValue.reset(); | ||
| 665 | - mapBValue.panTo(polyline_center,PanOptions_); | ||
| 666 | - mapBValue.panBy(500,-510,PanOptions_); | ||
| 667 | - mapBValue.setZoom(14); | ||
| 668 | - }, | ||
| 669 | - | ||
| 670 | - //在地图上画出公交位置。 | ||
| 671 | - drawingBus :function(lon,lat){ | ||
| 672 | - var point = new BMap.Point(lon,lat); | ||
| 673 | - var myIcon = new BMap.Icon("/pages/excep/img/bus.png", new BMap.Size(300,157)); | ||
| 674 | - var marker = new BMap.Marker(point,{icon:myIcon}); // 创建标注 | ||
| 675 | - mapBValue.addOverlay(marker); | ||
| 676 | - marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画 | ||
| 677 | - }, | ||
| 678 | - | ||
| 679 | - // 在地图上画出上行线路走向 | ||
| 680 | - drawingUpline01 : function (polylineArray,polyline_center,data) { | ||
| 681 | - var polyUpline01 = 'polyline' + '_' + data.sectionrouteId; | ||
| 682 | - // 创建线路走向 | ||
| 683 | - polyUpline01 = new BMap.Polyline(polylineArray, {strokeColor : "blue",strokeWeight : 6,strokeOpacity : 0.5}); | ||
| 684 | - polyUpline01.data = data; | ||
| 685 | - // 把折线添加到地图上 | ||
| 686 | - mapBValue.addOverlay(polyUpline01); | ||
| 687 | - polyUpline01.addEventListener('click',function(e) { | ||
| 688 | - if(WorldsBMap.getIsEditStatus()) { | ||
| 689 | - layer.msg('请先保存正在编辑的路段信息...'); | ||
| 690 | - return false; | ||
| 691 | - } | ||
| 692 | - polyUpline01.enableEditing(); | ||
| 693 | - WorldsBMap.setIsEditStatus(true); | ||
| 694 | - }); | ||
| 695 | - // 添加双击折线保存事件 | ||
| 696 | - polyUpline01.addEventListener('dblclick',function(e) { | ||
| 697 | - WorldsBMap.setIsEditStatus(false); | ||
| 698 | - // 关闭 | ||
| 699 | - layer.closeAll(); | ||
| 700 | - polyUpline01.disableEditing(); | ||
| 701 | - EditSectionObj.setEitdSection(polyUpline01.data); | ||
| 702 | - // 获取折线坐标集合 | ||
| 703 | - var editPloyLineArray = polyUpline01.getPath(); | ||
| 704 | - EditSectionObj.setEitdBsectionVector(JSON.stringify(editPloyLineArray)); | ||
| 705 | - // polyUpline= ''; | ||
| 706 | - // 加载修改路段弹出层mobal页面 | ||
| 707 | - $.get('editsection.html', function(m){ | ||
| 708 | - $(pjaxContainer).append(m); | ||
| 709 | - $('#edit_section_mobal').trigger('editSectionMobal_show', [WorldsBMap,GetAjaxData,EditSectionObj,PublicFunctions]); | ||
| 710 | - }); | ||
| 711 | - }); | ||
| 712 | - var PanOptions_ ={noAnimation :true}; | ||
| 713 | - mapBValue.reset(); | ||
| 714 | - mapBValue.panTo(polyline_center,PanOptions_); | ||
| 715 | - mapBValue.panBy(500,-510,PanOptions_); | ||
| 716 | - mapBValue.setZoom(14); | ||
| 717 | - }, | ||
| 718 | - | ||
| 719 | - /** 在地图上画点 @param:<point_center:中心坐标点> */ | ||
| 720 | - drawingUpStationPoint : function(point_center,stationName,s) { | ||
| 721 | - | ||
| 722 | - // 自定义标注物图片 | ||
| 723 | - var icon_target = new BMap.Icon('/pages/base/stationroute/css/img/gjzd.png',new BMap.Size(10, 10)); | ||
| 724 | - | ||
| 725 | - var html2 = '<div style="position: absolute; margin: 0pt; padding: 0pt; width: 160px; height: 26px; left: -10px; top: -35px; overflow: hidden;">' | ||
| 726 | - + '<img class="rm3_image" style="border:none;left:0px; top:0px; position:absolute;" src="/pages/base/stationroute/css/img/back160.png">' | ||
| 727 | - + '</div>' | ||
| 728 | - + '<label class=" BMapLabel" unselectable="on" style="position: absolute; -moz-user-select: none; display: inline; cursor: inherit; border: 0px none; padding: 2px 1px 1px; white-space: nowrap; font: 12px arial,simsun; z-index: 80; color: rgb(255, 102, 0); left: 15px; top: -35px;"><span style="float: left; color: #fdfdfd; margin-left: -22px; font-size: 6px;">'+ s+'</span>'+ stationName+'</label>'; | ||
| 729 | - | ||
| 730 | - | ||
| 731 | - var myRichMarker1 = new BMapLib.RichMarker(html2, point_center,{ | ||
| 732 | - "anchor" : new BMap.Size(-10,8), | ||
| 733 | - "enableDragging" : true}); | ||
| 734 | - | ||
| 735 | - | ||
| 736 | - myRichMarker1.disableDragging(); | ||
| 737 | - mapBValue.addOverlay(myRichMarker1); | ||
| 738 | - | ||
| 739 | - | ||
| 740 | - // 创建标注物 | ||
| 741 | - marker = new BMap.Marker(point_center,{icon : icon_target}); | ||
| 742 | - | ||
| 743 | - // 允许覆盖物在map.clearOverlays方法中被清除。 | ||
| 744 | - marker.enableMassClear(); | ||
| 745 | - | ||
| 746 | - mapBValue.addOverlay(marker); | ||
| 747 | - }, | ||
| 748 | - | ||
| 749 | - // 站点名称获取百度坐标(手动规划) | ||
| 750 | - stationsNameToPoints : function(arra,callback) { | ||
| 751 | - // 获取长度 | ||
| 752 | - var len = arra.length; | ||
| 753 | - var stationList = []; | ||
| 754 | - (function(){ | ||
| 755 | - if (!arguments.callee.count) { | ||
| 756 | - arguments.callee.count = 0; | ||
| 757 | - } | ||
| 758 | - arguments.callee.count++; | ||
| 759 | - var index = parseInt(arguments.callee.count) - 1; | ||
| 760 | - if (index >= len) { | ||
| 761 | - callback && callback(stationList); | ||
| 762 | - return ; | ||
| 763 | - } | ||
| 764 | - var f = arguments.callee; | ||
| 765 | - if(arra[index].name!=''){ | ||
| 766 | - var localSearch = new BMap.LocalSearch(mapBValue); | ||
| 767 | - localSearch.search(arra[index].name); | ||
| 768 | - localSearch.setSearchCompleteCallback(function (searchResult) { | ||
| 769 | - var poi = searchResult.getPoi(0); | ||
| 770 | - if(poi) { | ||
| 771 | - stationList.push({name:arra[index].name.replace('公交车站',''),wgs:arra[index].wgs,potion:{lng:poi.point.lng,lat:poi.point.lat}}); | ||
| 772 | - }else { | ||
| 773 | - stationList.push({name:arra[index].name.replace('公交车站',''),wgs:arra[index].wgs,potion:{lng:arra[index].wgs.x,lat:arra[index].wgs.y}}); | ||
| 774 | - } | ||
| 775 | - f(); | ||
| 776 | - }); | ||
| 777 | - }else { | ||
| 778 | - f(); | ||
| 779 | - } | ||
| 780 | - })(); | ||
| 781 | - }, | ||
| 782 | - | ||
| 783 | - // 根据坐标点获取两点之间的时间与距离(手动规划) | ||
| 784 | - getDistanceAndTotime : function(stationList,cb) { | ||
| 785 | - | ||
| 786 | - stationList[0].distance = ''; | ||
| 787 | - | ||
| 788 | - stationList[0].duration = ''; | ||
| 789 | - | ||
| 790 | - // var sectionList = []; | ||
| 791 | - | ||
| 792 | - // 获取长度 | ||
| 793 | - var len = stationList.length; | ||
| 794 | - | ||
| 795 | - (function(){ | ||
| 796 | - | ||
| 797 | - if (!arguments.callee.count) { | ||
| 798 | - | ||
| 799 | - arguments.callee.count = 0; | ||
| 800 | - | ||
| 801 | - } | ||
| 802 | - | ||
| 803 | - arguments.callee.count++; | ||
| 804 | - | ||
| 805 | - var index = parseInt(arguments.callee.count) - 1; | ||
| 806 | - | ||
| 807 | - if (index >= len-1) { | ||
| 808 | - | ||
| 809 | - // cb && cb(stationList,sectionList); | ||
| 810 | - cb && cb(stationList); | ||
| 811 | - return; | ||
| 812 | - } | ||
| 813 | - | ||
| 814 | - var f = arguments.callee; | ||
| 815 | - | ||
| 816 | - var poiOne = new BMap.Point(stationList[index].potion.lng,stationList[index].potion.lat); | ||
| 817 | - | ||
| 818 | - var poiTwo = new BMap.Point(stationList[index+1].potion.lng,stationList[index+1].potion.lat); | ||
| 819 | - | ||
| 820 | - var transit = new BMap.TransitRoute(mapBValue, {renderOptions: {map: mapBValue},onSearchComplete: searchComplete}); | ||
| 821 | - | ||
| 822 | - transit.search(poiOne,poiTwo); | ||
| 823 | - | ||
| 824 | - function searchComplete(results){ | ||
| 825 | - | ||
| 826 | - var plan = results.getPlan(0); | ||
| 827 | - | ||
| 828 | - if (transit.getStatus() != BMAP_STATUS_SUCCESS){ | ||
| 829 | - | ||
| 830 | - stationList[index+1].distance = ''; | ||
| 831 | - | ||
| 832 | - stationList[index+1].duration = ''; | ||
| 833 | - | ||
| 834 | - // sectionList.push({sectionName:stationList[index].name+stationList[index+1].name,points:''}); | ||
| 835 | - | ||
| 836 | - }else { | ||
| 837 | - | ||
| 838 | - stationList[index+1].distance = plan.getDistance(true); | ||
| 839 | - | ||
| 840 | - stationList[index+1].duration = plan.getDuration(true); | ||
| 841 | - | ||
| 842 | - // var line = plan.getRoute(0); | ||
| 843 | - | ||
| 844 | - // sectionList.push({sectionName:stationList[index].name+stationList[index+1].name,points:line.getPath()}); | ||
| 845 | - | ||
| 846 | - } | ||
| 847 | - | ||
| 848 | - f(); | ||
| 849 | - } | ||
| 850 | - | ||
| 851 | - })(); | ||
| 852 | - | ||
| 853 | - }, | ||
| 854 | - | ||
| 855 | - // 根据坐标点获取两点之间的折线路段(手动规划) | ||
| 856 | - getSectionListPlonly : function(stationsPoint,cb) { | ||
| 857 | - | ||
| 858 | - var len = stationsPoint.length; | ||
| 859 | - | ||
| 860 | - var sectionList = []; | ||
| 861 | - | ||
| 862 | - (function(){ | ||
| 863 | - | ||
| 864 | - if (!arguments.callee.count) { | ||
| 865 | - | ||
| 866 | - arguments.callee.count = 0; | ||
| 867 | - | ||
| 868 | - } | ||
| 869 | - | ||
| 870 | - arguments.callee.count++; | ||
| 871 | - | ||
| 872 | - var index = parseInt(arguments.callee.count) - 1; | ||
| 873 | - | ||
| 874 | - if (index >= len-1 ) { | ||
| 875 | - | ||
| 876 | - cb && cb(sectionList); | ||
| 877 | - return; | ||
| 878 | - } | ||
| 879 | - | ||
| 880 | - var f = arguments.callee; | ||
| 881 | - | ||
| 882 | - var poiOne = new BMap.Point(stationsPoint[index].potion.lng,stationsPoint[index].potion.lat); | ||
| 883 | - | ||
| 884 | - var poiTwo = new BMap.Point(stationsPoint[index+1].potion.lng,stationsPoint[index+1].potion.lat); | ||
| 885 | - | ||
| 886 | - /* var transit = new BMap.TransitRoute(mapB, {renderOptions: {map: mapB},onPolylinesSet: searchPolylinesSet});*/ | ||
| 887 | - | ||
| 888 | - var transit = new BMap.DrivingRoute(mapBValue, {renderOptions: {map: mapBValue},onPolylinesSet: searchPolylinesSet}); | ||
| 889 | - | ||
| 890 | - function searchPolylinesSet(results){ | ||
| 891 | - | ||
| 892 | - if (transit.getStatus() != BMAP_STATUS_SUCCESS){ | ||
| 893 | - | ||
| 894 | - | ||
| 895 | - }else { | ||
| 896 | - | ||
| 897 | - var sectionArrayList = []; | ||
| 898 | - for (i = 0; i < results.length; i++){ | ||
| 899 | - | ||
| 900 | - // console.log(results[i].getPolyline().getPath()); | ||
| 901 | - sectionArrayList = sectionArrayList.concat(results[i].getPolyline().getPath()); | ||
| 902 | - | ||
| 903 | - } | ||
| 904 | - | ||
| 905 | - var sectionName = stationsPoint[index].name + '至' + stationsPoint[index+1].name; | ||
| 906 | - | ||
| 907 | - sectionList.push({sectionName:sectionName,points:sectionArrayList}); | ||
| 908 | - | ||
| 909 | - } | ||
| 910 | - | ||
| 911 | - f(); | ||
| 912 | - } | ||
| 913 | - | ||
| 914 | - transit.search(poiOne,poiTwo); | ||
| 915 | - | ||
| 916 | - })(); | ||
| 917 | - | ||
| 918 | - }, | ||
| 919 | - | ||
| 920 | - localtionPoint : function(stationNameV) { | ||
| 921 | - | ||
| 922 | - WorldsBMap.localSearchFromAdreesToPoint(stationNameV,function(Points) { | ||
| 923 | - | ||
| 924 | - if(Points) { | ||
| 925 | - | ||
| 926 | - var BJwpointsArray = Points.split(' '); | ||
| 927 | - | ||
| 928 | - var stationNameChangePoint = new BMap.Point(BJwpointsArray[0], BJwpointsArray[1]); | ||
| 929 | - | ||
| 930 | - var marker_stargt2 = new BMap.Marker(stationNameChangePoint); | ||
| 931 | - | ||
| 932 | - var PanOptions ={noAnimation :true}; | ||
| 933 | - | ||
| 934 | - mapBValue.panTo(stationNameChangePoint,PanOptions); | ||
| 935 | - | ||
| 936 | - mapBValue.panBy(0,-100); | ||
| 937 | - | ||
| 938 | - // 将标注添加到地图中 | ||
| 939 | - mapBValue.addOverlay(marker_stargt2); | ||
| 940 | - | ||
| 941 | - //跳动的动画 | ||
| 942 | - marker_stargt2.setAnimation(BMAP_ANIMATION_BOUNCE); | ||
| 943 | - | ||
| 944 | - } | ||
| 945 | - | ||
| 946 | - }); | ||
| 947 | - | ||
| 948 | - }, | ||
| 949 | - | ||
| 950 | - /** 系统规划抓去数据 @param lineNameValue:线路名称;i:方向*/ | ||
| 951 | - getBmapStationNames : function(lineNameValue,i,callback) { | ||
| 952 | - | ||
| 953 | - var busline = new BMap.BusLineSearch(mapBValue,{ | ||
| 954 | - | ||
| 955 | - // 设置公交列表查询后的回调函数。参数:rs: BusListResult类型 | ||
| 956 | - onGetBusListComplete:function(BusListResult) { | ||
| 957 | - | ||
| 958 | - // 如果不为空 | ||
| 959 | - if(BusListResult){ | ||
| 960 | - | ||
| 961 | - //获取第一个公交列表显示到map上 | ||
| 962 | - var fstLine = BusListResult.getBusListItem(i); | ||
| 963 | - | ||
| 964 | - /*if(fstLine==undefined){ | ||
| 965 | - | ||
| 966 | - layer.confirm('系统无法生成该线路【'+lineNameValue+'】的站点与路段!请点击返回选择其它方式规划', {btn : [ '返回' ],icon: 3, title:'提示' }, function(index){ | ||
| 967 | - | ||
| 968 | - layer.closeAll(); | ||
| 969 | - | ||
| 970 | - if(i==0){ | ||
| 971 | - | ||
| 972 | - $('#upToolsMobal').show(); | ||
| 973 | - | ||
| 974 | - }else if(i==1){ | ||
| 975 | - | ||
| 976 | - $('#downToolsMobal').show(); | ||
| 977 | - | ||
| 978 | - } | ||
| 979 | - | ||
| 980 | - return; | ||
| 981 | - }); | ||
| 982 | - | ||
| 983 | - }*/ | ||
| 984 | - | ||
| 985 | - if(fstLine==undefined){ | ||
| 986 | - | ||
| 987 | - | ||
| 988 | - callback && callback(null); | ||
| 989 | - | ||
| 990 | - } | ||
| 991 | - | ||
| 992 | - busline.getBusLine(fstLine); | ||
| 993 | - | ||
| 994 | - } | ||
| 995 | - | ||
| 996 | - }, | ||
| 997 | - | ||
| 998 | - //设置公交线路查询后的回调函数.参数:rs: BusLine类型 | ||
| 999 | - onGetBusLineComplete: function(BusLine){ | ||
| 1000 | - | ||
| 1001 | - // 如果不为空 | ||
| 1002 | - if(BusLine){ | ||
| 1003 | - | ||
| 1004 | - callback && callback(BusLine); | ||
| 1005 | - | ||
| 1006 | - } | ||
| 1007 | - | ||
| 1008 | - } | ||
| 1009 | - | ||
| 1010 | - }); | ||
| 1011 | - | ||
| 1012 | - busline.getBusList(lineNameValue); | ||
| 1013 | - | ||
| 1014 | - }, | ||
| 1015 | - | ||
| 1016 | - clearMarkAndOverlays : function() { | ||
| 1017 | - | ||
| 1018 | - // 清楚地图覆盖物 | ||
| 1019 | - mapBValue.clearOverlays(); | ||
| 1020 | - | ||
| 1021 | - mapBValue.removeOverlay(); | ||
| 1022 | - | ||
| 1023 | - } | ||
| 1024 | - | ||
| 1025 | - } | ||
| 1026 | - | ||
| 1027 | - return Bmap; | ||
| 1028 | - | 1 | +/** |
| 2 | + * 百度地图 | ||
| 3 | + * | ||
| 4 | + * - - - - - -》init:地图初始化 | ||
| 5 | + * | ||
| 6 | + * - - - - - -》lineInfoPanl:从百度地图抓去站点与路段数据 | ||
| 7 | + * | ||
| 8 | + * - - - - - -》getDistanceAndDuration:获取距离与时间 | ||
| 9 | + * | ||
| 10 | + * - - - - - -》pointsPolygon:地图画多边行 | ||
| 11 | + * | ||
| 12 | + * - - - - - -》pointsCircle:画圆 | ||
| 13 | + * | ||
| 14 | + * - - - - - -》localSearchFromAdreesToPoint:根据地理名称获取百度经纬度坐标 | ||
| 15 | + * | ||
| 16 | + * - - - - - -》drawingUpline:在地图上画出上行线路走向 | ||
| 17 | + * | ||
| 18 | + * - - - - - -》stationsNameToPoints:站点名称获取百度坐标(手动规划) | ||
| 19 | + * | ||
| 20 | + * - - - - - -》getDistanceAndTotime:根据坐标点获取两点之间的时间与距离(手动规划) | ||
| 21 | + * | ||
| 22 | + * - - - - - -》getSectionListPlonly:根据坐标点获取两点之间的折线路段(手动规划) | ||
| 23 | + */ | ||
| 24 | + | ||
| 25 | +var WorldsBMap = function () { | ||
| 26 | + | ||
| 27 | + /** WorldsBMap 全局变量定义 mapBValue:地图对象;polygon:多边形;polyUpline:走向折线;circle:圆 */ | ||
| 28 | + var mapBValue = '';polygon='',polyUpline='',circle='',iseditStatus = false; | ||
| 29 | + | ||
| 30 | + var Bmap = { | ||
| 31 | + | ||
| 32 | + init : function() { | ||
| 33 | + | ||
| 34 | + // 设置中心点, | ||
| 35 | + var CENTER_POINT = {lng : 121.528733,lat : 31.237425}; | ||
| 36 | + | ||
| 37 | + // 百度API Key | ||
| 38 | + var bdKey = 'IGGrr4UjwIYzatoCRFKEL8sT'; | ||
| 39 | + | ||
| 40 | + // 初始化百度地图 | ||
| 41 | + mapBValue = new BMap.Map("bmap_basic"); | ||
| 42 | + | ||
| 43 | + //中心点和缩放级别 | ||
| 44 | + mapBValue.centerAndZoom(new BMap.Point(CENTER_POINT.lng,CENTER_POINT.lat), 15); | ||
| 45 | + | ||
| 46 | + //启用地图拖拽事件,默认启用(可不写) | ||
| 47 | + mapBValue.enableDragging(); | ||
| 48 | + | ||
| 49 | + //启用地图滚轮放大缩小 | ||
| 50 | + mapBValue.enableScrollWheelZoom(); | ||
| 51 | + | ||
| 52 | + //禁用鼠标双击放大 | ||
| 53 | + mapBValue.disableDoubleClickZoom(); | ||
| 54 | + | ||
| 55 | + //启用键盘上下左右键移动地图 | ||
| 56 | + mapBValue.enableKeyboard(); | ||
| 57 | + | ||
| 58 | + return mapBValue; | ||
| 59 | + }, | ||
| 60 | + | ||
| 61 | + /** 获取地图对象 @return 地图对象map */ | ||
| 62 | + getmapBValue : function() { | ||
| 63 | + | ||
| 64 | + return mapBValue; | ||
| 65 | + | ||
| 66 | + }, | ||
| 67 | + | ||
| 68 | + getPolygon : function(){ | ||
| 69 | + | ||
| 70 | + return polygon; | ||
| 71 | + }, | ||
| 72 | + | ||
| 73 | + getPolyUpline : function() { | ||
| 74 | + | ||
| 75 | + return polyUpline; | ||
| 76 | + }, | ||
| 77 | + | ||
| 78 | + getCircle : function() { | ||
| 79 | + | ||
| 80 | + return circle; | ||
| 81 | + }, | ||
| 82 | + | ||
| 83 | + getIsEditStatus : function() { | ||
| 84 | + return iseditStatus; | ||
| 85 | + }, | ||
| 86 | + | ||
| 87 | + setIsEditStatus : function(v) { | ||
| 88 | + iseditStatus = v ; | ||
| 89 | + }, | ||
| 90 | + | ||
| 91 | + initDrawingManager: function(map,styleOptions) { | ||
| 92 | + | ||
| 93 | + }, | ||
| 94 | + | ||
| 95 | + getDrawingManagerObj : function() { | ||
| 96 | + | ||
| 97 | + return drawingManagerInitV; | ||
| 98 | + }, | ||
| 99 | + | ||
| 100 | + // 从百度地图抓去站点与路段数据 | ||
| 101 | + lineInfoPanl : function(lineNameValue,i,cb) { | ||
| 102 | + | ||
| 103 | + /** 根据线路名称与方向从百度地图获取站点与路段 @param lineNameValue:线路名称;i:方向<0:上行;1:下行> */ | ||
| 104 | + WorldsBMap.getBmapStationNames(lineNameValue,i,function(BusLine){ | ||
| 105 | + | ||
| 106 | + return cb && cb(BusLine); | ||
| 107 | + | ||
| 108 | + }); | ||
| 109 | + | ||
| 110 | + }, | ||
| 111 | + | ||
| 112 | + /** 获取距离与时间 @param <points:坐标点集合> */ | ||
| 113 | + getDistanceAndDuration : function(points,callback){ | ||
| 114 | + | ||
| 115 | + // 获取长度 | ||
| 116 | + var len = points.length; | ||
| 117 | + | ||
| 118 | + (function(){ | ||
| 119 | + | ||
| 120 | + if (!arguments.callee.count) { | ||
| 121 | + | ||
| 122 | + arguments.callee.count = 0; | ||
| 123 | + | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + arguments.callee.count++; | ||
| 127 | + | ||
| 128 | + var index = parseInt(arguments.callee.count) - 1; | ||
| 129 | + | ||
| 130 | + if (index >= len-1) { | ||
| 131 | + | ||
| 132 | + callback && callback(points); | ||
| 133 | + | ||
| 134 | + return; | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + // 当函数被调用时,它的arguments.callee对象就会指向自身,也就是一个对自己的引用。(当前正在执行的函数。) | ||
| 138 | + var f = arguments.callee; | ||
| 139 | + | ||
| 140 | + // 起点坐标 <坐标格式:40.056878,116.30815> | ||
| 141 | + var origin = points[index].potion.lat + ',' + points[index].potion.lng; | ||
| 142 | + | ||
| 143 | + // 终点坐标 <坐标格式:40.056878,116.30815> | ||
| 144 | + var destination = points[index+1].potion.lat + ',' + points[index+1].potion.lng; | ||
| 145 | + | ||
| 146 | + var region = '上海'; | ||
| 147 | + | ||
| 148 | + var origin_region = '上海'; | ||
| 149 | + | ||
| 150 | + var destination_region = '上海'; | ||
| 151 | + | ||
| 152 | + var output = 'json'; | ||
| 153 | + | ||
| 154 | + var ak_My = 'wjlITmXeCek5MxyU3ZUBkTeU8B0o0npk'; | ||
| 155 | + | ||
| 156 | + /** | ||
| 157 | + * origin:起点名称或经纬度; | ||
| 158 | + * | ||
| 159 | + * destination:终点名称或经纬度; | ||
| 160 | + * | ||
| 161 | + * origin_region:起始点所在城市,驾车导航时必填。 | ||
| 162 | + * | ||
| 163 | + * destination_region:终点所在城市,驾车导航时必填。 | ||
| 164 | + * | ||
| 165 | + * output :表示输出类型,可设置为xml或json,默认为xml。 | ||
| 166 | + * | ||
| 167 | + **/ | ||
| 168 | + var paramsB = {origin:origin,destination:destination,region:region,origin_region:origin_region,destination_region:destination_region,output:output,ak:ak_My}; | ||
| 169 | + | ||
| 170 | + /** @description :未认证开发者默认配额为:2000次/天。 */ | ||
| 171 | + $.ajax({ | ||
| 172 | + | ||
| 173 | + // 百度地图根据坐标获取两点之间的时间与距离 | ||
| 174 | + url: '//api.map.baidu.com/direction/v1?mode=transit', | ||
| 175 | + | ||
| 176 | + data: paramsB, | ||
| 177 | + | ||
| 178 | + dataType: 'jsonp', | ||
| 179 | + | ||
| 180 | + success: function(r){ | ||
| 181 | + | ||
| 182 | + if(r) { | ||
| 183 | + | ||
| 184 | + if(r.message=='ok') { | ||
| 185 | + | ||
| 186 | + if(r.result.taxi==null) { | ||
| 187 | + | ||
| 188 | + // 获取距离(单位:米) | ||
| 189 | + points[index+1].distance = 0; | ||
| 190 | + | ||
| 191 | + // 获取时间(单位:秒) | ||
| 192 | + points[index+1].duration = 0; | ||
| 193 | + | ||
| 194 | + }else { | ||
| 195 | + | ||
| 196 | + // 获取距离(单位:米) | ||
| 197 | + points[index+1].distance = r.result.taxi.distance; | ||
| 198 | + | ||
| 199 | + // 获取时间(单位:秒) | ||
| 200 | + points[index+1].duration = r.result.taxi.duration; | ||
| 201 | + | ||
| 202 | + } | ||
| 203 | + | ||
| 204 | + | ||
| 205 | + } | ||
| 206 | + | ||
| 207 | + } | ||
| 208 | + | ||
| 209 | + f(); | ||
| 210 | + } | ||
| 211 | + }); | ||
| 212 | + | ||
| 213 | + })(); | ||
| 214 | + | ||
| 215 | + }, | ||
| 216 | + | ||
| 217 | + // 地图画多边形 | ||
| 218 | + pointsPolygon : function(objStation) { | ||
| 219 | + | ||
| 220 | + // 将视图切换到指定的缩放等级,中心点坐标不变。注意:当有信息窗口在地图上打开时,地图缩放将保证信息窗口所在的坐标位置不动。(自1.2新增) | ||
| 221 | + mapBValue.setZoom(15); | ||
| 222 | + | ||
| 223 | + // 如果不为空 | ||
| 224 | + if(objStation) { | ||
| 225 | + | ||
| 226 | + // 获取中心点坐标字符串 | ||
| 227 | + var testpointStr = objStation.stationBJwpoints; | ||
| 228 | + | ||
| 229 | + // 按空格切割中心点坐标字符串 | ||
| 230 | + var BJwpointsPolygon = testpointStr.split(' '); | ||
| 231 | + | ||
| 232 | + // 中心点坐标 | ||
| 233 | + var pointPolygon = new BMap.Point(BJwpointsPolygon[0], BJwpointsPolygon[1]); | ||
| 234 | + | ||
| 235 | + // 获取多边形坐标字符串 | ||
| 236 | + var stationBPolygonGrid = objStation.stationBPolygonGrid; | ||
| 237 | + | ||
| 238 | + // 截取多边形坐标字符串 | ||
| 239 | + var stationBPolygonGridStr = stationBPolygonGrid.substring(9,stationBPolygonGrid.length-2); | ||
| 240 | + | ||
| 241 | + // 按逗号切割 | ||
| 242 | + var pointPolygonArray = stationBPolygonGridStr.split(','); | ||
| 243 | + | ||
| 244 | + // 多边形坐标集合 | ||
| 245 | + var polygonP = []; | ||
| 246 | + | ||
| 247 | + for(var v = 0;v<pointPolygonArray.length;v++) { | ||
| 248 | + | ||
| 249 | + polygonP.push(new BMap.Point(pointPolygonArray[v].split(" ")[0],pointPolygonArray[v].split(" ")[1])); | ||
| 250 | + | ||
| 251 | + } | ||
| 252 | + | ||
| 253 | + // 画多边形 | ||
| 254 | + polygon = new BMap.Polygon(polygonP, { | ||
| 255 | + | ||
| 256 | + // 线条显色 | ||
| 257 | + strokeColor : "blue", | ||
| 258 | + | ||
| 259 | + // 边线的宽度,以像素为单位。 | ||
| 260 | + strokeWeight : 2, | ||
| 261 | + | ||
| 262 | + // 边线透明度,取值范围0 - 1。 | ||
| 263 | + strokeOpacity : 0.5 | ||
| 264 | + }); | ||
| 265 | + | ||
| 266 | + // 增加地图覆盖物多边形 | ||
| 267 | + mapBValue.addOverlay(polygon); | ||
| 268 | + | ||
| 269 | + // 信息窗口属性 | ||
| 270 | + var opts_polygon = { | ||
| 271 | + | ||
| 272 | + // 信息窗口宽度 | ||
| 273 | + width : 200, | ||
| 274 | + | ||
| 275 | + // 信息窗口高度 | ||
| 276 | + height : 400, | ||
| 277 | + | ||
| 278 | + // 信息窗位置偏移值。 | ||
| 279 | + offset: new BMap.Size(500,20), | ||
| 280 | + | ||
| 281 | + //标题 | ||
| 282 | + title : '<h4 style="color:#FFFFFF">'+objStation.stationStationName+'站详情</h4>', | ||
| 283 | + | ||
| 284 | + //设置不允许信窗发送短息 | ||
| 285 | + enableMessage : false, | ||
| 286 | + | ||
| 287 | + //是否开启点击地图关闭信息窗口 | ||
| 288 | + enableCloseOnClick : false | ||
| 289 | + }; | ||
| 290 | + | ||
| 291 | + var markTypeStr = ''; | ||
| 292 | + | ||
| 293 | + if(objStation.stationRouteStationMark=='B') { | ||
| 294 | + | ||
| 295 | + markTypeStr='起点站'; | ||
| 296 | + | ||
| 297 | + }else if(objStation.stationRouteStationMark=='Z') { | ||
| 298 | + | ||
| 299 | + markTypeStr ='中途站'; | ||
| 300 | + | ||
| 301 | + | ||
| 302 | + }else if(objStation.stationRouteStationMark=='E') { | ||
| 303 | + | ||
| 304 | + markTypeStr='终点站'; | ||
| 305 | + | ||
| 306 | + } | ||
| 307 | + | ||
| 308 | + var htm = '<HR style="border:1 dashed #987cb9" width="100%" color=#987cb9 SIZE=1>'+ | ||
| 309 | + '<span style="color:#DDD;font-size: 15px;">站点名称:' + objStation.stationStationName + '</span>' + | ||
| 310 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">站点编码:' + objStation.stationStationCod + '</span>' + | ||
| 311 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">站点序号:' + objStation.stationRouteStationRouteCode + '</span>' + | ||
| 312 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">站点类型:' + markTypeStr + '</span>' + | ||
| 313 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">纬度坐标:' + objStation.stationBJwpoints + '</span>' + | ||
| 314 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">到站时间:' + objStation.stationRouteToTime + ' 分钟</span>' + | ||
| 315 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">到站距离:' + objStation.stationRouteDistances + ' 公里</span>' + | ||
| 316 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">范围半径:' + objStation.stationRadius + '</span>' + | ||
| 317 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">版本 号:' + objStation.stationRouteVersions + '</span>' + | ||
| 318 | + '<span class="help-block" style="width: 100%;font-size: 15px;;color:#DDD;'+ | ||
| 319 | + 'overflow: hidden; white-space: nowrap; text-overflow: ellipsis; " title="'+ | ||
| 320 | + objStation.stationRouteDescriptions +'" >说明/描述:' + objStation.stationRouteDescriptions + '</span>' ; | ||
| 321 | + | ||
| 322 | + // 创建信息窗口 | ||
| 323 | + var infoWindow_target = new BMap.InfoWindow(htm, opts_polygon); | ||
| 324 | + // 自定义标注物图片 | ||
| 325 | + var icon_target = new BMap.Icon('/pages/base/stationroute/css/img/cz.png',new BMap.Size(20, 20)); | ||
| 326 | + | ||
| 327 | + // 创建点 | ||
| 328 | + marker = new BMap.Marker(pointPolygon,{icon : icon_target}); | ||
| 329 | + | ||
| 330 | + // 把标注添物加到地图上 | ||
| 331 | + mapBValue.addOverlay(marker); | ||
| 332 | + | ||
| 333 | + // 是否在平移过程中禁止动画。(自1.2新增) | ||
| 334 | + var PanOptions_ ={noAnimation :true}; | ||
| 335 | + | ||
| 336 | + // 将地图的中心点更改为给定的点。 | ||
| 337 | + mapBValue.panTo(pointPolygon,PanOptions_); | ||
| 338 | + | ||
| 339 | + // 将地图在水平位置上移动x像素,垂直位置上移动y像素。 | ||
| 340 | + mapBValue.panBy(10,-150,PanOptions_); | ||
| 341 | + | ||
| 342 | + //开启信息窗口 | ||
| 343 | + mapBValue.openInfoWindow(infoWindow_target,pointPolygon); | ||
| 344 | + | ||
| 345 | + } | ||
| 346 | + | ||
| 347 | + }, | ||
| 348 | + | ||
| 349 | + editPolyUpline : function() { | ||
| 350 | + // 禁止覆盖物在map.clearOverlays方法中被清除。(自 1.1 新增) | ||
| 351 | + polyUpline.disableMassClear(); | ||
| 352 | + WorldsBMap.clearMarkAndOverlays(); | ||
| 353 | + // 允许覆盖物在map.clearOverlays方法中被清除。(自 1.1 新增) | ||
| 354 | + polyUpline.enableMassClear(); | ||
| 355 | + // 开启线路编辑 | ||
| 356 | + polyUpline.enableEditing(); | ||
| 357 | + // 添加双击折线保存事件 | ||
| 358 | + polyUpline.addEventListener('dblclick',function(e) { | ||
| 359 | + // 关闭 | ||
| 360 | + layer.closeAll(); | ||
| 361 | + polyUpline.disableEditing(); | ||
| 362 | + // 获取折线坐标集合 | ||
| 363 | + var editPloyLineArray = polyUpline.getPath(); | ||
| 364 | + EditSectionObj.setEitdBsectionVector(JSON.stringify(editPloyLineArray)); | ||
| 365 | + polyUpline= ''; | ||
| 366 | + // 加载修改路段弹出层mobal页面 | ||
| 367 | + $.get('editsection.html', function(m){ | ||
| 368 | + $(pjaxContainer).append(m); | ||
| 369 | + $('#edit_section_mobal').trigger('editSectionMobal_show', [WorldsBMap,GetAjaxData,EditSectionObj,PublicFunctions]); | ||
| 370 | + }); | ||
| 371 | + }); | ||
| 372 | + }, | ||
| 373 | + | ||
| 374 | + // 画圆 | ||
| 375 | + pointsCircle : function(objStation) { | ||
| 376 | + | ||
| 377 | + // 将视图切换到指定的缩放等级,中心点坐标不变。注意:当有信息窗口在地图上打开时,地图缩放将保证信息窗口所在的坐标位置不动。(自1.2新增) | ||
| 378 | + mapBValue.setZoom(16); | ||
| 379 | + | ||
| 380 | + if(objStation) { | ||
| 381 | + | ||
| 382 | + // 清除地图覆盖物 | ||
| 383 | + mapBValue.clearOverlays(); | ||
| 384 | + | ||
| 385 | + // 获取中心坐标点字符串分割 | ||
| 386 | + var BJwpoints = objStation.stationBJwpoints.split(' '); | ||
| 387 | + | ||
| 388 | + // 中心坐标点 | ||
| 389 | + var point = new BMap.Point(BJwpoints[0], BJwpoints[1]); | ||
| 390 | + | ||
| 391 | + //创建圆 | ||
| 392 | + circle = new BMap.Circle(point,objStation.stationRadius,{strokeColor:"blue", strokeWeight:2, strokeOpacity:0.5}); | ||
| 393 | + | ||
| 394 | + // 允许覆盖物在map.clearOverlays方法中被清除 | ||
| 395 | + circle.enableMassClear(); | ||
| 396 | + | ||
| 397 | + // 百度地图添加覆盖物圆 | ||
| 398 | + mapBValue.addOverlay(circle); | ||
| 399 | + | ||
| 400 | + // 信息窗口参数属性 | ||
| 401 | + var opts = { | ||
| 402 | + | ||
| 403 | + // 信息窗口宽度 | ||
| 404 | + width : 200, | ||
| 405 | + | ||
| 406 | + // 信息窗口高度 | ||
| 407 | + height : 450, | ||
| 408 | + | ||
| 409 | + // 信息窗位置偏移值。 | ||
| 410 | + offset: new BMap.Size(500,120), | ||
| 411 | + | ||
| 412 | + //标题 | ||
| 413 | + title : '<h4 style="color:#FFFFFF">'+objStation.stationStationName+'站详情</h4>', | ||
| 414 | + | ||
| 415 | + //设置不允许信窗发送短息 | ||
| 416 | + enableMessage : false, | ||
| 417 | + | ||
| 418 | + //是否开启点击地图关闭信息窗口 | ||
| 419 | + enableCloseOnClick : false, | ||
| 420 | + | ||
| 421 | + // 是否开启信息窗口打开时地图自动移动(默认开启)。(自 1.1 新增) | ||
| 422 | + enableAutoPan:false | ||
| 423 | + }; | ||
| 424 | + | ||
| 425 | + var markTypeStr = ''; | ||
| 426 | + | ||
| 427 | + if(objStation.stationRouteStationMark=='B') { | ||
| 428 | + | ||
| 429 | + markTypeStr='起点站'; | ||
| 430 | + | ||
| 431 | + }else if(objStation.stationRouteStationMark=='Z') { | ||
| 432 | + | ||
| 433 | + markTypeStr ='中途站'; | ||
| 434 | + | ||
| 435 | + | ||
| 436 | + }else if(objStation.stationRouteStationMark=='E') { | ||
| 437 | + | ||
| 438 | + markTypeStr='终点站'; | ||
| 439 | + | ||
| 440 | + } | ||
| 441 | + | ||
| 442 | + var htm = '<HR style="border:1 dashed #987cb9" width="100%" color=#987cb9 SIZE=1>'+ | ||
| 443 | + '<span style="color:#DDD;font-size: 15px;">站点名称:' + objStation.stationStationName + '</span>' + | ||
| 444 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">站点编码:' + objStation.stationStationCod + '</span>' + | ||
| 445 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">站点序号:' + objStation.stationRouteStationRouteCode + '</span>' + | ||
| 446 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">站点类型:' + markTypeStr + '</span>' + | ||
| 447 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">纬度坐标:' + objStation.stationBJwpoints + '</span>' + | ||
| 448 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">到站时间:' + objStation.stationRouteToTime + ' 分钟</span>' + | ||
| 449 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">到站距离:' + objStation.stationRouteDistances + ' 公里</span>' + | ||
| 450 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">范围半径:' + objStation.stationRadius + '</span>' + | ||
| 451 | + '<span class="help-block" style="color:#DDD;font-size: 15px;">版本 号:' + objStation.stationRouteVersions + '</span>' + | ||
| 452 | + '<span class="help-block" style="width: 100%;font-size: 15px;;color:#DDD;'+ | ||
| 453 | + 'overflow: hidden; white-space: nowrap; text-overflow: ellipsis; " title="'+ | ||
| 454 | + objStation.stationRouteDescriptions +'" >说明/描述:' + objStation.stationRouteDescriptions + '</span>' ; | ||
| 455 | + | ||
| 456 | + // 创建信息窗口 | ||
| 457 | + var infoWindow_target = new BMap.InfoWindow(htm, opts); | ||
| 458 | + // 自定义标注物图片 | ||
| 459 | + var icon_target = new BMap.Icon('/pages/base/stationroute/css/img/cz.png',new BMap.Size(20, 20)); | ||
| 460 | + | ||
| 461 | + // 创建点 | ||
| 462 | + marker = new BMap.Marker(point,{icon : icon_target}); | ||
| 463 | + | ||
| 464 | + // 把标注添物加到地图上 | ||
| 465 | + mapBValue.addOverlay(marker); | ||
| 466 | + | ||
| 467 | + setTimeout(function(){ | ||
| 468 | + //开启信息窗口 | ||
| 469 | + marker.openInfoWindow(infoWindow_target,point); | ||
| 470 | + | ||
| 471 | + },100); | ||
| 472 | + | ||
| 473 | + // 是否在平移过程中禁止动画。(自1.2新增) | ||
| 474 | + var PanOptions_ ={noAnimation :true}; | ||
| 475 | + | ||
| 476 | + // 将地图的中心点更改为给定的点。 | ||
| 477 | + mapBValue.panTo(point,PanOptions_); | ||
| 478 | + | ||
| 479 | + mapBValue.panBy(10,-200,PanOptions_); | ||
| 480 | + | ||
| 481 | + // 添加标志物监听事件 | ||
| 482 | + marker.addEventListener("click",function() { | ||
| 483 | + | ||
| 484 | + //开启信息窗口 | ||
| 485 | + marker.openInfoWindow(infoWindow_target,point); | ||
| 486 | + | ||
| 487 | + }); | ||
| 488 | + | ||
| 489 | + } | ||
| 490 | + | ||
| 491 | + }, | ||
| 492 | + | ||
| 493 | + // 根据地理名称获取百度经纬度坐标 | ||
| 494 | + localSearchFromAdreesToPoint: function(Address,callback) { | ||
| 495 | + | ||
| 496 | + // 创建一个搜索类实例 | ||
| 497 | + var localSearch = new BMap.LocalSearch(mapBValue); | ||
| 498 | + | ||
| 499 | + // 检索完成后的回调函数。 | ||
| 500 | + localSearch.setSearchCompleteCallback(function (searchResult) { | ||
| 501 | + | ||
| 502 | + var resultPoints = ''; | ||
| 503 | + | ||
| 504 | + if(searchResult) { | ||
| 505 | + | ||
| 506 | + // 返回索引指定的结果。索引0表示第1条结果 | ||
| 507 | + var poi = searchResult.getPoi(0); | ||
| 508 | + | ||
| 509 | + if(poi) { | ||
| 510 | + | ||
| 511 | + //获取经度和纬度 | ||
| 512 | + resultPoints = poi.point.lng + ' ' + poi.point.lat; | ||
| 513 | + | ||
| 514 | + callback && callback(resultPoints); | ||
| 515 | + | ||
| 516 | + }else { | ||
| 517 | + | ||
| 518 | + callback && callback(false); | ||
| 519 | + | ||
| 520 | + } | ||
| 521 | + | ||
| 522 | + }else { | ||
| 523 | + | ||
| 524 | + callback && callback(false); | ||
| 525 | + } | ||
| 526 | + | ||
| 527 | + }); | ||
| 528 | + | ||
| 529 | + // 根据检索词发起检索。 | ||
| 530 | + localSearch.search(Address); | ||
| 531 | + | ||
| 532 | + }, | ||
| 533 | + | ||
| 534 | + // 编辑图形 | ||
| 535 | + editShapes : function(editStationName,stationShapesTypeV,mindex) { | ||
| 536 | + | ||
| 537 | + // 关闭信息窗口 | ||
| 538 | + marker.closeInfoWindow(); | ||
| 539 | + | ||
| 540 | + // 清除marker | ||
| 541 | + mapBValue.removeOverlay(marker); | ||
| 542 | + | ||
| 543 | + // 编辑圆 | ||
| 544 | + if(stationShapesTypeV =='r') { | ||
| 545 | + | ||
| 546 | + // 开启编辑功能 | ||
| 547 | + circle.enableEditing(); | ||
| 548 | + | ||
| 549 | + // 编辑圆监听事件 | ||
| 550 | + circle.addEventListener('dblclick',function() { | ||
| 551 | + | ||
| 552 | + // 关闭提示弹出层 | ||
| 553 | + layer.close(mindex); | ||
| 554 | + | ||
| 555 | + // 返回圆形的半径,单位为米。 | ||
| 556 | + var newRadius = circle.getRadius(); | ||
| 557 | + | ||
| 558 | + // 返回圆形的中心点坐标。 | ||
| 559 | + var newCenter = circle.getCenter().lng + ' ' + circle.getCenter().lat; | ||
| 560 | + | ||
| 561 | + var centre_New = [{potion:{lng:circle.getCenter().lng,lat:circle.getCenter().lat}}]; | ||
| 562 | + | ||
| 563 | + /** 设置修改站点集合对象站点中心点百度坐标属性值 @param:<bJwpoints:中心点百度坐标) */ | ||
| 564 | + EditStationObj.setEitdStationBJwpoints(newCenter); | ||
| 565 | + | ||
| 566 | + /** 设置修改站点集合对象范围图形类型属性值 @param:<shapesType:范围图形类型) */ | ||
| 567 | + EditStationObj.setEitdStationShapesType('r'); | ||
| 568 | + | ||
| 569 | + /** 设置修改站点集合对象圆形半径属性值 @param:<radius:圆形半径) */ | ||
| 570 | + EditStationObj.setEitdStationRadius(Math.round(newRadius)); | ||
| 571 | + | ||
| 572 | + /** 设置修改站点集合对象图形百度坐标集合属性值 @param:<bPolygonGrid:图形百度坐标集合) */ | ||
| 573 | + EditStationObj.setEitdBPolygonGrid(''); | ||
| 574 | + | ||
| 575 | + // 加载编辑页面 | ||
| 576 | + $.get('edit.html', function(m){ | ||
| 577 | + | ||
| 578 | + $(pjaxContainer).append(m); | ||
| 579 | + | ||
| 580 | + $('#edit_station_mobal').trigger('editSelectMobal_show', [WorldsBMap,GetAjaxData,EditStationObj,LineObj,PublicFunctions]); | ||
| 581 | + | ||
| 582 | + }); | ||
| 583 | + | ||
| 584 | + }); | ||
| 585 | + | ||
| 586 | + // 编辑多变行 | ||
| 587 | + }else if(stationShapesTypeV =='d') { | ||
| 588 | + | ||
| 589 | + // 开启编辑功能(自 1.1 新增) | ||
| 590 | + polygon.enableEditing(); | ||
| 591 | + | ||
| 592 | + // 添加多变行编辑事件 | ||
| 593 | + polygon.addEventListener('dblclick',function(e) { | ||
| 594 | + | ||
| 595 | + // 获取编辑的多边形对象 | ||
| 596 | + var edit_pointE = polygon; | ||
| 597 | + | ||
| 598 | + var edit_bPloygonGrid = ""; | ||
| 599 | + | ||
| 600 | + var editPolyGonLen_ = edit_pointE.getPath().length; | ||
| 601 | + | ||
| 602 | + for(var k =0;k<editPolyGonLen_;k++) { | ||
| 603 | + | ||
| 604 | + if(k==0) { | ||
| 605 | + | ||
| 606 | + edit_bPloygonGrid = edit_pointE.getPath()[k].lng + ' ' + edit_pointE.getPath()[k].lat; | ||
| 607 | + | ||
| 608 | + }else { | ||
| 609 | + | ||
| 610 | + edit_bPloygonGrid = edit_bPloygonGrid + ',' + edit_pointE.getPath()[k].lng + ' ' + edit_pointE.getPath()[k].lat; | ||
| 611 | + | ||
| 612 | + } | ||
| 613 | + | ||
| 614 | + } | ||
| 615 | + | ||
| 616 | + edit_bPloygonGrid = edit_bPloygonGrid + ',' + edit_pointE.getPath()[0].lng + ' ' + edit_pointE.getPath()[0].lat; | ||
| 617 | + | ||
| 618 | + // 多边形中心点 | ||
| 619 | + var centre_points = edit_pointE.getBounds().getCenter().lng + ' ' + edit_pointE.getBounds().getCenter().lat; | ||
| 620 | + | ||
| 621 | + /** 设置修改站点集合对象站点中心点百度坐标属性值 @param:<bJwpoints:中心点百度坐标) */ | ||
| 622 | + EditStationObj.setEitdStationBJwpoints(centre_points); | ||
| 623 | + | ||
| 624 | + /** 设置修改站点集合对象范围图形类型属性值 @param:<shapesType:范围图形类型) */ | ||
| 625 | + EditStationObj.setEitdStationShapesType('d'); | ||
| 626 | + | ||
| 627 | + /** 设置修改站点集合对象圆形半径属性值 @param:<radius:圆形半径) */ | ||
| 628 | + EditStationObj.setEitdStationRadius(''); | ||
| 629 | + | ||
| 630 | + /** 设置修改站点集合对象图形百度坐标集合属性值 @param:<bPolygonGrid:图形百度坐标集合) */ | ||
| 631 | + EditStationObj.setEitdBPolygonGrid(edit_bPloygonGrid); | ||
| 632 | + | ||
| 633 | + $.get('edit.html', function(m){ | ||
| 634 | + | ||
| 635 | + $(pjaxContainer).append(m); | ||
| 636 | + | ||
| 637 | + $('#edit_station_mobal').trigger('editSelectMobal_show', [WorldsBMap,GetAjaxData,EditStationObj,LineObj,PublicFunctions]); | ||
| 638 | + | ||
| 639 | + }); | ||
| 640 | + | ||
| 641 | + }); | ||
| 642 | + | ||
| 643 | + } | ||
| 644 | + | ||
| 645 | + }, | ||
| 646 | + | ||
| 647 | + // 在地图上画出上行线路走向 | ||
| 648 | + drawingUpline : function (polylineArray,polyline_center,data) { | ||
| 649 | + /*WorldsBMap.clearMarkAndOverlays();*/ | ||
| 650 | + polyUpline = ''; | ||
| 651 | + // 创建线路走向 | ||
| 652 | + polyUpline = new BMap.Polyline(polylineArray, {strokeColor : "blue",strokeWeight : 6,strokeOpacity : 0.5}); | ||
| 653 | + // polyUpline.data = data; | ||
| 654 | + // 把折线添加到地图上 | ||
| 655 | + mapBValue.addOverlay(polyUpline); | ||
| 656 | + /*var ceter_index = Math.round(resultdata.length / 2); | ||
| 657 | + | ||
| 658 | + var ceterPointsStr = resultdata[ceter_index].bJwpoints; | ||
| 659 | + | ||
| 660 | + var ceterPointsArray = ceterPointsStr.split(' '); | ||
| 661 | + | ||
| 662 | + var polyline_center = new BMap.Point(ceterPointsArray[0],ceterPointsArray[1]);*/ | ||
| 663 | + var PanOptions_ ={noAnimation :true}; | ||
| 664 | + mapBValue.reset(); | ||
| 665 | + mapBValue.panTo(polyline_center,PanOptions_); | ||
| 666 | + mapBValue.panBy(500,-510,PanOptions_); | ||
| 667 | + mapBValue.setZoom(14); | ||
| 668 | + }, | ||
| 669 | + | ||
| 670 | + //在地图上画出公交位置。 | ||
| 671 | + drawingBus :function(lon,lat){ | ||
| 672 | + var point = new BMap.Point(lon,lat); | ||
| 673 | + var myIcon = new BMap.Icon("/pages/excep/img/bus.png", new BMap.Size(300,157)); | ||
| 674 | + var marker = new BMap.Marker(point,{icon:myIcon}); // 创建标注 | ||
| 675 | + mapBValue.addOverlay(marker); | ||
| 676 | + marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画 | ||
| 677 | + }, | ||
| 678 | + | ||
| 679 | + // 在地图上画出上行线路走向 | ||
| 680 | + drawingUpline01 : function (polylineArray,polyline_center,data) { | ||
| 681 | + var polyUpline01 = 'polyline' + '_' + data.sectionrouteId; | ||
| 682 | + // 创建线路走向 | ||
| 683 | + polyUpline01 = new BMap.Polyline(polylineArray, {strokeColor : "blue",strokeWeight : 6,strokeOpacity : 0.5}); | ||
| 684 | + polyUpline01.data = data; | ||
| 685 | + // 把折线添加到地图上 | ||
| 686 | + mapBValue.addOverlay(polyUpline01); | ||
| 687 | + polyUpline01.addEventListener('click',function(e) { | ||
| 688 | + if(WorldsBMap.getIsEditStatus()) { | ||
| 689 | + layer.msg('请先保存正在编辑的路段信息...'); | ||
| 690 | + return false; | ||
| 691 | + } | ||
| 692 | + polyUpline01.enableEditing(); | ||
| 693 | + WorldsBMap.setIsEditStatus(true); | ||
| 694 | + }); | ||
| 695 | + // 添加双击折线保存事件 | ||
| 696 | + polyUpline01.addEventListener('dblclick',function(e) { | ||
| 697 | + WorldsBMap.setIsEditStatus(false); | ||
| 698 | + // 关闭 | ||
| 699 | + layer.closeAll(); | ||
| 700 | + polyUpline01.disableEditing(); | ||
| 701 | + EditSectionObj.setEitdSection(polyUpline01.data); | ||
| 702 | + // 获取折线坐标集合 | ||
| 703 | + var editPloyLineArray = polyUpline01.getPath(); | ||
| 704 | + EditSectionObj.setEitdBsectionVector(JSON.stringify(editPloyLineArray)); | ||
| 705 | + // polyUpline= ''; | ||
| 706 | + // 加载修改路段弹出层mobal页面 | ||
| 707 | + $.get('editsection.html', function(m){ | ||
| 708 | + $(pjaxContainer).append(m); | ||
| 709 | + $('#edit_section_mobal').trigger('editSectionMobal_show', [WorldsBMap,GetAjaxData,EditSectionObj,PublicFunctions]); | ||
| 710 | + }); | ||
| 711 | + }); | ||
| 712 | + var PanOptions_ ={noAnimation :true}; | ||
| 713 | + mapBValue.reset(); | ||
| 714 | + mapBValue.panTo(polyline_center,PanOptions_); | ||
| 715 | + mapBValue.panBy(500,-510,PanOptions_); | ||
| 716 | + mapBValue.setZoom(14); | ||
| 717 | + }, | ||
| 718 | + | ||
| 719 | + /** 在地图上画点 @param:<point_center:中心坐标点> */ | ||
| 720 | + drawingUpStationPoint : function(point_center,stationName,s) { | ||
| 721 | + | ||
| 722 | + // 自定义标注物图片 | ||
| 723 | + var icon_target = new BMap.Icon('/pages/base/stationroute/css/img/gjzd.png',new BMap.Size(10, 10)); | ||
| 724 | + | ||
| 725 | + var html2 = '<div style="position: absolute; margin: 0pt; padding: 0pt; width: 160px; height: 26px; left: -10px; top: -35px; overflow: hidden;">' | ||
| 726 | + + '<img class="rm3_image" style="border:none;left:0px; top:0px; position:absolute;" src="/pages/base/stationroute/css/img/back160.png">' | ||
| 727 | + + '</div>' | ||
| 728 | + + '<label class=" BMapLabel" unselectable="on" style="position: absolute; -moz-user-select: none; display: inline; cursor: inherit; border: 0px none; padding: 2px 1px 1px; white-space: nowrap; font: 12px arial,simsun; z-index: 80; color: rgb(255, 102, 0); left: 15px; top: -35px;"><span style="float: left; color: #fdfdfd; margin-left: -22px; font-size: 6px;">'+ s+'</span>'+ stationName+'</label>'; | ||
| 729 | + | ||
| 730 | + | ||
| 731 | + var myRichMarker1 = new BMapLib.RichMarker(html2, point_center,{ | ||
| 732 | + "anchor" : new BMap.Size(-10,8), | ||
| 733 | + "enableDragging" : true}); | ||
| 734 | + | ||
| 735 | + | ||
| 736 | + myRichMarker1.disableDragging(); | ||
| 737 | + mapBValue.addOverlay(myRichMarker1); | ||
| 738 | + | ||
| 739 | + | ||
| 740 | + // 创建标注物 | ||
| 741 | + marker = new BMap.Marker(point_center,{icon : icon_target}); | ||
| 742 | + | ||
| 743 | + // 允许覆盖物在map.clearOverlays方法中被清除。 | ||
| 744 | + marker.enableMassClear(); | ||
| 745 | + | ||
| 746 | + mapBValue.addOverlay(marker); | ||
| 747 | + }, | ||
| 748 | + | ||
| 749 | + // 站点名称获取百度坐标(手动规划) | ||
| 750 | + stationsNameToPoints : function(arra,callback) { | ||
| 751 | + // 获取长度 | ||
| 752 | + var len = arra.length; | ||
| 753 | + var stationList = []; | ||
| 754 | + (function(){ | ||
| 755 | + if (!arguments.callee.count) { | ||
| 756 | + arguments.callee.count = 0; | ||
| 757 | + } | ||
| 758 | + arguments.callee.count++; | ||
| 759 | + var index = parseInt(arguments.callee.count) - 1; | ||
| 760 | + if (index >= len) { | ||
| 761 | + callback && callback(stationList); | ||
| 762 | + return ; | ||
| 763 | + } | ||
| 764 | + var f = arguments.callee; | ||
| 765 | + if(arra[index].name!=''){ | ||
| 766 | + var localSearch = new BMap.LocalSearch(mapBValue); | ||
| 767 | + localSearch.search(arra[index].name); | ||
| 768 | + localSearch.setSearchCompleteCallback(function (searchResult) { | ||
| 769 | + var poi = searchResult.getPoi(0); | ||
| 770 | + if(poi) { | ||
| 771 | + stationList.push({name:arra[index].name.replace('公交车站',''),wgs:arra[index].wgs,potion:{lng:poi.point.lng,lat:poi.point.lat}}); | ||
| 772 | + }else { | ||
| 773 | + stationList.push({name:arra[index].name.replace('公交车站',''),wgs:arra[index].wgs,potion:{lng:arra[index].wgs.x,lat:arra[index].wgs.y}}); | ||
| 774 | + } | ||
| 775 | + f(); | ||
| 776 | + }); | ||
| 777 | + }else { | ||
| 778 | + f(); | ||
| 779 | + } | ||
| 780 | + })(); | ||
| 781 | + }, | ||
| 782 | + | ||
| 783 | + // 根据坐标点获取两点之间的时间与距离(手动规划) | ||
| 784 | + getDistanceAndTotime : function(stationList,cb) { | ||
| 785 | + | ||
| 786 | + stationList[0].distance = ''; | ||
| 787 | + | ||
| 788 | + stationList[0].duration = ''; | ||
| 789 | + | ||
| 790 | + // var sectionList = []; | ||
| 791 | + | ||
| 792 | + // 获取长度 | ||
| 793 | + var len = stationList.length; | ||
| 794 | + | ||
| 795 | + (function(){ | ||
| 796 | + | ||
| 797 | + if (!arguments.callee.count) { | ||
| 798 | + | ||
| 799 | + arguments.callee.count = 0; | ||
| 800 | + | ||
| 801 | + } | ||
| 802 | + | ||
| 803 | + arguments.callee.count++; | ||
| 804 | + | ||
| 805 | + var index = parseInt(arguments.callee.count) - 1; | ||
| 806 | + | ||
| 807 | + if (index >= len-1) { | ||
| 808 | + | ||
| 809 | + // cb && cb(stationList,sectionList); | ||
| 810 | + cb && cb(stationList); | ||
| 811 | + return; | ||
| 812 | + } | ||
| 813 | + | ||
| 814 | + var f = arguments.callee; | ||
| 815 | + | ||
| 816 | + var poiOne = new BMap.Point(stationList[index].potion.lng,stationList[index].potion.lat); | ||
| 817 | + | ||
| 818 | + var poiTwo = new BMap.Point(stationList[index+1].potion.lng,stationList[index+1].potion.lat); | ||
| 819 | + | ||
| 820 | + var transit = new BMap.TransitRoute(mapBValue, {renderOptions: {map: mapBValue},onSearchComplete: searchComplete}); | ||
| 821 | + | ||
| 822 | + transit.search(poiOne,poiTwo); | ||
| 823 | + | ||
| 824 | + function searchComplete(results){ | ||
| 825 | + | ||
| 826 | + var plan = results.getPlan(0); | ||
| 827 | + | ||
| 828 | + if (transit.getStatus() != BMAP_STATUS_SUCCESS){ | ||
| 829 | + | ||
| 830 | + stationList[index+1].distance = ''; | ||
| 831 | + | ||
| 832 | + stationList[index+1].duration = ''; | ||
| 833 | + | ||
| 834 | + // sectionList.push({sectionName:stationList[index].name+stationList[index+1].name,points:''}); | ||
| 835 | + | ||
| 836 | + }else { | ||
| 837 | + | ||
| 838 | + stationList[index+1].distance = plan.getDistance(true); | ||
| 839 | + | ||
| 840 | + stationList[index+1].duration = plan.getDuration(true); | ||
| 841 | + | ||
| 842 | + // var line = plan.getRoute(0); | ||
| 843 | + | ||
| 844 | + // sectionList.push({sectionName:stationList[index].name+stationList[index+1].name,points:line.getPath()}); | ||
| 845 | + | ||
| 846 | + } | ||
| 847 | + | ||
| 848 | + f(); | ||
| 849 | + } | ||
| 850 | + | ||
| 851 | + })(); | ||
| 852 | + | ||
| 853 | + }, | ||
| 854 | + | ||
| 855 | + // 根据坐标点获取两点之间的折线路段(手动规划) | ||
| 856 | + getSectionListPlonly : function(stationsPoint,cb) { | ||
| 857 | + | ||
| 858 | + var len = stationsPoint.length; | ||
| 859 | + | ||
| 860 | + var sectionList = []; | ||
| 861 | + | ||
| 862 | + (function(){ | ||
| 863 | + | ||
| 864 | + if (!arguments.callee.count) { | ||
| 865 | + | ||
| 866 | + arguments.callee.count = 0; | ||
| 867 | + | ||
| 868 | + } | ||
| 869 | + | ||
| 870 | + arguments.callee.count++; | ||
| 871 | + | ||
| 872 | + var index = parseInt(arguments.callee.count) - 1; | ||
| 873 | + | ||
| 874 | + if (index >= len-1 ) { | ||
| 875 | + | ||
| 876 | + cb && cb(sectionList); | ||
| 877 | + return; | ||
| 878 | + } | ||
| 879 | + | ||
| 880 | + var f = arguments.callee; | ||
| 881 | + | ||
| 882 | + var poiOne = new BMap.Point(stationsPoint[index].potion.lng,stationsPoint[index].potion.lat); | ||
| 883 | + | ||
| 884 | + var poiTwo = new BMap.Point(stationsPoint[index+1].potion.lng,stationsPoint[index+1].potion.lat); | ||
| 885 | + | ||
| 886 | + /* var transit = new BMap.TransitRoute(mapB, {renderOptions: {map: mapB},onPolylinesSet: searchPolylinesSet});*/ | ||
| 887 | + | ||
| 888 | + var transit = new BMap.DrivingRoute(mapBValue, {renderOptions: {map: mapBValue},onPolylinesSet: searchPolylinesSet}); | ||
| 889 | + | ||
| 890 | + function searchPolylinesSet(results){ | ||
| 891 | + | ||
| 892 | + if (transit.getStatus() != BMAP_STATUS_SUCCESS){ | ||
| 893 | + | ||
| 894 | + | ||
| 895 | + }else { | ||
| 896 | + | ||
| 897 | + var sectionArrayList = []; | ||
| 898 | + for (i = 0; i < results.length; i++){ | ||
| 899 | + | ||
| 900 | + // console.log(results[i].getPolyline().getPath()); | ||
| 901 | + sectionArrayList = sectionArrayList.concat(results[i].getPolyline().getPath()); | ||
| 902 | + | ||
| 903 | + } | ||
| 904 | + | ||
| 905 | + var sectionName = stationsPoint[index].name + '至' + stationsPoint[index+1].name; | ||
| 906 | + | ||
| 907 | + sectionList.push({sectionName:sectionName,points:sectionArrayList}); | ||
| 908 | + | ||
| 909 | + } | ||
| 910 | + | ||
| 911 | + f(); | ||
| 912 | + } | ||
| 913 | + | ||
| 914 | + transit.search(poiOne,poiTwo); | ||
| 915 | + | ||
| 916 | + })(); | ||
| 917 | + | ||
| 918 | + }, | ||
| 919 | + | ||
| 920 | + localtionPoint : function(stationNameV) { | ||
| 921 | + | ||
| 922 | + WorldsBMap.localSearchFromAdreesToPoint(stationNameV,function(Points) { | ||
| 923 | + | ||
| 924 | + if(Points) { | ||
| 925 | + | ||
| 926 | + var BJwpointsArray = Points.split(' '); | ||
| 927 | + | ||
| 928 | + var stationNameChangePoint = new BMap.Point(BJwpointsArray[0], BJwpointsArray[1]); | ||
| 929 | + | ||
| 930 | + var marker_stargt2 = new BMap.Marker(stationNameChangePoint); | ||
| 931 | + | ||
| 932 | + var PanOptions ={noAnimation :true}; | ||
| 933 | + | ||
| 934 | + mapBValue.panTo(stationNameChangePoint,PanOptions); | ||
| 935 | + | ||
| 936 | + mapBValue.panBy(0,-100); | ||
| 937 | + | ||
| 938 | + // 将标注添加到地图中 | ||
| 939 | + mapBValue.addOverlay(marker_stargt2); | ||
| 940 | + | ||
| 941 | + //跳动的动画 | ||
| 942 | + marker_stargt2.setAnimation(BMAP_ANIMATION_BOUNCE); | ||
| 943 | + | ||
| 944 | + } | ||
| 945 | + | ||
| 946 | + }); | ||
| 947 | + | ||
| 948 | + }, | ||
| 949 | + | ||
| 950 | + /** 系统规划抓去数据 @param lineNameValue:线路名称;i:方向*/ | ||
| 951 | + getBmapStationNames : function(lineNameValue,i,callback) { | ||
| 952 | + | ||
| 953 | + var busline = new BMap.BusLineSearch(mapBValue,{ | ||
| 954 | + | ||
| 955 | + // 设置公交列表查询后的回调函数。参数:rs: BusListResult类型 | ||
| 956 | + onGetBusListComplete:function(BusListResult) { | ||
| 957 | + | ||
| 958 | + // 如果不为空 | ||
| 959 | + if(BusListResult){ | ||
| 960 | + | ||
| 961 | + //获取第一个公交列表显示到map上 | ||
| 962 | + var fstLine = BusListResult.getBusListItem(i); | ||
| 963 | + | ||
| 964 | + /*if(fstLine==undefined){ | ||
| 965 | + | ||
| 966 | + layer.confirm('系统无法生成该线路【'+lineNameValue+'】的站点与路段!请点击返回选择其它方式规划', {btn : [ '返回' ],icon: 3, title:'提示' }, function(index){ | ||
| 967 | + | ||
| 968 | + layer.closeAll(); | ||
| 969 | + | ||
| 970 | + if(i==0){ | ||
| 971 | + | ||
| 972 | + $('#upToolsMobal').show(); | ||
| 973 | + | ||
| 974 | + }else if(i==1){ | ||
| 975 | + | ||
| 976 | + $('#downToolsMobal').show(); | ||
| 977 | + | ||
| 978 | + } | ||
| 979 | + | ||
| 980 | + return; | ||
| 981 | + }); | ||
| 982 | + | ||
| 983 | + }*/ | ||
| 984 | + | ||
| 985 | + if(fstLine==undefined){ | ||
| 986 | + | ||
| 987 | + | ||
| 988 | + callback && callback(null); | ||
| 989 | + | ||
| 990 | + } | ||
| 991 | + | ||
| 992 | + busline.getBusLine(fstLine); | ||
| 993 | + | ||
| 994 | + } | ||
| 995 | + | ||
| 996 | + }, | ||
| 997 | + | ||
| 998 | + //设置公交线路查询后的回调函数.参数:rs: BusLine类型 | ||
| 999 | + onGetBusLineComplete: function(BusLine){ | ||
| 1000 | + | ||
| 1001 | + // 如果不为空 | ||
| 1002 | + if(BusLine){ | ||
| 1003 | + | ||
| 1004 | + callback && callback(BusLine); | ||
| 1005 | + | ||
| 1006 | + } | ||
| 1007 | + | ||
| 1008 | + } | ||
| 1009 | + | ||
| 1010 | + }); | ||
| 1011 | + | ||
| 1012 | + busline.getBusList(lineNameValue); | ||
| 1013 | + | ||
| 1014 | + }, | ||
| 1015 | + | ||
| 1016 | + clearMarkAndOverlays : function() { | ||
| 1017 | + | ||
| 1018 | + // 清楚地图覆盖物 | ||
| 1019 | + mapBValue.clearOverlays(); | ||
| 1020 | + | ||
| 1021 | + mapBValue.removeOverlay(); | ||
| 1022 | + | ||
| 1023 | + } | ||
| 1024 | + | ||
| 1025 | + } | ||
| 1026 | + | ||
| 1027 | + return Bmap; | ||
| 1028 | + | ||
| 1029 | }(); | 1029 | }(); |
| 1030 | \ No newline at end of file | 1030 | \ No newline at end of file |
src/main/resources/static/pages/excep/js/speeding-map.js
| 1 | -/** | ||
| 2 | - * 百度地图 | ||
| 3 | - * | ||
| 4 | - * - - - - - -》init:地图初始化 | ||
| 5 | - * | ||
| 6 | - * - - - - - -》getDistanceAndDuration:获取距离与时间 | ||
| 7 | - * | ||
| 8 | - * - - - - - -》drawingUpline:在地图上画出上行线路走向 | ||
| 9 | - * | ||
| 10 | - * - - - - - -》stationsPointsToLibraryPoint:根据站点坐标匹配库中的公交站点(手动规划) | ||
| 11 | - */ | ||
| 12 | - | ||
| 13 | -var SpeedingMap = function () { | ||
| 14 | - | ||
| 15 | - /** SpeedingMap 全局变量定义 mapBValue:地图对象;polyUpline:走向折线;sectionList:截取过的路段 ;pointIndex:计算路段被切的次数; | ||
| 16 | - * firstPoint:截取路段的第一个点;iseditStatus:路段是否在编辑状态;isCutSection : 获取路段是否在截取状态*/ | ||
| 17 | - var mapBValue = '', polyUpline='', sectionList = [], pointIndex = 0, iseditStatus = false, firstPoint = {}, isCutSection = false; | ||
| 18 | - | ||
| 19 | - var Bmap = { | ||
| 20 | - | ||
| 21 | - init : function() { | ||
| 22 | - | ||
| 23 | - // 设置中心点, | ||
| 24 | - var CENTER_POINT = {lng : 121.528733,lat : 31.237425}; | ||
| 25 | - | ||
| 26 | - // 百度API Key | ||
| 27 | - var bdKey = 'IGGrr4UjwIYzatoCRFKEL8sT'; | ||
| 28 | - | ||
| 29 | - // 初始化百度地图 | ||
| 30 | - mapBValue = new BMap.Map("speedingMap"); | ||
| 31 | - | ||
| 32 | - //中心点和缩放级别 | ||
| 33 | - mapBValue.centerAndZoom(new BMap.Point(CENTER_POINT.lng,CENTER_POINT.lat),15); | ||
| 34 | - | ||
| 35 | - //启用地图拖拽事件,默认启用(可不写) | ||
| 36 | - mapBValue.enableDragging(); | ||
| 37 | - | ||
| 38 | - //启用地图滚轮放大缩小 | ||
| 39 | - mapBValue.enableScrollWheelZoom(); | ||
| 40 | - | ||
| 41 | - //禁用鼠标双击放大 | ||
| 42 | - mapBValue.disableDoubleClickZoom(); | ||
| 43 | - | ||
| 44 | - //启用键盘上下左右键移动地图 | ||
| 45 | - mapBValue.enableKeyboard(); | ||
| 46 | - | ||
| 47 | - return mapBValue; | ||
| 48 | - }, | ||
| 49 | - /** 获取第一个切路段的点 @return Point*/ | ||
| 50 | - getFirstPoint : function() { | ||
| 51 | - return firstPoint; | ||
| 52 | - }, | ||
| 53 | - /** 获取地图对象 @return 地图对象map */ | ||
| 54 | - getmapBValue : function() { | ||
| 55 | - | ||
| 56 | - return mapBValue; | ||
| 57 | - | ||
| 58 | - }, | ||
| 59 | - | ||
| 60 | - getPolyUpline : function() { | ||
| 61 | - | ||
| 62 | - return polyUpline; | ||
| 63 | - }, | ||
| 64 | - | ||
| 65 | - /** 获取截取过的路段 @return 路段对象List */ | ||
| 66 | - getSectionList : function() { | ||
| 67 | - | ||
| 68 | - return sectionList; | ||
| 69 | - | ||
| 70 | - }, | ||
| 71 | - setSectionList : function(list) { | ||
| 72 | - | ||
| 73 | - sectionList = list; | ||
| 74 | - }, | ||
| 75 | - initCutSectionPoint : function() { | ||
| 76 | - sectionList = []; | ||
| 77 | - var tbodyHtml = template('section_list',{list : sectionList}); | ||
| 78 | - $('#section_table tbody').html(tbodyHtml); | ||
| 79 | - }, | ||
| 80 | - /** 获取切路段的点下标 @return int*/ | ||
| 81 | - setPointIndex : function(index) { | ||
| 82 | - pointIndex = index; | ||
| 83 | - }, | ||
| 84 | - getPointIndex : function() { | ||
| 85 | - | ||
| 86 | - return pointIndex; | ||
| 87 | - | ||
| 88 | - }, | ||
| 89 | - /** 获取路段是否在编辑状态 @return boolean*/ | ||
| 90 | - getIsEditStatus : function() { | ||
| 91 | - return iseditStatus; | ||
| 92 | - }, | ||
| 93 | - setIsEditStatus : function(v) { | ||
| 94 | - iseditStatus = v ; | ||
| 95 | - }, | ||
| 96 | - | ||
| 97 | - /** 获取路段是否在截取状态 @return boolean*/ | ||
| 98 | - getIsCutSection : function() { | ||
| 99 | - return isCutSection; | ||
| 100 | - }, | ||
| 101 | - setIsCutSection : function(v) { | ||
| 102 | - isCutSection = v ; | ||
| 103 | - }, | ||
| 104 | - | ||
| 105 | - /** 获取距离与时间 @param <points:坐标点集合> */ | ||
| 106 | - getDistanceAndDuration : function(points,callback){ | ||
| 107 | - | ||
| 108 | - // 获取长度 | ||
| 109 | - var len = points.length; | ||
| 110 | - (function(){ | ||
| 111 | - | ||
| 112 | - if (!arguments.callee.count) { | ||
| 113 | - | ||
| 114 | - arguments.callee.count = 0; | ||
| 115 | - | ||
| 116 | - } | ||
| 117 | - | ||
| 118 | - arguments.callee.count++; | ||
| 119 | - | ||
| 120 | - var index = parseInt(arguments.callee.count) - 1; | ||
| 121 | - | ||
| 122 | - if (index >= len-1) { | ||
| 123 | - | ||
| 124 | - callback && callback(points); | ||
| 125 | - | ||
| 126 | - return; | ||
| 127 | - } | ||
| 128 | - | ||
| 129 | - // 当函数被调用时,它的arguments.callee对象就会指向自身,也就是一个对自己的引用。(当前正在执行的函数。) | ||
| 130 | - var f = arguments.callee; | ||
| 131 | - // 起点坐标 <坐标格式:40.056878,116.30815> | ||
| 132 | - var origin = points[index].potion.lat + ',' + points[index].potion.lng; | ||
| 133 | - | ||
| 134 | - // 终点坐标 <坐标格式:40.056878,116.30815> | ||
| 135 | - var destination = points[index+1].potion.lat + ',' + points[index+1].potion.lng; | ||
| 136 | - var region = '上海'; | ||
| 137 | - | ||
| 138 | - var origin_region = '上海'; | ||
| 139 | - | ||
| 140 | - var destination_region = '上海'; | ||
| 141 | - | ||
| 142 | - var output = 'json'; | ||
| 143 | - | ||
| 144 | - var ak_My = 'wjlITmXeCek5MxyU3ZUBkTeU8B0o0npk'; | ||
| 145 | - | ||
| 146 | - /** | ||
| 147 | - * origin:起点名称或经纬度; | ||
| 148 | - * | ||
| 149 | - * destination:终点名称或经纬度; | ||
| 150 | - * | ||
| 151 | - * origin_region:起始点所在城市,驾车导航时必填。 | ||
| 152 | - * | ||
| 153 | - * destination_region:终点所在城市,驾车导航时必填。 | ||
| 154 | - * | ||
| 155 | - * output :表示输出类型,可设置为xml或json,默认为xml。 | ||
| 156 | - * | ||
| 157 | - **/ | ||
| 158 | - var paramsB = {origin:origin,destination:destination,region:region,origin_region:origin_region,destination_region:destination_region,output:output,ak:ak_My}; | ||
| 159 | - | ||
| 160 | - /** @description :未认证开发者默认配额为:2000次/天。 */ | ||
| 161 | - $.ajax({ | ||
| 162 | - | ||
| 163 | - // 百度地图根据坐标获取两点之间的时间与距离 | ||
| 164 | - url: 'http://api.map.baidu.com/direction/v1?mode=transit', | ||
| 165 | - | ||
| 166 | - data: paramsB, | ||
| 167 | - | ||
| 168 | - dataType: 'jsonp', | ||
| 169 | - | ||
| 170 | - success: function(r){ | ||
| 171 | - | ||
| 172 | - if(r) { | ||
| 173 | - | ||
| 174 | - if(r.message=='ok') { | ||
| 175 | - | ||
| 176 | - if(r.result.taxi==null) { | ||
| 177 | - | ||
| 178 | - // 获取距离(单位:米) | ||
| 179 | - points[index+1].distance = 0; | ||
| 180 | - | ||
| 181 | - // 获取时间(单位:秒) | ||
| 182 | - points[index+1].duration = 0; | ||
| 183 | - | ||
| 184 | - }else { | ||
| 185 | - | ||
| 186 | - // 获取距离(单位:米) | ||
| 187 | - points[index+1].distance = r.result.taxi.distance; | ||
| 188 | - | ||
| 189 | - // 获取时间(单位:秒) | ||
| 190 | - points[index+1].duration = r.result.taxi.duration; | ||
| 191 | - | ||
| 192 | - } | ||
| 193 | - | ||
| 194 | - | ||
| 195 | - } | ||
| 196 | - | ||
| 197 | - } | ||
| 198 | - | ||
| 199 | - f(); | ||
| 200 | - } | ||
| 201 | - }); | ||
| 202 | - | ||
| 203 | - })(); | ||
| 204 | - | ||
| 205 | - }, | ||
| 206 | - // 在地图上画出上行线路走向 | ||
| 207 | - drawingUpline01 : function (polylineArray,polyline_center,data) { | ||
| 208 | - var polyUpline01 = 'polyline' + '_' + data.sectionrouteId; | ||
| 209 | - // 创建线路走向 | ||
| 210 | - polyUpline01 = new BMap.Polyline(polylineArray, {strokeColor : "blue",strokeWeight : 6,strokeOpacity : 0.5}); | ||
| 211 | - polyUpline01.data = data; | ||
| 212 | - // 把折线添加到地图上 | ||
| 213 | - mapBValue.addOverlay(polyUpline01); | ||
| 214 | - var sectionPoint = []; | ||
| 215 | - // 线路单击事件 | ||
| 216 | - polyUpline01.addEventListener('click',function(e) { | ||
| 217 | - if(SpeedingMap.getIsEditStatus()) { | ||
| 218 | - layer.msg('请先保存正在编辑的路段信息...'); | ||
| 219 | - return false; | ||
| 220 | - } | ||
| 221 | - if(SpeedingMap.getIsCutSection()) { | ||
| 222 | - layer.msg('请先撤销所有切路段的点...'); | ||
| 223 | - return false; | ||
| 224 | - } | ||
| 225 | - polyUpline01.enableEditing(); | ||
| 226 | - SpeedingMap.setIsEditStatus(true); | ||
| 227 | - }); | ||
| 228 | - | ||
| 229 | - // 添加路段双击事件 | ||
| 230 | - polyUpline01.addEventListener("dblclick",function(e){ | ||
| 231 | - if(SpeedingMap.getIsCutSection()) { | ||
| 232 | - layer.msg('请先撤销所有切路段的点...'); | ||
| 233 | - return false; | ||
| 234 | - } | ||
| 235 | - SpeedingMap.setIsEditStatus(false); | ||
| 236 | - // 关闭 | ||
| 237 | - layer.closeAll(); | ||
| 238 | - polyUpline01.disableEditing(); | ||
| 239 | - EditSectionObj.setEitdSection(polyUpline01.data); | ||
| 240 | - // 获取折线坐标集合 | ||
| 241 | - var editPloyLineArray = polyUpline01.getPath(); | ||
| 242 | - EditSectionObj.setEitdBsectionVector(JSON.stringify(editPloyLineArray)); | ||
| 243 | - sectionList = []; | ||
| 244 | - var tbodyHtml = template('section_list',{list : sectionList}); | ||
| 245 | - // 截取路段 | ||
| 246 | - $('#section_table tbody').html(tbodyHtml); | ||
| 247 | - // 加载修改路段弹出层mobal页面 | ||
| 248 | - $.get('editsection.html', function(m){ | ||
| 249 | - $(pjaxContainer).append(m); | ||
| 250 | - $('#edit_section_mobal_cache').trigger('editSectionMobalCache_show', [SpeedingMap,GetAjaxData,EditSectionObj,PublicFunctions]); | ||
| 251 | - }); | ||
| 252 | - }); | ||
| 253 | - | ||
| 254 | - // 路段右击事件 | ||
| 255 | - var editSection = function(e,ee,marker){ | ||
| 256 | - if(SpeedingMap.getIsEditStatus()) { | ||
| 257 | - layer.msg('请先保存正在编辑的路段信息...'); | ||
| 258 | - return false; | ||
| 259 | - } | ||
| 260 | - var lng = e.lng; | ||
| 261 | - var lat = e.lat; | ||
| 262 | - var sectionName = null; | ||
| 263 | - var marker = new BMap.Marker(new BMap.Point(lng, lat)); // 创建点 | ||
| 264 | - marker.isFlag = true; | ||
| 265 | - if(pointIndex == 0) { | ||
| 266 | - sectionPoint[pointIndex] = {lng:lng , lat:lat}; | ||
| 267 | - layer.msg('进入切路段状态,请选择本路段的终点!'); | ||
| 268 | - mapBValue.addOverlay(marker);// 添加覆盖物 | ||
| 269 | - firstPoint = {lng:lng, lat:lat}; | ||
| 270 | - pointIndex++; | ||
| 271 | - EditSectionObj.setEitdSection(polyUpline01.data); | ||
| 272 | - // 获取折线坐标集合 | ||
| 273 | - var editPloyLineArray = polyUpline01.getPath(); | ||
| 274 | - EditSectionObj.setEitdBsectionVector(JSON.stringify(editPloyLineArray)); | ||
| 275 | - } else if (pointIndex > 0) { | ||
| 276 | - layer.prompt({title: '请输入路段名!'}, function(sectionName, index){ | ||
| 277 | - pointList = []; | ||
| 278 | - sectionPoint[pointIndex] = {lng:lng , lat:lat}; | ||
| 279 | - pointList[0] = sectionPoint[pointIndex-1]; | ||
| 280 | - pointList[1] = sectionPoint[pointIndex]; | ||
| 281 | - sectionList.push({name:sectionName, section:pointList}); | ||
| 282 | - layer.close(index); | ||
| 283 | - layer.msg('路段截取成功,请选择下一个路段的终点'); | ||
| 284 | - mapBValue.addOverlay(marker);// 添加覆盖物 | ||
| 285 | - var tbodyHtml = template('section_list',{list : sectionList}); | ||
| 286 | - // 截取路段 | ||
| 287 | - $('#section_table tbody').html(tbodyHtml); | ||
| 288 | - pointIndex++; | ||
| 289 | - }); | ||
| 290 | - } | ||
| 291 | - SpeedingMap.setIsCutSection(true); | ||
| 292 | - } | ||
| 293 | - var markerMenu=new BMap.ContextMenu(); | ||
| 294 | - markerMenu.addItem(new BMap.MenuItem('切路段',editSection.bind(polyUpline01))); | ||
| 295 | - polyUpline01.addContextMenu(markerMenu); | ||
| 296 | - | ||
| 297 | - | ||
| 298 | - var PanOptions_ ={noAnimation :true}; | ||
| 299 | - mapBValue.reset(); | ||
| 300 | - mapBValue.panTo(polyline_center,PanOptions_); | ||
| 301 | - mapBValue.panBy(500,-510,PanOptions_); | ||
| 302 | - mapBValue.setZoom(14); | ||
| 303 | - }, | ||
| 304 | - // 删除点刷新cutSectionTable | ||
| 305 | - refreshCutSectionTable : function() { | ||
| 306 | - var tbodyHtml = template('section_list',{list : sectionList}); | ||
| 307 | - $('#section_table tbody').html(tbodyHtml); | ||
| 308 | - }, | ||
| 309 | - // 删除点刷新覆盖物 | ||
| 310 | - deleteCutSectionPoint : function(point) { | ||
| 311 | - var lng = point.lng; | ||
| 312 | - var lat = point.lat; | ||
| 313 | - var allOverlay = mapBValue.getOverlays(); | ||
| 314 | - // 删除最后一个点 | ||
| 315 | - for (var i = 0; i < allOverlay.length -1; i++){ | ||
| 316 | - if(allOverlay[i].isFlag) { | ||
| 317 | - if(allOverlay[i].point.lng == lng && allOverlay[i].point.lat == lat){ | ||
| 318 | - mapBValue.removeOverlay(allOverlay[i]); | ||
| 319 | - break; | ||
| 320 | - } | ||
| 321 | - } | ||
| 322 | - } | ||
| 323 | - }, | ||
| 324 | - /** 在地图上画点 @param:<point_center:中心坐标点> */ | ||
| 325 | - drawingUpStationPoint : function(point_center,stationName,s) { | ||
| 326 | - | ||
| 327 | - // 自定义标注物图片 | ||
| 328 | - var icon_target = new BMap.Icon('/pages/base/stationroute/css/img/gjzd.png',new BMap.Size(10, 10)); | ||
| 329 | - | ||
| 330 | - var html2 = '<div style="position: absolute; margin: 0pt; padding: 0pt; width: 160px; height: 26px; left: -10px; top: -35px; overflow: hidden;">' | ||
| 331 | - + '<img class="rm3_image" style="border:none;left:0px; top:0px; position:absolute;" src="/pages/base/stationroute/css/img/back160.png">' | ||
| 332 | - + '</div>' | ||
| 333 | - + '<label class=" BMapLabel" unselectable="on" style="position: absolute; -moz-user-select: none; display: inline; cursor: inherit; border: 0px none; padding: 2px 1px 1px; white-space: nowrap; font: 12px arial,simsun; z-index: 80; color: rgb(255, 102, 0); left: 15px; top: -35px;"><span style="float: left; color: #fdfdfd; margin-left: -22px; font-size: 6px;">'+ s+'</span>'+ stationName+'</label>'; | ||
| 334 | - | ||
| 335 | - | ||
| 336 | - var myRichMarker1 = new BMapLib.RichMarker(html2, point_center,{ | ||
| 337 | - "anchor" : new BMap.Size(-10,8), | ||
| 338 | - "enableDragging" : true}); | ||
| 339 | - | ||
| 340 | - | ||
| 341 | - myRichMarker1.disableDragging(); | ||
| 342 | - mapBValue.addOverlay(myRichMarker1); | ||
| 343 | - | ||
| 344 | - | ||
| 345 | - // 创建标注物 | ||
| 346 | - marker = new BMap.Marker(point_center,{icon : icon_target}); | ||
| 347 | - | ||
| 348 | - // 允许覆盖物在map.clearOverlays方法中被清除。 | ||
| 349 | - marker.enableMassClear(); | ||
| 350 | - | ||
| 351 | - mapBValue.addOverlay(marker); | ||
| 352 | - }, | ||
| 353 | - | ||
| 354 | - // 根据站点坐标匹配库中的公交站点(手动规划) | ||
| 355 | - stationsPointsToLibraryPoint : function(arra,callback) { | ||
| 356 | - // 获取长度 | ||
| 357 | - var len = arra.length; | ||
| 358 | - var station = {}; | ||
| 359 | - var stationList = []; | ||
| 360 | - (function(){ | ||
| 361 | - if (!arguments.callee.count) { | ||
| 362 | - arguments.callee.count = 0; | ||
| 363 | - } | ||
| 364 | - arguments.callee.count++; | ||
| 365 | - var index = parseInt(arguments.callee.count) - 1; | ||
| 366 | - if (index >= len) { | ||
| 367 | - callback && callback(stationList); | ||
| 368 | - return ; | ||
| 369 | - } | ||
| 370 | - var f = arguments.callee; | ||
| 371 | - station = arra[index]; | ||
| 372 | - if(arra[index].name!=''){ | ||
| 373 | - | ||
| 374 | - $.get('/station/matchStation',station,function(resultStation) { | ||
| 375 | - stationList.push({name:resultStation.name ,wgs:arra[index].wgs,potion:{lng:resultStation.potion_lng, lat:resultStation.potion_lat}, isHave:resultStation.isHave , id:resultStation.id}); | ||
| 376 | - f(); | ||
| 377 | - }); | ||
| 378 | - }else { | ||
| 379 | - f(); | ||
| 380 | - } | ||
| 381 | - })() | ||
| 382 | - }, | ||
| 383 | - clearMarkAndOverlays : function() { | ||
| 384 | - | ||
| 385 | - // 清楚地图覆盖物 | ||
| 386 | - mapBValue.clearOverlays(); | ||
| 387 | - | ||
| 388 | - mapBValue.removeOverlay(); | ||
| 389 | - | ||
| 390 | - } | ||
| 391 | - | ||
| 392 | - } | ||
| 393 | - | ||
| 394 | - return Bmap; | ||
| 395 | - | 1 | +/** |
| 2 | + * 百度地图 | ||
| 3 | + * | ||
| 4 | + * - - - - - -》init:地图初始化 | ||
| 5 | + * | ||
| 6 | + * - - - - - -》getDistanceAndDuration:获取距离与时间 | ||
| 7 | + * | ||
| 8 | + * - - - - - -》drawingUpline:在地图上画出上行线路走向 | ||
| 9 | + * | ||
| 10 | + * - - - - - -》stationsPointsToLibraryPoint:根据站点坐标匹配库中的公交站点(手动规划) | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +var SpeedingMap = function () { | ||
| 14 | + | ||
| 15 | + /** SpeedingMap 全局变量定义 mapBValue:地图对象;polyUpline:走向折线;sectionList:截取过的路段 ;pointIndex:计算路段被切的次数; | ||
| 16 | + * firstPoint:截取路段的第一个点;iseditStatus:路段是否在编辑状态;isCutSection : 获取路段是否在截取状态*/ | ||
| 17 | + var mapBValue = '', polyUpline='', sectionList = [], pointIndex = 0, iseditStatus = false, firstPoint = {}, isCutSection = false; | ||
| 18 | + | ||
| 19 | + var Bmap = { | ||
| 20 | + | ||
| 21 | + init : function() { | ||
| 22 | + | ||
| 23 | + // 设置中心点, | ||
| 24 | + var CENTER_POINT = {lng : 121.528733,lat : 31.237425}; | ||
| 25 | + | ||
| 26 | + // 百度API Key | ||
| 27 | + var bdKey = 'IGGrr4UjwIYzatoCRFKEL8sT'; | ||
| 28 | + | ||
| 29 | + // 初始化百度地图 | ||
| 30 | + mapBValue = new BMap.Map("speedingMap"); | ||
| 31 | + | ||
| 32 | + //中心点和缩放级别 | ||
| 33 | + mapBValue.centerAndZoom(new BMap.Point(CENTER_POINT.lng,CENTER_POINT.lat),15); | ||
| 34 | + | ||
| 35 | + //启用地图拖拽事件,默认启用(可不写) | ||
| 36 | + mapBValue.enableDragging(); | ||
| 37 | + | ||
| 38 | + //启用地图滚轮放大缩小 | ||
| 39 | + mapBValue.enableScrollWheelZoom(); | ||
| 40 | + | ||
| 41 | + //禁用鼠标双击放大 | ||
| 42 | + mapBValue.disableDoubleClickZoom(); | ||
| 43 | + | ||
| 44 | + //启用键盘上下左右键移动地图 | ||
| 45 | + mapBValue.enableKeyboard(); | ||
| 46 | + | ||
| 47 | + return mapBValue; | ||
| 48 | + }, | ||
| 49 | + /** 获取第一个切路段的点 @return Point*/ | ||
| 50 | + getFirstPoint : function() { | ||
| 51 | + return firstPoint; | ||
| 52 | + }, | ||
| 53 | + /** 获取地图对象 @return 地图对象map */ | ||
| 54 | + getmapBValue : function() { | ||
| 55 | + | ||
| 56 | + return mapBValue; | ||
| 57 | + | ||
| 58 | + }, | ||
| 59 | + | ||
| 60 | + getPolyUpline : function() { | ||
| 61 | + | ||
| 62 | + return polyUpline; | ||
| 63 | + }, | ||
| 64 | + | ||
| 65 | + /** 获取截取过的路段 @return 路段对象List */ | ||
| 66 | + getSectionList : function() { | ||
| 67 | + | ||
| 68 | + return sectionList; | ||
| 69 | + | ||
| 70 | + }, | ||
| 71 | + setSectionList : function(list) { | ||
| 72 | + | ||
| 73 | + sectionList = list; | ||
| 74 | + }, | ||
| 75 | + initCutSectionPoint : function() { | ||
| 76 | + sectionList = []; | ||
| 77 | + var tbodyHtml = template('section_list',{list : sectionList}); | ||
| 78 | + $('#section_table tbody').html(tbodyHtml); | ||
| 79 | + }, | ||
| 80 | + /** 获取切路段的点下标 @return int*/ | ||
| 81 | + setPointIndex : function(index) { | ||
| 82 | + pointIndex = index; | ||
| 83 | + }, | ||
| 84 | + getPointIndex : function() { | ||
| 85 | + | ||
| 86 | + return pointIndex; | ||
| 87 | + | ||
| 88 | + }, | ||
| 89 | + /** 获取路段是否在编辑状态 @return boolean*/ | ||
| 90 | + getIsEditStatus : function() { | ||
| 91 | + return iseditStatus; | ||
| 92 | + }, | ||
| 93 | + setIsEditStatus : function(v) { | ||
| 94 | + iseditStatus = v ; | ||
| 95 | + }, | ||
| 96 | + | ||
| 97 | + /** 获取路段是否在截取状态 @return boolean*/ | ||
| 98 | + getIsCutSection : function() { | ||
| 99 | + return isCutSection; | ||
| 100 | + }, | ||
| 101 | + setIsCutSection : function(v) { | ||
| 102 | + isCutSection = v ; | ||
| 103 | + }, | ||
| 104 | + | ||
| 105 | + /** 获取距离与时间 @param <points:坐标点集合> */ | ||
| 106 | + getDistanceAndDuration : function(points,callback){ | ||
| 107 | + | ||
| 108 | + // 获取长度 | ||
| 109 | + var len = points.length; | ||
| 110 | + (function(){ | ||
| 111 | + | ||
| 112 | + if (!arguments.callee.count) { | ||
| 113 | + | ||
| 114 | + arguments.callee.count = 0; | ||
| 115 | + | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + arguments.callee.count++; | ||
| 119 | + | ||
| 120 | + var index = parseInt(arguments.callee.count) - 1; | ||
| 121 | + | ||
| 122 | + if (index >= len-1) { | ||
| 123 | + | ||
| 124 | + callback && callback(points); | ||
| 125 | + | ||
| 126 | + return; | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + // 当函数被调用时,它的arguments.callee对象就会指向自身,也就是一个对自己的引用。(当前正在执行的函数。) | ||
| 130 | + var f = arguments.callee; | ||
| 131 | + // 起点坐标 <坐标格式:40.056878,116.30815> | ||
| 132 | + var origin = points[index].potion.lat + ',' + points[index].potion.lng; | ||
| 133 | + | ||
| 134 | + // 终点坐标 <坐标格式:40.056878,116.30815> | ||
| 135 | + var destination = points[index+1].potion.lat + ',' + points[index+1].potion.lng; | ||
| 136 | + var region = '上海'; | ||
| 137 | + | ||
| 138 | + var origin_region = '上海'; | ||
| 139 | + | ||
| 140 | + var destination_region = '上海'; | ||
| 141 | + | ||
| 142 | + var output = 'json'; | ||
| 143 | + | ||
| 144 | + var ak_My = 'wjlITmXeCek5MxyU3ZUBkTeU8B0o0npk'; | ||
| 145 | + | ||
| 146 | + /** | ||
| 147 | + * origin:起点名称或经纬度; | ||
| 148 | + * | ||
| 149 | + * destination:终点名称或经纬度; | ||
| 150 | + * | ||
| 151 | + * origin_region:起始点所在城市,驾车导航时必填。 | ||
| 152 | + * | ||
| 153 | + * destination_region:终点所在城市,驾车导航时必填。 | ||
| 154 | + * | ||
| 155 | + * output :表示输出类型,可设置为xml或json,默认为xml。 | ||
| 156 | + * | ||
| 157 | + **/ | ||
| 158 | + var paramsB = {origin:origin,destination:destination,region:region,origin_region:origin_region,destination_region:destination_region,output:output,ak:ak_My}; | ||
| 159 | + | ||
| 160 | + /** @description :未认证开发者默认配额为:2000次/天。 */ | ||
| 161 | + $.ajax({ | ||
| 162 | + | ||
| 163 | + // 百度地图根据坐标获取两点之间的时间与距离 | ||
| 164 | + url: '//api.map.baidu.com/direction/v1?mode=transit', | ||
| 165 | + | ||
| 166 | + data: paramsB, | ||
| 167 | + | ||
| 168 | + dataType: 'jsonp', | ||
| 169 | + | ||
| 170 | + success: function(r){ | ||
| 171 | + | ||
| 172 | + if(r) { | ||
| 173 | + | ||
| 174 | + if(r.message=='ok') { | ||
| 175 | + | ||
| 176 | + if(r.result.taxi==null) { | ||
| 177 | + | ||
| 178 | + // 获取距离(单位:米) | ||
| 179 | + points[index+1].distance = 0; | ||
| 180 | + | ||
| 181 | + // 获取时间(单位:秒) | ||
| 182 | + points[index+1].duration = 0; | ||
| 183 | + | ||
| 184 | + }else { | ||
| 185 | + | ||
| 186 | + // 获取距离(单位:米) | ||
| 187 | + points[index+1].distance = r.result.taxi.distance; | ||
| 188 | + | ||
| 189 | + // 获取时间(单位:秒) | ||
| 190 | + points[index+1].duration = r.result.taxi.duration; | ||
| 191 | + | ||
| 192 | + } | ||
| 193 | + | ||
| 194 | + | ||
| 195 | + } | ||
| 196 | + | ||
| 197 | + } | ||
| 198 | + | ||
| 199 | + f(); | ||
| 200 | + } | ||
| 201 | + }); | ||
| 202 | + | ||
| 203 | + })(); | ||
| 204 | + | ||
| 205 | + }, | ||
| 206 | + // 在地图上画出上行线路走向 | ||
| 207 | + drawingUpline01 : function (polylineArray,polyline_center,data) { | ||
| 208 | + var polyUpline01 = 'polyline' + '_' + data.sectionrouteId; | ||
| 209 | + // 创建线路走向 | ||
| 210 | + polyUpline01 = new BMap.Polyline(polylineArray, {strokeColor : "blue",strokeWeight : 6,strokeOpacity : 0.5}); | ||
| 211 | + polyUpline01.data = data; | ||
| 212 | + // 把折线添加到地图上 | ||
| 213 | + mapBValue.addOverlay(polyUpline01); | ||
| 214 | + var sectionPoint = []; | ||
| 215 | + // 线路单击事件 | ||
| 216 | + polyUpline01.addEventListener('click',function(e) { | ||
| 217 | + if(SpeedingMap.getIsEditStatus()) { | ||
| 218 | + layer.msg('请先保存正在编辑的路段信息...'); | ||
| 219 | + return false; | ||
| 220 | + } | ||
| 221 | + if(SpeedingMap.getIsCutSection()) { | ||
| 222 | + layer.msg('请先撤销所有切路段的点...'); | ||
| 223 | + return false; | ||
| 224 | + } | ||
| 225 | + polyUpline01.enableEditing(); | ||
| 226 | + SpeedingMap.setIsEditStatus(true); | ||
| 227 | + }); | ||
| 228 | + | ||
| 229 | + // 添加路段双击事件 | ||
| 230 | + polyUpline01.addEventListener("dblclick",function(e){ | ||
| 231 | + if(SpeedingMap.getIsCutSection()) { | ||
| 232 | + layer.msg('请先撤销所有切路段的点...'); | ||
| 233 | + return false; | ||
| 234 | + } | ||
| 235 | + SpeedingMap.setIsEditStatus(false); | ||
| 236 | + // 关闭 | ||
| 237 | + layer.closeAll(); | ||
| 238 | + polyUpline01.disableEditing(); | ||
| 239 | + EditSectionObj.setEitdSection(polyUpline01.data); | ||
| 240 | + // 获取折线坐标集合 | ||
| 241 | + var editPloyLineArray = polyUpline01.getPath(); | ||
| 242 | + EditSectionObj.setEitdBsectionVector(JSON.stringify(editPloyLineArray)); | ||
| 243 | + sectionList = []; | ||
| 244 | + var tbodyHtml = template('section_list',{list : sectionList}); | ||
| 245 | + // 截取路段 | ||
| 246 | + $('#section_table tbody').html(tbodyHtml); | ||
| 247 | + // 加载修改路段弹出层mobal页面 | ||
| 248 | + $.get('editsection.html', function(m){ | ||
| 249 | + $(pjaxContainer).append(m); | ||
| 250 | + $('#edit_section_mobal_cache').trigger('editSectionMobalCache_show', [SpeedingMap,GetAjaxData,EditSectionObj,PublicFunctions]); | ||
| 251 | + }); | ||
| 252 | + }); | ||
| 253 | + | ||
| 254 | + // 路段右击事件 | ||
| 255 | + var editSection = function(e,ee,marker){ | ||
| 256 | + if(SpeedingMap.getIsEditStatus()) { | ||
| 257 | + layer.msg('请先保存正在编辑的路段信息...'); | ||
| 258 | + return false; | ||
| 259 | + } | ||
| 260 | + var lng = e.lng; | ||
| 261 | + var lat = e.lat; | ||
| 262 | + var sectionName = null; | ||
| 263 | + var marker = new BMap.Marker(new BMap.Point(lng, lat)); // 创建点 | ||
| 264 | + marker.isFlag = true; | ||
| 265 | + if(pointIndex == 0) { | ||
| 266 | + sectionPoint[pointIndex] = {lng:lng , lat:lat}; | ||
| 267 | + layer.msg('进入切路段状态,请选择本路段的终点!'); | ||
| 268 | + mapBValue.addOverlay(marker);// 添加覆盖物 | ||
| 269 | + firstPoint = {lng:lng, lat:lat}; | ||
| 270 | + pointIndex++; | ||
| 271 | + EditSectionObj.setEitdSection(polyUpline01.data); | ||
| 272 | + // 获取折线坐标集合 | ||
| 273 | + var editPloyLineArray = polyUpline01.getPath(); | ||
| 274 | + EditSectionObj.setEitdBsectionVector(JSON.stringify(editPloyLineArray)); | ||
| 275 | + } else if (pointIndex > 0) { | ||
| 276 | + layer.prompt({title: '请输入路段名!'}, function(sectionName, index){ | ||
| 277 | + pointList = []; | ||
| 278 | + sectionPoint[pointIndex] = {lng:lng , lat:lat}; | ||
| 279 | + pointList[0] = sectionPoint[pointIndex-1]; | ||
| 280 | + pointList[1] = sectionPoint[pointIndex]; | ||
| 281 | + sectionList.push({name:sectionName, section:pointList}); | ||
| 282 | + layer.close(index); | ||
| 283 | + layer.msg('路段截取成功,请选择下一个路段的终点'); | ||
| 284 | + mapBValue.addOverlay(marker);// 添加覆盖物 | ||
| 285 | + var tbodyHtml = template('section_list',{list : sectionList}); | ||
| 286 | + // 截取路段 | ||
| 287 | + $('#section_table tbody').html(tbodyHtml); | ||
| 288 | + pointIndex++; | ||
| 289 | + }); | ||
| 290 | + } | ||
| 291 | + SpeedingMap.setIsCutSection(true); | ||
| 292 | + } | ||
| 293 | + var markerMenu=new BMap.ContextMenu(); | ||
| 294 | + markerMenu.addItem(new BMap.MenuItem('切路段',editSection.bind(polyUpline01))); | ||
| 295 | + polyUpline01.addContextMenu(markerMenu); | ||
| 296 | + | ||
| 297 | + | ||
| 298 | + var PanOptions_ ={noAnimation :true}; | ||
| 299 | + mapBValue.reset(); | ||
| 300 | + mapBValue.panTo(polyline_center,PanOptions_); | ||
| 301 | + mapBValue.panBy(500,-510,PanOptions_); | ||
| 302 | + mapBValue.setZoom(14); | ||
| 303 | + }, | ||
| 304 | + // 删除点刷新cutSectionTable | ||
| 305 | + refreshCutSectionTable : function() { | ||
| 306 | + var tbodyHtml = template('section_list',{list : sectionList}); | ||
| 307 | + $('#section_table tbody').html(tbodyHtml); | ||
| 308 | + }, | ||
| 309 | + // 删除点刷新覆盖物 | ||
| 310 | + deleteCutSectionPoint : function(point) { | ||
| 311 | + var lng = point.lng; | ||
| 312 | + var lat = point.lat; | ||
| 313 | + var allOverlay = mapBValue.getOverlays(); | ||
| 314 | + // 删除最后一个点 | ||
| 315 | + for (var i = 0; i < allOverlay.length -1; i++){ | ||
| 316 | + if(allOverlay[i].isFlag) { | ||
| 317 | + if(allOverlay[i].point.lng == lng && allOverlay[i].point.lat == lat){ | ||
| 318 | + mapBValue.removeOverlay(allOverlay[i]); | ||
| 319 | + break; | ||
| 320 | + } | ||
| 321 | + } | ||
| 322 | + } | ||
| 323 | + }, | ||
| 324 | + /** 在地图上画点 @param:<point_center:中心坐标点> */ | ||
| 325 | + drawingUpStationPoint : function(point_center,stationName,s) { | ||
| 326 | + | ||
| 327 | + // 自定义标注物图片 | ||
| 328 | + var icon_target = new BMap.Icon('/pages/base/stationroute/css/img/gjzd.png',new BMap.Size(10, 10)); | ||
| 329 | + | ||
| 330 | + var html2 = '<div style="position: absolute; margin: 0pt; padding: 0pt; width: 160px; height: 26px; left: -10px; top: -35px; overflow: hidden;">' | ||
| 331 | + + '<img class="rm3_image" style="border:none;left:0px; top:0px; position:absolute;" src="/pages/base/stationroute/css/img/back160.png">' | ||
| 332 | + + '</div>' | ||
| 333 | + + '<label class=" BMapLabel" unselectable="on" style="position: absolute; -moz-user-select: none; display: inline; cursor: inherit; border: 0px none; padding: 2px 1px 1px; white-space: nowrap; font: 12px arial,simsun; z-index: 80; color: rgb(255, 102, 0); left: 15px; top: -35px;"><span style="float: left; color: #fdfdfd; margin-left: -22px; font-size: 6px;">'+ s+'</span>'+ stationName+'</label>'; | ||
| 334 | + | ||
| 335 | + | ||
| 336 | + var myRichMarker1 = new BMapLib.RichMarker(html2, point_center,{ | ||
| 337 | + "anchor" : new BMap.Size(-10,8), | ||
| 338 | + "enableDragging" : true}); | ||
| 339 | + | ||
| 340 | + | ||
| 341 | + myRichMarker1.disableDragging(); | ||
| 342 | + mapBValue.addOverlay(myRichMarker1); | ||
| 343 | + | ||
| 344 | + | ||
| 345 | + // 创建标注物 | ||
| 346 | + marker = new BMap.Marker(point_center,{icon : icon_target}); | ||
| 347 | + | ||
| 348 | + // 允许覆盖物在map.clearOverlays方法中被清除。 | ||
| 349 | + marker.enableMassClear(); | ||
| 350 | + | ||
| 351 | + mapBValue.addOverlay(marker); | ||
| 352 | + }, | ||
| 353 | + | ||
| 354 | + // 根据站点坐标匹配库中的公交站点(手动规划) | ||
| 355 | + stationsPointsToLibraryPoint : function(arra,callback) { | ||
| 356 | + // 获取长度 | ||
| 357 | + var len = arra.length; | ||
| 358 | + var station = {}; | ||
| 359 | + var stationList = []; | ||
| 360 | + (function(){ | ||
| 361 | + if (!arguments.callee.count) { | ||
| 362 | + arguments.callee.count = 0; | ||
| 363 | + } | ||
| 364 | + arguments.callee.count++; | ||
| 365 | + var index = parseInt(arguments.callee.count) - 1; | ||
| 366 | + if (index >= len) { | ||
| 367 | + callback && callback(stationList); | ||
| 368 | + return ; | ||
| 369 | + } | ||
| 370 | + var f = arguments.callee; | ||
| 371 | + station = arra[index]; | ||
| 372 | + if(arra[index].name!=''){ | ||
| 373 | + | ||
| 374 | + $.get('/station/matchStation',station,function(resultStation) { | ||
| 375 | + stationList.push({name:resultStation.name ,wgs:arra[index].wgs,potion:{lng:resultStation.potion_lng, lat:resultStation.potion_lat}, isHave:resultStation.isHave , id:resultStation.id}); | ||
| 376 | + f(); | ||
| 377 | + }); | ||
| 378 | + }else { | ||
| 379 | + f(); | ||
| 380 | + } | ||
| 381 | + })() | ||
| 382 | + }, | ||
| 383 | + clearMarkAndOverlays : function() { | ||
| 384 | + | ||
| 385 | + // 清楚地图覆盖物 | ||
| 386 | + mapBValue.clearOverlays(); | ||
| 387 | + | ||
| 388 | + mapBValue.removeOverlay(); | ||
| 389 | + | ||
| 390 | + } | ||
| 391 | + | ||
| 392 | + } | ||
| 393 | + | ||
| 394 | + return Bmap; | ||
| 395 | + | ||
| 396 | }(); | 396 | }(); |
| 397 | \ No newline at end of file | 397 | \ No newline at end of file |
src/main/resources/static/pages/forms/statement/scheduleAnaly.html
| @@ -42,7 +42,7 @@ | @@ -42,7 +42,7 @@ | ||
| 42 | </div> | 42 | </div> |
| 43 | <div style="display: inline-block;margin-left: 10px;"> | 43 | <div style="display: inline-block;margin-left: 10px;"> |
| 44 | <span class="item-label" style="width: 80px;">班次类型: </span> | 44 | <span class="item-label" style="width: 80px;">班次类型: </span> |
| 45 | - <select class="form-control" name="line" id="bcType" style="width: 150px;"> | 45 | + <select class="form-control" name="bcType" id="bcType" style="width: 150px;"> |
| 46 | <option value="0">全部班次</option> | 46 | <option value="0">全部班次</option> |
| 47 | <option value="1">全程</option> | 47 | <option value="1">全程</option> |
| 48 | <option value="2">区间</option> | 48 | <option value="2">区间</option> |
src/main/resources/static/pages/home.html
| @@ -59,19 +59,20 @@ | @@ -59,19 +59,20 @@ | ||
| 59 | } | 59 | } |
| 60 | </style> | 60 | </style> |
| 61 | <div class="system_change_log"> | 61 | <div class="system_change_log"> |
| 62 | - <h2 style="text-indent: 35px;margin: 10px 0 5px;">2022-08-29 更新说明 Changelog</h2> | 62 | + <h2 style="text-indent: 35px;margin: 10px 0 5px;">2022-06-13 更新说明 Changelog</h2> |
| 63 | <br><br> | 63 | <br><br> |
| 64 | <ul > | 64 | <ul > |
| 65 | <li class="sub_title"><h6>报表</h6></li> | 65 | <li class="sub_title"><h6>报表</h6></li> |
| 66 | - <li><span class="label s_c_change">修改</span>1.统计报表->路单线路明细月报、年报 加入氢能源的统计内容</li> | ||
| 67 | - <!--<li class="sub_title"><h6>基础信息</h6></li> | 66 | + <li><span class="label s_c_change">修改</span>1.统计报表->路单线路明细月报、年报 中耗电统计值偏离的问题</li> |
| 67 | + <li><span class="label s_c_change">修改</span>2.统计报表->"(班次)到离站"报表,新增历史站点版本数据查询,解决站点顺序的问题</li> | ||
| 68 | + <li class="sub_title"><h6>基础信息</h6></li> | ||
| 68 | <li><span class="label s_c_change">修改</span>1.调度系统车辆信息与车辆库车辆信息保持同步,调度系统取消车辆的新增、编辑功能</li> | 69 | <li><span class="label s_c_change">修改</span>1.调度系统车辆信息与车辆库车辆信息保持同步,调度系统取消车辆的新增、编辑功能</li> |
| 69 | <li><span class="label s_c_change">修改</span>2.调度系统人员信息与人事系统人员信息保持同步,调度系统取消人员的新增、编辑功能</li> | 70 | <li><span class="label s_c_change">修改</span>2.调度系统人员信息与人事系统人员信息保持同步,调度系统取消人员的新增、编辑功能</li> |
| 70 | <li class="sub_title"><h6>运管处</h6></li> | 71 | <li class="sub_title"><h6>运管处</h6></li> |
| 71 | <li><span class="label s_c_change">修改</span>1.电子路单上传至运管处时采用多次上传降低上传失败率</li> | 72 | <li><span class="label s_c_change">修改</span>1.电子路单上传至运管处时采用多次上传降低上传失败率</li> |
| 72 | <li class="sub_title"><h6>线调</h6></li> | 73 | <li class="sub_title"><h6>线调</h6></li> |
| 73 | <li><span class="label s_c_change">修改</span>1.线调->车载设备->设备管理 中"最后GPS时间"列显示异常修正</li> | 74 | <li><span class="label s_c_change">修改</span>1.线调->车载设备->设备管理 中"最后GPS时间"列显示异常修正</li> |
| 74 | - <li><span class="label s_c_change">修改</span>2.无排班线路添加"临加班次"功能</li>--> | 75 | + <li><span class="label s_c_change">修改</span>2.无排班线路添加"临加班次"功能</li> |
| 75 | </ul> | 76 | </ul> |
| 76 | 77 | ||
| 77 | </div> | 78 | </div> |
src/main/resources/static/pages/mapmonitor/real/js/map_platform_old.js
| 1 | -var realMap = (function() { | ||
| 2 | - | ||
| 3 | - function getJSONP(url, data ,callback){ | ||
| 4 | - $.ajax({ | ||
| 5 | - url:url, | ||
| 6 | - data: data, | ||
| 7 | - dataType:'jsonp', | ||
| 8 | - success:callback, | ||
| 9 | - error: function(e){ | ||
| 10 | - alert('error: jsonp,' + url); | ||
| 11 | - } | ||
| 12 | - }); | ||
| 13 | - } | ||
| 14 | - | ||
| 15 | - /** | ||
| 16 | - * 透明点,用于替换隐藏百度Marker的icon | ||
| 17 | - */ | ||
| 18 | - var tmIcon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKTWlDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVN3WJP3Fj7f92UPVkLY8LGXbIEAIiOsCMgQWaIQkgBhhBASQMWFiApWFBURnEhVxILVCkidiOKgKLhnQYqIWotVXDjuH9yntX167+3t+9f7vOec5/zOec8PgBESJpHmomoAOVKFPDrYH49PSMTJvYACFUjgBCAQ5svCZwXFAADwA3l4fnSwP/wBr28AAgBw1S4kEsfh/4O6UCZXACCRAOAiEucLAZBSAMguVMgUAMgYALBTs2QKAJQAAGx5fEIiAKoNAOz0ST4FANipk9wXANiiHKkIAI0BAJkoRyQCQLsAYFWBUiwCwMIAoKxAIi4EwK4BgFm2MkcCgL0FAHaOWJAPQGAAgJlCLMwAIDgCAEMeE80DIEwDoDDSv+CpX3CFuEgBAMDLlc2XS9IzFLiV0Bp38vDg4iHiwmyxQmEXKRBmCeQinJebIxNI5wNMzgwAABr50cH+OD+Q5+bk4eZm52zv9MWi/mvwbyI+IfHf/ryMAgQAEE7P79pf5eXWA3DHAbB1v2upWwDaVgBo3/ldM9sJoFoK0Hr5i3k4/EAenqFQyDwdHAoLC+0lYqG9MOOLPv8z4W/gi372/EAe/tt68ABxmkCZrcCjg/1xYW52rlKO58sEQjFu9+cj/seFf/2OKdHiNLFcLBWK8ViJuFAiTcd5uVKRRCHJleIS6X8y8R+W/QmTdw0ArIZPwE62B7XLbMB+7gECiw5Y0nYAQH7zLYwaC5EAEGc0Mnn3AACTv/mPQCsBAM2XpOMAALzoGFyolBdMxggAAESggSqwQQcMwRSswA6cwR28wBcCYQZEQAwkwDwQQgbkgBwKoRiWQRlUwDrYBLWwAxqgEZrhELTBMTgN5+ASXIHrcBcGYBiewhi8hgkEQcgIE2EhOogRYo7YIs4IF5mOBCJhSDSSgKQg6YgUUSLFyHKkAqlCapFdSCPyLXIUOY1cQPqQ28ggMor8irxHMZSBslED1AJ1QLmoHxqKxqBz0XQ0D12AlqJr0Rq0Hj2AtqKn0UvodXQAfYqOY4DRMQ5mjNlhXIyHRWCJWBomxxZj5Vg1Vo81Yx1YN3YVG8CeYe8IJAKLgBPsCF6EEMJsgpCQR1hMWEOoJewjtBK6CFcJg4Qxwicik6hPtCV6EvnEeGI6sZBYRqwm7iEeIZ4lXicOE1+TSCQOyZLkTgohJZAySQtJa0jbSC2kU6Q+0hBpnEwm65Btyd7kCLKArCCXkbeQD5BPkvvJw+S3FDrFiOJMCaIkUqSUEko1ZT/lBKWfMkKZoKpRzame1AiqiDqfWkltoHZQL1OHqRM0dZolzZsWQ8ukLaPV0JppZ2n3aC/pdLoJ3YMeRZfQl9Jr6Afp5+mD9HcMDYYNg8dIYigZaxl7GacYtxkvmUymBdOXmchUMNcyG5lnmA+Yb1VYKvYqfBWRyhKVOpVWlX6V56pUVXNVP9V5qgtUq1UPq15WfaZGVbNQ46kJ1Bar1akdVbupNq7OUndSj1DPUV+jvl/9gvpjDbKGhUaghkijVGO3xhmNIRbGMmXxWELWclYD6yxrmE1iW7L57Ex2Bfsbdi97TFNDc6pmrGaRZp3mcc0BDsax4PA52ZxKziHODc57LQMtPy2x1mqtZq1+rTfaetq+2mLtcu0W7eva73VwnUCdLJ31Om0693UJuja6UbqFutt1z+o+02PreekJ9cr1Dund0Uf1bfSj9Rfq79bv0R83MDQINpAZbDE4Y/DMkGPoa5hpuNHwhOGoEctoupHEaKPRSaMnuCbuh2fjNXgXPmasbxxirDTeZdxrPGFiaTLbpMSkxeS+Kc2Ua5pmutG003TMzMgs3KzYrMnsjjnVnGueYb7ZvNv8jYWlRZzFSos2i8eW2pZ8ywWWTZb3rJhWPlZ5VvVW16xJ1lzrLOtt1ldsUBtXmwybOpvLtqitm63Edptt3xTiFI8p0in1U27aMez87ArsmuwG7Tn2YfYl9m32zx3MHBId1jt0O3xydHXMdmxwvOuk4TTDqcSpw+lXZxtnoXOd8zUXpkuQyxKXdpcXU22niqdun3rLleUa7rrStdP1o5u7m9yt2W3U3cw9xX2r+00umxvJXcM970H08PdY4nHM452nm6fC85DnL152Xlle+70eT7OcJp7WMG3I28Rb4L3Le2A6Pj1l+s7pAz7GPgKfep+Hvqa+It89viN+1n6Zfgf8nvs7+sv9j/i/4XnyFvFOBWABwQHlAb2BGoGzA2sDHwSZBKUHNQWNBbsGLww+FUIMCQ1ZH3KTb8AX8hv5YzPcZyya0RXKCJ0VWhv6MMwmTB7WEY6GzwjfEH5vpvlM6cy2CIjgR2yIuB9pGZkX+X0UKSoyqi7qUbRTdHF09yzWrORZ+2e9jvGPqYy5O9tqtnJ2Z6xqbFJsY+ybuIC4qriBeIf4RfGXEnQTJAntieTE2MQ9ieNzAudsmjOc5JpUlnRjruXcorkX5unOy553PFk1WZB8OIWYEpeyP+WDIEJQLxhP5aduTR0T8oSbhU9FvqKNolGxt7hKPJLmnVaV9jjdO31D+miGT0Z1xjMJT1IreZEZkrkj801WRNberM/ZcdktOZSclJyjUg1plrQr1zC3KLdPZisrkw3keeZtyhuTh8r35CP5c/PbFWyFTNGjtFKuUA4WTC+oK3hbGFt4uEi9SFrUM99m/ur5IwuCFny9kLBQuLCz2Lh4WfHgIr9FuxYji1MXdy4xXVK6ZHhp8NJ9y2jLspb9UOJYUlXyannc8o5Sg9KlpUMrglc0lamUycturvRauWMVYZVkVe9ql9VbVn8qF5VfrHCsqK74sEa45uJXTl/VfPV5bdra3kq3yu3rSOuk626s91m/r0q9akHV0IbwDa0b8Y3lG19tSt50oXpq9Y7NtM3KzQM1YTXtW8y2rNvyoTaj9nqdf13LVv2tq7e+2Sba1r/dd3vzDoMdFTve75TsvLUreFdrvUV99W7S7oLdjxpiG7q/5n7duEd3T8Wej3ulewf2Re/ranRvbNyvv7+yCW1SNo0eSDpw5ZuAb9qb7Zp3tXBaKg7CQeXBJ9+mfHvjUOihzsPcw83fmX+39QjrSHkr0jq/dawto22gPaG97+iMo50dXh1Hvrf/fu8x42N1xzWPV56gnSg98fnkgpPjp2Snnp1OPz3Umdx590z8mWtdUV29Z0PPnj8XdO5Mt1/3yfPe549d8Lxw9CL3Ytslt0utPa49R35w/eFIr1tv62X3y+1XPK509E3rO9Hv03/6asDVc9f41y5dn3m978bsG7duJt0cuCW69fh29u0XdwruTNxdeo94r/y+2v3qB/oP6n+0/rFlwG3g+GDAYM/DWQ/vDgmHnv6U/9OH4dJHzEfVI0YjjY+dHx8bDRq98mTOk+GnsqcTz8p+Vv9563Or59/94vtLz1j82PAL+YvPv655qfNy76uprzrHI8cfvM55PfGm/K3O233vuO+638e9H5ko/ED+UPPR+mPHp9BP9z7nfP78L/eE8/sl0p8zAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAAbSURBVHjaYvz//z8DAwMDAxMDFAAAAAD//wMAMAYDAW/BVI8AAAAASUVORK5CYII='; | ||
| 19 | - | ||
| 20 | - var REAL_BAIDU_TEXT = '百度地图', REAL_GAODE_TEXT = '高德地图'; | ||
| 21 | - | ||
| 22 | - // 中心点 (上海市浦东新区政府) | ||
| 23 | - var CENTER_POINT = { | ||
| 24 | - lng : 121.544336, | ||
| 25 | - lat : 31.221315 | ||
| 26 | - }; | ||
| 27 | - | ||
| 28 | - // 图层容器 | ||
| 29 | - var mapContainer = $('#mapContainer'); | ||
| 30 | - // 路况按钮 | ||
| 31 | - var trafficBtn = $('#trafficItem'); | ||
| 32 | - | ||
| 33 | - var storage = window.localStorage; | ||
| 34 | - | ||
| 35 | - var currentMap; | ||
| 36 | - | ||
| 37 | - var city = "上海"; | ||
| 38 | - | ||
| 39 | - //百度API Key | ||
| 40 | - var bdKey = 'IGGrr4UjwIYzatoCRFKEL8sT'; | ||
| 41 | - | ||
| 42 | - var bd_gps_info_win_opts = { | ||
| 43 | - width : 190, | ||
| 44 | - height: 255, | ||
| 45 | - enableMessage:true | ||
| 46 | - }; | ||
| 47 | - | ||
| 48 | - //线路路由 | ||
| 49 | - var polylines; | ||
| 50 | - | ||
| 51 | - //百度 -轨迹回放点聚合 | ||
| 52 | - //var historyClusterer; | ||
| 53 | - | ||
| 54 | - var markerClusterer; | ||
| 55 | - | ||
| 56 | - //设备号和marker对照 | ||
| 57 | - var markersMap; | ||
| 58 | - var real_map = { | ||
| 59 | - getMap: function(){ | ||
| 60 | - return currentMap; | ||
| 61 | - }, | ||
| 62 | - init: function(){ | ||
| 63 | - var m = storage.getItem('real_map'); | ||
| 64 | - if(m && m == REAL_GAODE_TEXT) | ||
| 65 | - real_map.gaode.init(); | ||
| 66 | - else | ||
| 67 | - real_map.baidu.init(); | ||
| 68 | - }, | ||
| 69 | - //百度地图 | ||
| 70 | - baidu : { | ||
| 71 | - //初始化 | ||
| 72 | - init : function() { | ||
| 73 | - real_map.setText(REAL_BAIDU_TEXT); | ||
| 74 | - | ||
| 75 | - var map = new BMap.Map(mapContainer[0]); | ||
| 76 | - //中心点和缩放级别 | ||
| 77 | - map.centerAndZoom(new BMap.Point(CENTER_POINT.lng,CENTER_POINT.lat), 15); | ||
| 78 | - map.enableScrollWheelZoom(); | ||
| 79 | - //加载完成 | ||
| 80 | - map.addEventListener("tilesloaded", function() { | ||
| 81 | - layer.closeAll(); | ||
| 82 | - storage.setItem('real_map', REAL_BAIDU_TEXT); | ||
| 83 | - }); | ||
| 84 | - | ||
| 85 | - // 路况控件 | ||
| 86 | - var ctrl = new BMapLib.TrafficControl(); | ||
| 87 | - map.addControl(ctrl); | ||
| 88 | - | ||
| 89 | - //historyClusterer = new BMapLib.MarkerClusterer(map, {isAverangeCenter : true,minClusterSize : 2}) | ||
| 90 | - var isVisible; | ||
| 91 | - trafficBtn.on('click', function() { | ||
| 92 | - if (isVisible) { | ||
| 93 | - ctrl.hide(); | ||
| 94 | - isVisible = false; | ||
| 95 | - //调整线路路由透明度 | ||
| 96 | - $.each(polylines, function(){ | ||
| 97 | - this.setStrokeOpacity(0.5); | ||
| 98 | - }); | ||
| 99 | - } else { | ||
| 100 | - ctrl.show(); | ||
| 101 | - isVisible = true; | ||
| 102 | - //调整线路路由透明度 | ||
| 103 | - $.each(polylines, function(){ | ||
| 104 | - this.setStrokeOpacity(0.1); | ||
| 105 | - }); | ||
| 106 | - } | ||
| 107 | - }); | ||
| 108 | - //百度路况控件自身关闭按钮 | ||
| 109 | - $('.portlet-fullscreen').on('click', '.maplibTc .maplibTcClose', function(){ | ||
| 110 | - isVisible = false; | ||
| 111 | - //调整线路路由透明度 | ||
| 112 | - $.each(polylines, function(){ | ||
| 113 | - this.setStrokeOpacity(0.5); | ||
| 114 | - }); | ||
| 115 | - }); | ||
| 116 | - | ||
| 117 | - $('#tcWrap.maplibTc').addClass('animated bounceInLeft'); | ||
| 118 | - $('.maplibTcBtn_deskTop.anchorTR').remove(); | ||
| 119 | - | ||
| 120 | - //保存当前地图实例和名称 | ||
| 121 | - currentMap = { | ||
| 122 | - map: map, | ||
| 123 | - mapName: REAL_BAIDU_TEXT, | ||
| 124 | - fName : 'baidu' | ||
| 125 | - } | ||
| 126 | - | ||
| 127 | - }, | ||
| 128 | - clear: function(){ | ||
| 129 | - currentMap.map.clearOverlays(); | ||
| 130 | - markerClusterer && markerClusterer.clearMarkers(); | ||
| 131 | - | ||
| 132 | - }, | ||
| 133 | - change : function() { | ||
| 134 | - if(currentMap.mapName == REAL_BAIDU_TEXT) | ||
| 135 | - return; | ||
| 136 | - | ||
| 137 | - showMsg(REAL_BAIDU_TEXT); | ||
| 138 | - | ||
| 139 | - real_map.destroy(); | ||
| 140 | - real_map.baidu.init(); | ||
| 141 | - }, | ||
| 142 | - autocomplete: function(input, cb){ | ||
| 143 | - var ac = new BMap.Autocomplete({ | ||
| 144 | - 'location' : realMap.getMap().map, | ||
| 145 | - 'input': input, | ||
| 146 | - 'onSearchComplete': function(result){ | ||
| 147 | - //隐藏默认的提示框 | ||
| 148 | - ac.hide(); | ||
| 149 | - cb && cb({type: 'baidu', result: result.wr}); | ||
| 150 | - } | ||
| 151 | - }); | ||
| 152 | - | ||
| 153 | - $('#' + input).on('keyup', function(){ | ||
| 154 | - if(this.value == ''){ | ||
| 155 | - $('.search_result').html(''); | ||
| 156 | - return; | ||
| 157 | - } | ||
| 158 | - }); | ||
| 159 | - | ||
| 160 | - }, | ||
| 161 | - setPlace: function(val){ | ||
| 162 | - var map = currentMap.map; | ||
| 163 | - map.clearOverlays(); | ||
| 164 | - var local = new BMap.LocalSearch(map, { | ||
| 165 | - onSearchComplete: function(){ | ||
| 166 | - var poi = local.getResults().getPoi(0); | ||
| 167 | - if(!poi){ | ||
| 168 | - return; | ||
| 169 | - } | ||
| 170 | - var pp = poi.point; | ||
| 171 | - map.centerAndZoom(pp, 18); | ||
| 172 | - map.addOverlay(new BMap.Marker(pp)); | ||
| 173 | - } | ||
| 174 | - }); | ||
| 175 | - | ||
| 176 | - local.search(val); | ||
| 177 | - }, | ||
| 178 | - drawLine: function(route){ | ||
| 179 | - var map = currentMap.map; | ||
| 180 | - map.clearOverlays(); | ||
| 181 | - polylines = []; | ||
| 182 | - //画线路 | ||
| 183 | - //从localStorage里读取路由信息 | ||
| 184 | - //var route = JSON.parse(storage.getItem(lineCode + '_route')); | ||
| 185 | - var upLineOps = {strokeColor:"blue", strokeWeight:6, strokeOpacity:0.5} | ||
| 186 | - ,downLineOps = {strokeColor:"red", strokeWeight:6, strokeOpacity:0.5}; | ||
| 187 | - | ||
| 188 | - var upPos = [], downPos = [], tempArray; | ||
| 189 | - //上行 | ||
| 190 | - if(route.up){ | ||
| 191 | - $.each(route.up.split(','), function(){ | ||
| 192 | - tempArray = this.split(' '); | ||
| 193 | - upPos.push(new BMap.Point(tempArray[0], tempArray[1])); | ||
| 194 | - }); | ||
| 195 | - | ||
| 196 | - var upLine = new BMap.Polyline(upPos, upLineOps); | ||
| 197 | - map.addOverlay(upLine); | ||
| 198 | - | ||
| 199 | - polylines.push(upLine); | ||
| 200 | - map.panTo(upPos[parseInt(upPos.length / 2)]); | ||
| 201 | - } | ||
| 202 | - //下行 | ||
| 203 | - if(route.down){ | ||
| 204 | - $.each(route.down.split(','), function(){ | ||
| 205 | - tempArray = this.split(' '); | ||
| 206 | - downPos.push(new BMap.Point(tempArray[0], tempArray[1])); | ||
| 207 | - }); | ||
| 208 | - | ||
| 209 | - var downLine = new BMap.Polyline(downPos, downLineOps); | ||
| 210 | - map.addOverlay(downLine); | ||
| 211 | - polylines.push(downLine); | ||
| 212 | - | ||
| 213 | - } | ||
| 214 | - }, | ||
| 215 | - //批量将GPS信号画到地图上 | ||
| 216 | - drawGpsMarker: function(gpsList){ | ||
| 217 | - markersMap = {}; | ||
| 218 | - var map = currentMap.map; | ||
| 219 | - | ||
| 220 | - markerClusterer && markerClusterer.clearMarkers(); | ||
| 221 | - markerClusterer = new BMapLib.MarkerClusterer(map, {isAverangeCenter : true,minClusterSize : 3}); | ||
| 222 | - real_map.baidu.coordsConvert(gpsList, function(){ | ||
| 223 | - //绘制车辆位置 | ||
| 224 | - var marker; | ||
| 225 | - $.each(gpsList, function(i, gpsData){ | ||
| 226 | - marker = createBDMarkerByGps(gpsData) | ||
| 227 | - map.addOverlay(marker); | ||
| 228 | - //marker加入点聚合 | ||
| 229 | - markerClusterer.addMarker(marker); | ||
| 230 | - | ||
| 231 | - markersMap[gpsData.deviceId] = marker; | ||
| 232 | - }); | ||
| 233 | - | ||
| 234 | - }); | ||
| 235 | - }, | ||
| 236 | - goToMarker: function(deviceId){ | ||
| 237 | - var m = markersMap[deviceId]; | ||
| 238 | - if(m){ | ||
| 239 | - currentMap.map.panTo(m.point); | ||
| 240 | - setTimeout(function(){ | ||
| 241 | - bdOpenWindow(m); | ||
| 242 | - }, 500); | ||
| 243 | - } | ||
| 244 | - }, | ||
| 245 | - coordsConvert: function(list, cb){ | ||
| 246 | - if(list.length > 100) | ||
| 247 | - list = list.slice(0, 100); | ||
| 248 | - | ||
| 249 | - var coords = ''; | ||
| 250 | - //拼接GPS坐标,一次性转换 | ||
| 251 | - for (var i = 0, item; item = list[i++];) | ||
| 252 | - coords += item.lon + ',' + item.lat + ';'; | ||
| 253 | - coords = coords.substring(0, coords.length - 1); | ||
| 254 | - getJSONP('http://api.map.baidu.com/geoconv/v1/',{coords: coords, ak: bdKey} | ||
| 255 | - ,function(rt){ | ||
| 256 | - $.each(rt.result, function(j, bdCoord){ | ||
| 257 | - list[j].bd_coord = bdCoord; | ||
| 258 | - }); | ||
| 259 | - cb&&cb(); | ||
| 260 | - }); | ||
| 261 | - }, | ||
| 262 | - //绘制轨迹回放 marker | ||
| 263 | - addHistoryMarker: function(gps){ | ||
| 264 | - | ||
| 265 | - var marker = bdHistoryMarker(gps); | ||
| 266 | - currentMap.map.addOverlay(marker); | ||
| 267 | - | ||
| 268 | - //historyClusterer.addMarker(marker); | ||
| 269 | - return marker; | ||
| 270 | - }, | ||
| 271 | - //移动marker | ||
| 272 | - moveMarker: function(marker , gps){ | ||
| 273 | - marker.setPosition(new BMap.Point(gps.bd_lon, gps.bd_lat)); | ||
| 274 | - //重新设置颜色 | ||
| 275 | - marker.getLabel().setStyle({borderColor: bgColor(gps), backgroundColor: bgColor(gps)}); | ||
| 276 | - }, | ||
| 277 | - //居中marker | ||
| 278 | - markerToCenter: function(marker){ | ||
| 279 | - currentMap.map.panTo(marker.getPosition()); | ||
| 280 | - }, | ||
| 281 | - //删除marker | ||
| 282 | - removeMarker: function(marker){ | ||
| 283 | - currentMap.map.removeOverlay(marker); | ||
| 284 | - } | ||
| 285 | - }, | ||
| 286 | - //高德地图 | ||
| 287 | - gaode : { | ||
| 288 | - init : function() { | ||
| 289 | - var mapLoadAnim = '<div class="sk-cube-grid _center">'+ | ||
| 290 | - '<div class="sk-cube sk-cube1"></div>'+ | ||
| 291 | - '<div class="sk-cube sk-cube2"></div>'+ | ||
| 292 | - '<div class="sk-cube sk-cube3"></div>'+ | ||
| 293 | - '<div class="sk-cube sk-cube4"></div>'+ | ||
| 294 | - '<div class="sk-cube sk-cube5"></div>'+ | ||
| 295 | - '<div class="sk-cube sk-cube6"></div>'+ | ||
| 296 | - '<div class="sk-cube sk-cube7"></div>'+ | ||
| 297 | - '<div class="sk-cube sk-cube8"></div>'+ | ||
| 298 | - '<div class="sk-cube sk-cube9"></div>'+ | ||
| 299 | - '</div>'; | ||
| 300 | - | ||
| 301 | - mapContainer.html(mapLoadAnim); | ||
| 302 | - | ||
| 303 | - real_map.gaode.setStyle(); | ||
| 304 | - real_map.setText(REAL_GAODE_TEXT); | ||
| 305 | - | ||
| 306 | - var map = new AMap.Map(mapContainer[0]); | ||
| 307 | - // 地图中心和缩放级别 | ||
| 308 | - map.setZoomAndCenter(14, [ CENTER_POINT.lng,CENTER_POINT.lat ]); | ||
| 309 | - //加载完成 | ||
| 310 | - AMap.event.addListener(map, 'complete', function() { | ||
| 311 | - layer.closeAll(); | ||
| 312 | - storage.setItem('real_map', REAL_GAODE_TEXT); | ||
| 313 | - $('.sk-cube-grid._center').remove(); | ||
| 314 | - }); | ||
| 315 | - | ||
| 316 | - // 实时路况图层 | ||
| 317 | - var trafficLayer = new AMap.TileLayer.Traffic(); | ||
| 318 | - trafficLayer.setMap(map); | ||
| 319 | - trafficLayer.hide(); | ||
| 320 | - | ||
| 321 | - var isVisible; | ||
| 322 | - trafficBtn.on('click', function() { | ||
| 323 | - if (isVisible) { | ||
| 324 | - trafficLayer.hide(); | ||
| 325 | - isVisible = false; | ||
| 326 | - $(this).removeClass('active'); | ||
| 327 | - | ||
| 328 | - //调整线路路由透明度 | ||
| 329 | - $.each(polylines, function(){ | ||
| 330 | - this.setOptions({strokeOpacity: 0.5}); | ||
| 331 | - }); | ||
| 332 | - } else { | ||
| 333 | - trafficLayer.show(); | ||
| 334 | - isVisible = true; | ||
| 335 | - $(this).addClass('active'); | ||
| 336 | - | ||
| 337 | - //调整线路路由透明度 | ||
| 338 | - $.each(polylines, function(){ | ||
| 339 | - this.setOptions({strokeOpacity: 0.1}); | ||
| 340 | - }); | ||
| 341 | - } | ||
| 342 | - }); | ||
| 343 | - | ||
| 344 | - //保存当前地图实例和名称 | ||
| 345 | - currentMap = { | ||
| 346 | - map: map, | ||
| 347 | - mapName: REAL_GAODE_TEXT, | ||
| 348 | - fName : 'gaode' | ||
| 349 | - } | ||
| 350 | - | ||
| 351 | - }, | ||
| 352 | - change : function() { | ||
| 353 | - if(currentMap.mapName == REAL_GAODE_TEXT) | ||
| 354 | - return; | ||
| 355 | - | ||
| 356 | - showMsg(REAL_GAODE_TEXT); | ||
| 357 | - | ||
| 358 | - real_map.destroy(); | ||
| 359 | - real_map.gaode.init(); | ||
| 360 | - }, | ||
| 361 | - setStyle : function() { | ||
| 362 | - $('.mapRightWrap').addClass('gaode'); | ||
| 363 | - $('.mapTools').addClass('gaode'); | ||
| 364 | - $('.leftUtils').addClass('gaode'); | ||
| 365 | - }, | ||
| 366 | - clearStyle : function() { | ||
| 367 | - $('.mapRightWrap').removeClass('gaode'); | ||
| 368 | - $('.mapTools').removeClass('gaode'); | ||
| 369 | - $('.leftUtils').removeClass('gaode'); | ||
| 370 | - }, | ||
| 371 | - autocomplete: function(input, cb){ | ||
| 372 | - | ||
| 373 | - AMap.plugin('AMap.Autocomplete',function(){ | ||
| 374 | - var autoOptions = { | ||
| 375 | - city: city | ||
| 376 | - }; | ||
| 377 | - autocomplete= new AMap.Autocomplete(autoOptions); | ||
| 378 | - | ||
| 379 | - $('#' + input).on('keyup', function(){ | ||
| 380 | - if(this.value == ''){ | ||
| 381 | - $('.search_result').html(''); | ||
| 382 | - return; | ||
| 383 | - } | ||
| 384 | - autocomplete.search(this.value, function(status, result){ | ||
| 385 | - cb & cb({type: 'gaode', result: result.tips}); | ||
| 386 | - }); | ||
| 387 | - }); | ||
| 388 | - }); | ||
| 389 | - }, | ||
| 390 | - setPlace: function(val){ | ||
| 391 | - var map = currentMap.map; | ||
| 392 | - | ||
| 393 | - AMap.plugin(['AMap.PlaceSearch'],function(){ | ||
| 394 | - var placeSearch = new AMap.PlaceSearch({ | ||
| 395 | - city:city, | ||
| 396 | - map:map, | ||
| 397 | - pageSize: 1 | ||
| 398 | - }); | ||
| 399 | - | ||
| 400 | - placeSearch.search(val); | ||
| 401 | - }); | ||
| 402 | - }, | ||
| 403 | - drawLine: function(route){ | ||
| 404 | - polylines = []; | ||
| 405 | - var map = currentMap.map; | ||
| 406 | - map.clearMap(); | ||
| 407 | - | ||
| 408 | - //var route = JSON.parse(storage.getItem(lineCode + '_route')); | ||
| 409 | - var upArr = [], downArr = []; | ||
| 410 | - | ||
| 411 | - var upLineOps = {path: upArr, strokeColor:"blue", strokeWeight:6, strokeOpacity:0.5} | ||
| 412 | - ,downLineOps = {path: downArr, strokeColor:"red", strokeWeight:6, strokeOpacity:0.5}; | ||
| 413 | - | ||
| 414 | - //上行 | ||
| 415 | - if(route.up){ | ||
| 416 | - $.each(route.up_gcj.split(','), function(){ | ||
| 417 | - tempArray = this.split(' '); | ||
| 418 | - upArr.push([tempArray[0], tempArray[1]]); | ||
| 419 | - }); | ||
| 420 | - var upLine = new AMap.Polyline(upLineOps); | ||
| 421 | - //保存线条引用 | ||
| 422 | - polylines.push(upLine); | ||
| 423 | - | ||
| 424 | - upLine.setMap(map); | ||
| 425 | - map.setCenter(upArr[parseInt(upArr.length / 2)]); | ||
| 426 | - | ||
| 427 | - } | ||
| 428 | - //下行 | ||
| 429 | - if(route.down){ | ||
| 430 | - $.each(route.down_gcj.split(','), function(){ | ||
| 431 | - tempArray = this.split(' '); | ||
| 432 | - downArr.push([tempArray[0], tempArray[1]]); | ||
| 433 | - }); | ||
| 434 | - var downLine = new AMap.Polyline(downLineOps); | ||
| 435 | - //保存线条引用 | ||
| 436 | - polylines.push(downLine); | ||
| 437 | - | ||
| 438 | - downLine.setMap(map); | ||
| 439 | - } | ||
| 440 | - }, | ||
| 441 | - drawGpsMarker: function(gpsList){ | ||
| 442 | - } | ||
| 443 | - }, | ||
| 444 | - setText : function(text) { | ||
| 445 | - $('.leftUtils span.dropdown-toggle').html( | ||
| 446 | - text + ' <i class="fa fa-angle-down"></i>'); | ||
| 447 | - }, | ||
| 448 | - destroy : function() { | ||
| 449 | - trafficBtn.unbind('click'); | ||
| 450 | - | ||
| 451 | - //如果当前地图实例有destroy方法即执行 | ||
| 452 | - var map = currentMap.map; | ||
| 453 | - map.destroy && map.destroy(); | ||
| 454 | - | ||
| 455 | - if (currentMap.mapName == REAL_GAODE_TEXT) { | ||
| 456 | - // 如果前一个地图是高德,清除相关样式 | ||
| 457 | - real_map.gaode.clearStyle(); | ||
| 458 | - } | ||
| 459 | - } | ||
| 460 | - } | ||
| 461 | - | ||
| 462 | - function showMsg(text){ | ||
| 463 | - layer.msg('正在切换到' + text + '...', {icon : 16,shade : [ 0.6, '#393D49' ],time : 0}); | ||
| 464 | - } | ||
| 465 | - | ||
| 466 | - /** | ||
| 467 | - * 颜色 | ||
| 468 | - */ | ||
| 469 | - var bgColor = function(g){ | ||
| 470 | - if(g.state == 0){ | ||
| 471 | - if(g.upDown == 0) | ||
| 472 | - return '#5E96D2'; | ||
| 473 | - else if(g.upDown == 1) | ||
| 474 | - return '#C92121'; | ||
| 475 | - else | ||
| 476 | - return 'red'; | ||
| 477 | - } | ||
| 478 | - else | ||
| 479 | - return "rgb(171, 171, 171)"; | ||
| 480 | - } | ||
| 481 | - | ||
| 482 | - var tColor = function(g){ | ||
| 483 | - if(g.state == 0) | ||
| 484 | - return "#fff"; | ||
| 485 | - else | ||
| 486 | - return "rgb(229, 229, 229)"; | ||
| 487 | - } | ||
| 488 | - | ||
| 489 | - function createBDMarkerByGps(gpsData){ | ||
| 490 | - //marker | ||
| 491 | - var point = new BMap.Point(gpsData.bd_coord.x, gpsData.bd_coord.y) | ||
| 492 | - //label | ||
| 493 | - ,label = new BMap.Label(gpsData.nbbm.replace('-',''), {position: point, offset: new BMap.Size(-20,8)}); | ||
| 494 | - label.setStyle({borderColor: bgColor(gpsData), padding: '6px 6px 4px 6px', color: tColor(gpsData), backgroundColor: bgColor(gpsData)}); | ||
| 495 | - var marker = new BMap.Marker(point); | ||
| 496 | - marker.setLabel(label); | ||
| 497 | - //icon | ||
| 498 | - marker.setIcon(new BMap.Icon(tmIcon, new BMap.Size(25,25))); | ||
| 499 | - //window 绑定到 label | ||
| 500 | - marker.infoWindow = new BMap.InfoWindow(bd_gps_info_win_opts); | ||
| 501 | - //数据绑定到label | ||
| 502 | - marker.gpsData = gpsData; | ||
| 503 | - | ||
| 504 | - //mouseover | ||
| 505 | - label.addEventListener('mouseover', function(){ | ||
| 506 | - bdOpenWindow(marker); | ||
| 507 | - }); | ||
| 508 | - return marker; | ||
| 509 | - } | ||
| 510 | - | ||
| 511 | - function bdHistoryMarker(gps){ | ||
| 512 | - //marker | ||
| 513 | - var point = new BMap.Point(gps.bd_lon, gps.bd_lat) | ||
| 514 | - //label | ||
| 515 | - ,label = new BMap.Label(gps.nbbm, {position: point, offset: new BMap.Size(-20,8)}); | ||
| 516 | - label.setStyle({borderColor: bgColor(gps), padding: '6px 6px 4px 6px', color: tColor(gps), backgroundColor: bgColor(gps)}); | ||
| 517 | - var marker = new BMap.Marker(point); | ||
| 518 | - marker.setLabel(label); | ||
| 519 | - //icon | ||
| 520 | - marker.setIcon(new BMap.Icon(tmIcon, new BMap.Size(25,25))); | ||
| 521 | -/* //window 绑定到 label | ||
| 522 | - marker.infoWindow = new BMap.InfoWindow(bd_gps_info_win_opts); | ||
| 523 | - //数据绑定到label | ||
| 524 | - marker.gpsData = gpsData; | ||
| 525 | - | ||
| 526 | - //mouseover | ||
| 527 | - label.addEventListener('mouseover', function(){ | ||
| 528 | - bdOpenWindow(marker); | ||
| 529 | - });*/ | ||
| 530 | - return marker; | ||
| 531 | - } | ||
| 532 | - | ||
| 533 | - function bdOpenWindow(marker){ | ||
| 534 | - marker.infoWindow.setContent(template('gps_info_win_temp', marker.gpsData)); | ||
| 535 | - currentMap.map.openInfoWindow(marker.infoWindow, marker.point); | ||
| 536 | - } | ||
| 537 | - return real_map; | 1 | +var realMap = (function() { |
| 2 | + | ||
| 3 | + function getJSONP(url, data ,callback){ | ||
| 4 | + $.ajax({ | ||
| 5 | + url:url, | ||
| 6 | + data: data, | ||
| 7 | + dataType:'jsonp', | ||
| 8 | + success:callback, | ||
| 9 | + error: function(e){ | ||
| 10 | + alert('error: jsonp,' + url); | ||
| 11 | + } | ||
| 12 | + }); | ||
| 13 | + } | ||
| 14 | + | ||
| 15 | + /** | ||
| 16 | + * 透明点,用于替换隐藏百度Marker的icon | ||
| 17 | + */ | ||
| 18 | + var tmIcon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKTWlDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVN3WJP3Fj7f92UPVkLY8LGXbIEAIiOsCMgQWaIQkgBhhBASQMWFiApWFBURnEhVxILVCkidiOKgKLhnQYqIWotVXDjuH9yntX167+3t+9f7vOec5/zOec8PgBESJpHmomoAOVKFPDrYH49PSMTJvYACFUjgBCAQ5svCZwXFAADwA3l4fnSwP/wBr28AAgBw1S4kEsfh/4O6UCZXACCRAOAiEucLAZBSAMguVMgUAMgYALBTs2QKAJQAAGx5fEIiAKoNAOz0ST4FANipk9wXANiiHKkIAI0BAJkoRyQCQLsAYFWBUiwCwMIAoKxAIi4EwK4BgFm2MkcCgL0FAHaOWJAPQGAAgJlCLMwAIDgCAEMeE80DIEwDoDDSv+CpX3CFuEgBAMDLlc2XS9IzFLiV0Bp38vDg4iHiwmyxQmEXKRBmCeQinJebIxNI5wNMzgwAABr50cH+OD+Q5+bk4eZm52zv9MWi/mvwbyI+IfHf/ryMAgQAEE7P79pf5eXWA3DHAbB1v2upWwDaVgBo3/ldM9sJoFoK0Hr5i3k4/EAenqFQyDwdHAoLC+0lYqG9MOOLPv8z4W/gi372/EAe/tt68ABxmkCZrcCjg/1xYW52rlKO58sEQjFu9+cj/seFf/2OKdHiNLFcLBWK8ViJuFAiTcd5uVKRRCHJleIS6X8y8R+W/QmTdw0ArIZPwE62B7XLbMB+7gECiw5Y0nYAQH7zLYwaC5EAEGc0Mnn3AACTv/mPQCsBAM2XpOMAALzoGFyolBdMxggAAESggSqwQQcMwRSswA6cwR28wBcCYQZEQAwkwDwQQgbkgBwKoRiWQRlUwDrYBLWwAxqgEZrhELTBMTgN5+ASXIHrcBcGYBiewhi8hgkEQcgIE2EhOogRYo7YIs4IF5mOBCJhSDSSgKQg6YgUUSLFyHKkAqlCapFdSCPyLXIUOY1cQPqQ28ggMor8irxHMZSBslED1AJ1QLmoHxqKxqBz0XQ0D12AlqJr0Rq0Hj2AtqKn0UvodXQAfYqOY4DRMQ5mjNlhXIyHRWCJWBomxxZj5Vg1Vo81Yx1YN3YVG8CeYe8IJAKLgBPsCF6EEMJsgpCQR1hMWEOoJewjtBK6CFcJg4Qxwicik6hPtCV6EvnEeGI6sZBYRqwm7iEeIZ4lXicOE1+TSCQOyZLkTgohJZAySQtJa0jbSC2kU6Q+0hBpnEwm65Btyd7kCLKArCCXkbeQD5BPkvvJw+S3FDrFiOJMCaIkUqSUEko1ZT/lBKWfMkKZoKpRzame1AiqiDqfWkltoHZQL1OHqRM0dZolzZsWQ8ukLaPV0JppZ2n3aC/pdLoJ3YMeRZfQl9Jr6Afp5+mD9HcMDYYNg8dIYigZaxl7GacYtxkvmUymBdOXmchUMNcyG5lnmA+Yb1VYKvYqfBWRyhKVOpVWlX6V56pUVXNVP9V5qgtUq1UPq15WfaZGVbNQ46kJ1Bar1akdVbupNq7OUndSj1DPUV+jvl/9gvpjDbKGhUaghkijVGO3xhmNIRbGMmXxWELWclYD6yxrmE1iW7L57Ex2Bfsbdi97TFNDc6pmrGaRZp3mcc0BDsax4PA52ZxKziHODc57LQMtPy2x1mqtZq1+rTfaetq+2mLtcu0W7eva73VwnUCdLJ31Om0693UJuja6UbqFutt1z+o+02PreekJ9cr1Dund0Uf1bfSj9Rfq79bv0R83MDQINpAZbDE4Y/DMkGPoa5hpuNHwhOGoEctoupHEaKPRSaMnuCbuh2fjNXgXPmasbxxirDTeZdxrPGFiaTLbpMSkxeS+Kc2Ua5pmutG003TMzMgs3KzYrMnsjjnVnGueYb7ZvNv8jYWlRZzFSos2i8eW2pZ8ywWWTZb3rJhWPlZ5VvVW16xJ1lzrLOtt1ldsUBtXmwybOpvLtqitm63Edptt3xTiFI8p0in1U27aMez87ArsmuwG7Tn2YfYl9m32zx3MHBId1jt0O3xydHXMdmxwvOuk4TTDqcSpw+lXZxtnoXOd8zUXpkuQyxKXdpcXU22niqdun3rLleUa7rrStdP1o5u7m9yt2W3U3cw9xX2r+00umxvJXcM970H08PdY4nHM452nm6fC85DnL152Xlle+70eT7OcJp7WMG3I28Rb4L3Le2A6Pj1l+s7pAz7GPgKfep+Hvqa+It89viN+1n6Zfgf8nvs7+sv9j/i/4XnyFvFOBWABwQHlAb2BGoGzA2sDHwSZBKUHNQWNBbsGLww+FUIMCQ1ZH3KTb8AX8hv5YzPcZyya0RXKCJ0VWhv6MMwmTB7WEY6GzwjfEH5vpvlM6cy2CIjgR2yIuB9pGZkX+X0UKSoyqi7qUbRTdHF09yzWrORZ+2e9jvGPqYy5O9tqtnJ2Z6xqbFJsY+ybuIC4qriBeIf4RfGXEnQTJAntieTE2MQ9ieNzAudsmjOc5JpUlnRjruXcorkX5unOy553PFk1WZB8OIWYEpeyP+WDIEJQLxhP5aduTR0T8oSbhU9FvqKNolGxt7hKPJLmnVaV9jjdO31D+miGT0Z1xjMJT1IreZEZkrkj801WRNberM/ZcdktOZSclJyjUg1plrQr1zC3KLdPZisrkw3keeZtyhuTh8r35CP5c/PbFWyFTNGjtFKuUA4WTC+oK3hbGFt4uEi9SFrUM99m/ur5IwuCFny9kLBQuLCz2Lh4WfHgIr9FuxYji1MXdy4xXVK6ZHhp8NJ9y2jLspb9UOJYUlXyannc8o5Sg9KlpUMrglc0lamUycturvRauWMVYZVkVe9ql9VbVn8qF5VfrHCsqK74sEa45uJXTl/VfPV5bdra3kq3yu3rSOuk626s91m/r0q9akHV0IbwDa0b8Y3lG19tSt50oXpq9Y7NtM3KzQM1YTXtW8y2rNvyoTaj9nqdf13LVv2tq7e+2Sba1r/dd3vzDoMdFTve75TsvLUreFdrvUV99W7S7oLdjxpiG7q/5n7duEd3T8Wej3ulewf2Re/ranRvbNyvv7+yCW1SNo0eSDpw5ZuAb9qb7Zp3tXBaKg7CQeXBJ9+mfHvjUOihzsPcw83fmX+39QjrSHkr0jq/dawto22gPaG97+iMo50dXh1Hvrf/fu8x42N1xzWPV56gnSg98fnkgpPjp2Snnp1OPz3Umdx590z8mWtdUV29Z0PPnj8XdO5Mt1/3yfPe549d8Lxw9CL3Ytslt0utPa49R35w/eFIr1tv62X3y+1XPK509E3rO9Hv03/6asDVc9f41y5dn3m978bsG7duJt0cuCW69fh29u0XdwruTNxdeo94r/y+2v3qB/oP6n+0/rFlwG3g+GDAYM/DWQ/vDgmHnv6U/9OH4dJHzEfVI0YjjY+dHx8bDRq98mTOk+GnsqcTz8p+Vv9563Or59/94vtLz1j82PAL+YvPv655qfNy76uprzrHI8cfvM55PfGm/K3O233vuO+638e9H5ko/ED+UPPR+mPHp9BP9z7nfP78L/eE8/sl0p8zAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAAbSURBVHjaYvz//z8DAwMDAxMDFAAAAAD//wMAMAYDAW/BVI8AAAAASUVORK5CYII='; | ||
| 19 | + | ||
| 20 | + var REAL_BAIDU_TEXT = '百度地图', REAL_GAODE_TEXT = '高德地图'; | ||
| 21 | + | ||
| 22 | + // 中心点 (上海市浦东新区政府) | ||
| 23 | + var CENTER_POINT = { | ||
| 24 | + lng : 121.544336, | ||
| 25 | + lat : 31.221315 | ||
| 26 | + }; | ||
| 27 | + | ||
| 28 | + // 图层容器 | ||
| 29 | + var mapContainer = $('#mapContainer'); | ||
| 30 | + // 路况按钮 | ||
| 31 | + var trafficBtn = $('#trafficItem'); | ||
| 32 | + | ||
| 33 | + var storage = window.localStorage; | ||
| 34 | + | ||
| 35 | + var currentMap; | ||
| 36 | + | ||
| 37 | + var city = "上海"; | ||
| 38 | + | ||
| 39 | + //百度API Key | ||
| 40 | + var bdKey = 'IGGrr4UjwIYzatoCRFKEL8sT'; | ||
| 41 | + | ||
| 42 | + var bd_gps_info_win_opts = { | ||
| 43 | + width : 190, | ||
| 44 | + height: 255, | ||
| 45 | + enableMessage:true | ||
| 46 | + }; | ||
| 47 | + | ||
| 48 | + //线路路由 | ||
| 49 | + var polylines; | ||
| 50 | + | ||
| 51 | + //百度 -轨迹回放点聚合 | ||
| 52 | + //var historyClusterer; | ||
| 53 | + | ||
| 54 | + var markerClusterer; | ||
| 55 | + | ||
| 56 | + //设备号和marker对照 | ||
| 57 | + var markersMap; | ||
| 58 | + var real_map = { | ||
| 59 | + getMap: function(){ | ||
| 60 | + return currentMap; | ||
| 61 | + }, | ||
| 62 | + init: function(){ | ||
| 63 | + var m = storage.getItem('real_map'); | ||
| 64 | + if(m && m == REAL_GAODE_TEXT) | ||
| 65 | + real_map.gaode.init(); | ||
| 66 | + else | ||
| 67 | + real_map.baidu.init(); | ||
| 68 | + }, | ||
| 69 | + //百度地图 | ||
| 70 | + baidu : { | ||
| 71 | + //初始化 | ||
| 72 | + init : function() { | ||
| 73 | + real_map.setText(REAL_BAIDU_TEXT); | ||
| 74 | + | ||
| 75 | + var map = new BMap.Map(mapContainer[0]); | ||
| 76 | + //中心点和缩放级别 | ||
| 77 | + map.centerAndZoom(new BMap.Point(CENTER_POINT.lng,CENTER_POINT.lat), 15); | ||
| 78 | + map.enableScrollWheelZoom(); | ||
| 79 | + //加载完成 | ||
| 80 | + map.addEventListener("tilesloaded", function() { | ||
| 81 | + layer.closeAll(); | ||
| 82 | + storage.setItem('real_map', REAL_BAIDU_TEXT); | ||
| 83 | + }); | ||
| 84 | + | ||
| 85 | + // 路况控件 | ||
| 86 | + var ctrl = new BMapLib.TrafficControl(); | ||
| 87 | + map.addControl(ctrl); | ||
| 88 | + | ||
| 89 | + //historyClusterer = new BMapLib.MarkerClusterer(map, {isAverangeCenter : true,minClusterSize : 2}) | ||
| 90 | + var isVisible; | ||
| 91 | + trafficBtn.on('click', function() { | ||
| 92 | + if (isVisible) { | ||
| 93 | + ctrl.hide(); | ||
| 94 | + isVisible = false; | ||
| 95 | + //调整线路路由透明度 | ||
| 96 | + $.each(polylines, function(){ | ||
| 97 | + this.setStrokeOpacity(0.5); | ||
| 98 | + }); | ||
| 99 | + } else { | ||
| 100 | + ctrl.show(); | ||
| 101 | + isVisible = true; | ||
| 102 | + //调整线路路由透明度 | ||
| 103 | + $.each(polylines, function(){ | ||
| 104 | + this.setStrokeOpacity(0.1); | ||
| 105 | + }); | ||
| 106 | + } | ||
| 107 | + }); | ||
| 108 | + //百度路况控件自身关闭按钮 | ||
| 109 | + $('.portlet-fullscreen').on('click', '.maplibTc .maplibTcClose', function(){ | ||
| 110 | + isVisible = false; | ||
| 111 | + //调整线路路由透明度 | ||
| 112 | + $.each(polylines, function(){ | ||
| 113 | + this.setStrokeOpacity(0.5); | ||
| 114 | + }); | ||
| 115 | + }); | ||
| 116 | + | ||
| 117 | + $('#tcWrap.maplibTc').addClass('animated bounceInLeft'); | ||
| 118 | + $('.maplibTcBtn_deskTop.anchorTR').remove(); | ||
| 119 | + | ||
| 120 | + //保存当前地图实例和名称 | ||
| 121 | + currentMap = { | ||
| 122 | + map: map, | ||
| 123 | + mapName: REAL_BAIDU_TEXT, | ||
| 124 | + fName : 'baidu' | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + }, | ||
| 128 | + clear: function(){ | ||
| 129 | + currentMap.map.clearOverlays(); | ||
| 130 | + markerClusterer && markerClusterer.clearMarkers(); | ||
| 131 | + | ||
| 132 | + }, | ||
| 133 | + change : function() { | ||
| 134 | + if(currentMap.mapName == REAL_BAIDU_TEXT) | ||
| 135 | + return; | ||
| 136 | + | ||
| 137 | + showMsg(REAL_BAIDU_TEXT); | ||
| 138 | + | ||
| 139 | + real_map.destroy(); | ||
| 140 | + real_map.baidu.init(); | ||
| 141 | + }, | ||
| 142 | + autocomplete: function(input, cb){ | ||
| 143 | + var ac = new BMap.Autocomplete({ | ||
| 144 | + 'location' : realMap.getMap().map, | ||
| 145 | + 'input': input, | ||
| 146 | + 'onSearchComplete': function(result){ | ||
| 147 | + //隐藏默认的提示框 | ||
| 148 | + ac.hide(); | ||
| 149 | + cb && cb({type: 'baidu', result: result.wr}); | ||
| 150 | + } | ||
| 151 | + }); | ||
| 152 | + | ||
| 153 | + $('#' + input).on('keyup', function(){ | ||
| 154 | + if(this.value == ''){ | ||
| 155 | + $('.search_result').html(''); | ||
| 156 | + return; | ||
| 157 | + } | ||
| 158 | + }); | ||
| 159 | + | ||
| 160 | + }, | ||
| 161 | + setPlace: function(val){ | ||
| 162 | + var map = currentMap.map; | ||
| 163 | + map.clearOverlays(); | ||
| 164 | + var local = new BMap.LocalSearch(map, { | ||
| 165 | + onSearchComplete: function(){ | ||
| 166 | + var poi = local.getResults().getPoi(0); | ||
| 167 | + if(!poi){ | ||
| 168 | + return; | ||
| 169 | + } | ||
| 170 | + var pp = poi.point; | ||
| 171 | + map.centerAndZoom(pp, 18); | ||
| 172 | + map.addOverlay(new BMap.Marker(pp)); | ||
| 173 | + } | ||
| 174 | + }); | ||
| 175 | + | ||
| 176 | + local.search(val); | ||
| 177 | + }, | ||
| 178 | + drawLine: function(route){ | ||
| 179 | + var map = currentMap.map; | ||
| 180 | + map.clearOverlays(); | ||
| 181 | + polylines = []; | ||
| 182 | + //画线路 | ||
| 183 | + //从localStorage里读取路由信息 | ||
| 184 | + //var route = JSON.parse(storage.getItem(lineCode + '_route')); | ||
| 185 | + var upLineOps = {strokeColor:"blue", strokeWeight:6, strokeOpacity:0.5} | ||
| 186 | + ,downLineOps = {strokeColor:"red", strokeWeight:6, strokeOpacity:0.5}; | ||
| 187 | + | ||
| 188 | + var upPos = [], downPos = [], tempArray; | ||
| 189 | + //上行 | ||
| 190 | + if(route.up){ | ||
| 191 | + $.each(route.up.split(','), function(){ | ||
| 192 | + tempArray = this.split(' '); | ||
| 193 | + upPos.push(new BMap.Point(tempArray[0], tempArray[1])); | ||
| 194 | + }); | ||
| 195 | + | ||
| 196 | + var upLine = new BMap.Polyline(upPos, upLineOps); | ||
| 197 | + map.addOverlay(upLine); | ||
| 198 | + | ||
| 199 | + polylines.push(upLine); | ||
| 200 | + map.panTo(upPos[parseInt(upPos.length / 2)]); | ||
| 201 | + } | ||
| 202 | + //下行 | ||
| 203 | + if(route.down){ | ||
| 204 | + $.each(route.down.split(','), function(){ | ||
| 205 | + tempArray = this.split(' '); | ||
| 206 | + downPos.push(new BMap.Point(tempArray[0], tempArray[1])); | ||
| 207 | + }); | ||
| 208 | + | ||
| 209 | + var downLine = new BMap.Polyline(downPos, downLineOps); | ||
| 210 | + map.addOverlay(downLine); | ||
| 211 | + polylines.push(downLine); | ||
| 212 | + | ||
| 213 | + } | ||
| 214 | + }, | ||
| 215 | + //批量将GPS信号画到地图上 | ||
| 216 | + drawGpsMarker: function(gpsList){ | ||
| 217 | + markersMap = {}; | ||
| 218 | + var map = currentMap.map; | ||
| 219 | + | ||
| 220 | + markerClusterer && markerClusterer.clearMarkers(); | ||
| 221 | + markerClusterer = new BMapLib.MarkerClusterer(map, {isAverangeCenter : true,minClusterSize : 3}); | ||
| 222 | + real_map.baidu.coordsConvert(gpsList, function(){ | ||
| 223 | + //绘制车辆位置 | ||
| 224 | + var marker; | ||
| 225 | + $.each(gpsList, function(i, gpsData){ | ||
| 226 | + marker = createBDMarkerByGps(gpsData) | ||
| 227 | + map.addOverlay(marker); | ||
| 228 | + //marker加入点聚合 | ||
| 229 | + markerClusterer.addMarker(marker); | ||
| 230 | + | ||
| 231 | + markersMap[gpsData.deviceId] = marker; | ||
| 232 | + }); | ||
| 233 | + | ||
| 234 | + }); | ||
| 235 | + }, | ||
| 236 | + goToMarker: function(deviceId){ | ||
| 237 | + var m = markersMap[deviceId]; | ||
| 238 | + if(m){ | ||
| 239 | + currentMap.map.panTo(m.point); | ||
| 240 | + setTimeout(function(){ | ||
| 241 | + bdOpenWindow(m); | ||
| 242 | + }, 500); | ||
| 243 | + } | ||
| 244 | + }, | ||
| 245 | + coordsConvert: function(list, cb){ | ||
| 246 | + if(list.length > 100) | ||
| 247 | + list = list.slice(0, 100); | ||
| 248 | + | ||
| 249 | + var coords = ''; | ||
| 250 | + //拼接GPS坐标,一次性转换 | ||
| 251 | + for (var i = 0, item; item = list[i++];) | ||
| 252 | + coords += item.lon + ',' + item.lat + ';'; | ||
| 253 | + coords = coords.substring(0, coords.length - 1); | ||
| 254 | + getJSONP('//api.map.baidu.com/geoconv/v1/',{coords: coords, ak: bdKey} | ||
| 255 | + ,function(rt){ | ||
| 256 | + $.each(rt.result, function(j, bdCoord){ | ||
| 257 | + list[j].bd_coord = bdCoord; | ||
| 258 | + }); | ||
| 259 | + cb&&cb(); | ||
| 260 | + }); | ||
| 261 | + }, | ||
| 262 | + //绘制轨迹回放 marker | ||
| 263 | + addHistoryMarker: function(gps){ | ||
| 264 | + | ||
| 265 | + var marker = bdHistoryMarker(gps); | ||
| 266 | + currentMap.map.addOverlay(marker); | ||
| 267 | + | ||
| 268 | + //historyClusterer.addMarker(marker); | ||
| 269 | + return marker; | ||
| 270 | + }, | ||
| 271 | + //移动marker | ||
| 272 | + moveMarker: function(marker , gps){ | ||
| 273 | + marker.setPosition(new BMap.Point(gps.bd_lon, gps.bd_lat)); | ||
| 274 | + //重新设置颜色 | ||
| 275 | + marker.getLabel().setStyle({borderColor: bgColor(gps), backgroundColor: bgColor(gps)}); | ||
| 276 | + }, | ||
| 277 | + //居中marker | ||
| 278 | + markerToCenter: function(marker){ | ||
| 279 | + currentMap.map.panTo(marker.getPosition()); | ||
| 280 | + }, | ||
| 281 | + //删除marker | ||
| 282 | + removeMarker: function(marker){ | ||
| 283 | + currentMap.map.removeOverlay(marker); | ||
| 284 | + } | ||
| 285 | + }, | ||
| 286 | + //高德地图 | ||
| 287 | + gaode : { | ||
| 288 | + init : function() { | ||
| 289 | + var mapLoadAnim = '<div class="sk-cube-grid _center">'+ | ||
| 290 | + '<div class="sk-cube sk-cube1"></div>'+ | ||
| 291 | + '<div class="sk-cube sk-cube2"></div>'+ | ||
| 292 | + '<div class="sk-cube sk-cube3"></div>'+ | ||
| 293 | + '<div class="sk-cube sk-cube4"></div>'+ | ||
| 294 | + '<div class="sk-cube sk-cube5"></div>'+ | ||
| 295 | + '<div class="sk-cube sk-cube6"></div>'+ | ||
| 296 | + '<div class="sk-cube sk-cube7"></div>'+ | ||
| 297 | + '<div class="sk-cube sk-cube8"></div>'+ | ||
| 298 | + '<div class="sk-cube sk-cube9"></div>'+ | ||
| 299 | + '</div>'; | ||
| 300 | + | ||
| 301 | + mapContainer.html(mapLoadAnim); | ||
| 302 | + | ||
| 303 | + real_map.gaode.setStyle(); | ||
| 304 | + real_map.setText(REAL_GAODE_TEXT); | ||
| 305 | + | ||
| 306 | + var map = new AMap.Map(mapContainer[0]); | ||
| 307 | + // 地图中心和缩放级别 | ||
| 308 | + map.setZoomAndCenter(14, [ CENTER_POINT.lng,CENTER_POINT.lat ]); | ||
| 309 | + //加载完成 | ||
| 310 | + AMap.event.addListener(map, 'complete', function() { | ||
| 311 | + layer.closeAll(); | ||
| 312 | + storage.setItem('real_map', REAL_GAODE_TEXT); | ||
| 313 | + $('.sk-cube-grid._center').remove(); | ||
| 314 | + }); | ||
| 315 | + | ||
| 316 | + // 实时路况图层 | ||
| 317 | + var trafficLayer = new AMap.TileLayer.Traffic(); | ||
| 318 | + trafficLayer.setMap(map); | ||
| 319 | + trafficLayer.hide(); | ||
| 320 | + | ||
| 321 | + var isVisible; | ||
| 322 | + trafficBtn.on('click', function() { | ||
| 323 | + if (isVisible) { | ||
| 324 | + trafficLayer.hide(); | ||
| 325 | + isVisible = false; | ||
| 326 | + $(this).removeClass('active'); | ||
| 327 | + | ||
| 328 | + //调整线路路由透明度 | ||
| 329 | + $.each(polylines, function(){ | ||
| 330 | + this.setOptions({strokeOpacity: 0.5}); | ||
| 331 | + }); | ||
| 332 | + } else { | ||
| 333 | + trafficLayer.show(); | ||
| 334 | + isVisible = true; | ||
| 335 | + $(this).addClass('active'); | ||
| 336 | + | ||
| 337 | + //调整线路路由透明度 | ||
| 338 | + $.each(polylines, function(){ | ||
| 339 | + this.setOptions({strokeOpacity: 0.1}); | ||
| 340 | + }); | ||
| 341 | + } | ||
| 342 | + }); | ||
| 343 | + | ||
| 344 | + //保存当前地图实例和名称 | ||
| 345 | + currentMap = { | ||
| 346 | + map: map, | ||
| 347 | + mapName: REAL_GAODE_TEXT, | ||
| 348 | + fName : 'gaode' | ||
| 349 | + } | ||
| 350 | + | ||
| 351 | + }, | ||
| 352 | + change : function() { | ||
| 353 | + if(currentMap.mapName == REAL_GAODE_TEXT) | ||
| 354 | + return; | ||
| 355 | + | ||
| 356 | + showMsg(REAL_GAODE_TEXT); | ||
| 357 | + | ||
| 358 | + real_map.destroy(); | ||
| 359 | + real_map.gaode.init(); | ||
| 360 | + }, | ||
| 361 | + setStyle : function() { | ||
| 362 | + $('.mapRightWrap').addClass('gaode'); | ||
| 363 | + $('.mapTools').addClass('gaode'); | ||
| 364 | + $('.leftUtils').addClass('gaode'); | ||
| 365 | + }, | ||
| 366 | + clearStyle : function() { | ||
| 367 | + $('.mapRightWrap').removeClass('gaode'); | ||
| 368 | + $('.mapTools').removeClass('gaode'); | ||
| 369 | + $('.leftUtils').removeClass('gaode'); | ||
| 370 | + }, | ||
| 371 | + autocomplete: function(input, cb){ | ||
| 372 | + | ||
| 373 | + AMap.plugin('AMap.Autocomplete',function(){ | ||
| 374 | + var autoOptions = { | ||
| 375 | + city: city | ||
| 376 | + }; | ||
| 377 | + autocomplete= new AMap.Autocomplete(autoOptions); | ||
| 378 | + | ||
| 379 | + $('#' + input).on('keyup', function(){ | ||
| 380 | + if(this.value == ''){ | ||
| 381 | + $('.search_result').html(''); | ||
| 382 | + return; | ||
| 383 | + } | ||
| 384 | + autocomplete.search(this.value, function(status, result){ | ||
| 385 | + cb & cb({type: 'gaode', result: result.tips}); | ||
| 386 | + }); | ||
| 387 | + }); | ||
| 388 | + }); | ||
| 389 | + }, | ||
| 390 | + setPlace: function(val){ | ||
| 391 | + var map = currentMap.map; | ||
| 392 | + | ||
| 393 | + AMap.plugin(['AMap.PlaceSearch'],function(){ | ||
| 394 | + var placeSearch = new AMap.PlaceSearch({ | ||
| 395 | + city:city, | ||
| 396 | + map:map, | ||
| 397 | + pageSize: 1 | ||
| 398 | + }); | ||
| 399 | + | ||
| 400 | + placeSearch.search(val); | ||
| 401 | + }); | ||
| 402 | + }, | ||
| 403 | + drawLine: function(route){ | ||
| 404 | + polylines = []; | ||
| 405 | + var map = currentMap.map; | ||
| 406 | + map.clearMap(); | ||
| 407 | + | ||
| 408 | + //var route = JSON.parse(storage.getItem(lineCode + '_route')); | ||
| 409 | + var upArr = [], downArr = []; | ||
| 410 | + | ||
| 411 | + var upLineOps = {path: upArr, strokeColor:"blue", strokeWeight:6, strokeOpacity:0.5} | ||
| 412 | + ,downLineOps = {path: downArr, strokeColor:"red", strokeWeight:6, strokeOpacity:0.5}; | ||
| 413 | + | ||
| 414 | + //上行 | ||
| 415 | + if(route.up){ | ||
| 416 | + $.each(route.up_gcj.split(','), function(){ | ||
| 417 | + tempArray = this.split(' '); | ||
| 418 | + upArr.push([tempArray[0], tempArray[1]]); | ||
| 419 | + }); | ||
| 420 | + var upLine = new AMap.Polyline(upLineOps); | ||
| 421 | + //保存线条引用 | ||
| 422 | + polylines.push(upLine); | ||
| 423 | + | ||
| 424 | + upLine.setMap(map); | ||
| 425 | + map.setCenter(upArr[parseInt(upArr.length / 2)]); | ||
| 426 | + | ||
| 427 | + } | ||
| 428 | + //下行 | ||
| 429 | + if(route.down){ | ||
| 430 | + $.each(route.down_gcj.split(','), function(){ | ||
| 431 | + tempArray = this.split(' '); | ||
| 432 | + downArr.push([tempArray[0], tempArray[1]]); | ||
| 433 | + }); | ||
| 434 | + var downLine = new AMap.Polyline(downLineOps); | ||
| 435 | + //保存线条引用 | ||
| 436 | + polylines.push(downLine); | ||
| 437 | + | ||
| 438 | + downLine.setMap(map); | ||
| 439 | + } | ||
| 440 | + }, | ||
| 441 | + drawGpsMarker: function(gpsList){ | ||
| 442 | + } | ||
| 443 | + }, | ||
| 444 | + setText : function(text) { | ||
| 445 | + $('.leftUtils span.dropdown-toggle').html( | ||
| 446 | + text + ' <i class="fa fa-angle-down"></i>'); | ||
| 447 | + }, | ||
| 448 | + destroy : function() { | ||
| 449 | + trafficBtn.unbind('click'); | ||
| 450 | + | ||
| 451 | + //如果当前地图实例有destroy方法即执行 | ||
| 452 | + var map = currentMap.map; | ||
| 453 | + map.destroy && map.destroy(); | ||
| 454 | + | ||
| 455 | + if (currentMap.mapName == REAL_GAODE_TEXT) { | ||
| 456 | + // 如果前一个地图是高德,清除相关样式 | ||
| 457 | + real_map.gaode.clearStyle(); | ||
| 458 | + } | ||
| 459 | + } | ||
| 460 | + } | ||
| 461 | + | ||
| 462 | + function showMsg(text){ | ||
| 463 | + layer.msg('正在切换到' + text + '...', {icon : 16,shade : [ 0.6, '#393D49' ],time : 0}); | ||
| 464 | + } | ||
| 465 | + | ||
| 466 | + /** | ||
| 467 | + * 颜色 | ||
| 468 | + */ | ||
| 469 | + var bgColor = function(g){ | ||
| 470 | + if(g.state == 0){ | ||
| 471 | + if(g.upDown == 0) | ||
| 472 | + return '#5E96D2'; | ||
| 473 | + else if(g.upDown == 1) | ||
| 474 | + return '#C92121'; | ||
| 475 | + else | ||
| 476 | + return 'red'; | ||
| 477 | + } | ||
| 478 | + else | ||
| 479 | + return "rgb(171, 171, 171)"; | ||
| 480 | + } | ||
| 481 | + | ||
| 482 | + var tColor = function(g){ | ||
| 483 | + if(g.state == 0) | ||
| 484 | + return "#fff"; | ||
| 485 | + else | ||
| 486 | + return "rgb(229, 229, 229)"; | ||
| 487 | + } | ||
| 488 | + | ||
| 489 | + function createBDMarkerByGps(gpsData){ | ||
| 490 | + //marker | ||
| 491 | + var point = new BMap.Point(gpsData.bd_coord.x, gpsData.bd_coord.y) | ||
| 492 | + //label | ||
| 493 | + ,label = new BMap.Label(gpsData.nbbm.replace('-',''), {position: point, offset: new BMap.Size(-20,8)}); | ||
| 494 | + label.setStyle({borderColor: bgColor(gpsData), padding: '6px 6px 4px 6px', color: tColor(gpsData), backgroundColor: bgColor(gpsData)}); | ||
| 495 | + var marker = new BMap.Marker(point); | ||
| 496 | + marker.setLabel(label); | ||
| 497 | + //icon | ||
| 498 | + marker.setIcon(new BMap.Icon(tmIcon, new BMap.Size(25,25))); | ||
| 499 | + //window 绑定到 label | ||
| 500 | + marker.infoWindow = new BMap.InfoWindow(bd_gps_info_win_opts); | ||
| 501 | + //数据绑定到label | ||
| 502 | + marker.gpsData = gpsData; | ||
| 503 | + | ||
| 504 | + //mouseover | ||
| 505 | + label.addEventListener('mouseover', function(){ | ||
| 506 | + bdOpenWindow(marker); | ||
| 507 | + }); | ||
| 508 | + return marker; | ||
| 509 | + } | ||
| 510 | + | ||
| 511 | + function bdHistoryMarker(gps){ | ||
| 512 | + //marker | ||
| 513 | + var point = new BMap.Point(gps.bd_lon, gps.bd_lat) | ||
| 514 | + //label | ||
| 515 | + ,label = new BMap.Label(gps.nbbm, {position: point, offset: new BMap.Size(-20,8)}); | ||
| 516 | + label.setStyle({borderColor: bgColor(gps), padding: '6px 6px 4px 6px', color: tColor(gps), backgroundColor: bgColor(gps)}); | ||
| 517 | + var marker = new BMap.Marker(point); | ||
| 518 | + marker.setLabel(label); | ||
| 519 | + //icon | ||
| 520 | + marker.setIcon(new BMap.Icon(tmIcon, new BMap.Size(25,25))); | ||
| 521 | +/* //window 绑定到 label | ||
| 522 | + marker.infoWindow = new BMap.InfoWindow(bd_gps_info_win_opts); | ||
| 523 | + //数据绑定到label | ||
| 524 | + marker.gpsData = gpsData; | ||
| 525 | + | ||
| 526 | + //mouseover | ||
| 527 | + label.addEventListener('mouseover', function(){ | ||
| 528 | + bdOpenWindow(marker); | ||
| 529 | + });*/ | ||
| 530 | + return marker; | ||
| 531 | + } | ||
| 532 | + | ||
| 533 | + function bdOpenWindow(marker){ | ||
| 534 | + marker.infoWindow.setContent(template('gps_info_win_temp', marker.gpsData)); | ||
| 535 | + currentMap.map.openInfoWindow(marker.infoWindow, marker.point); | ||
| 536 | + } | ||
| 537 | + return real_map; | ||
| 538 | })(); | 538 | })(); |
| 539 | \ No newline at end of file | 539 | \ No newline at end of file |
src/main/resources/static/pages/permission/authorize_all/user_auth.html
| @@ -174,6 +174,7 @@ | @@ -174,6 +174,7 @@ | ||
| 174 | '26_4': '南汇公司(南汇维修公司)', | 174 | '26_4': '南汇公司(南汇维修公司)', |
| 175 | '26_5': '南汇公司(南汇公司)', | 175 | '26_5': '南汇公司(南汇公司)', |
| 176 | '26_6': '南汇公司(南汇六分)', | 176 | '26_6': '南汇公司(南汇六分)', |
| 177 | + '26_7': '南汇公司(南汇五分)', | ||
| 177 | '05_5': '杨高公司(杨高分公司)', | 178 | '05_5': '杨高公司(杨高分公司)', |
| 178 | '05_6': '杨高公司(周浦分公司)', | 179 | '05_6': '杨高公司(周浦分公司)', |
| 179 | '05_3': '杨高公司(芦潮港分公司)', | 180 | '05_3': '杨高公司(芦潮港分公司)', |
src/main/resources/static/pages/permission/user/changePWD.html
| @@ -54,11 +54,27 @@ $(function(){ | @@ -54,11 +54,27 @@ $(function(){ | ||
| 54 | //表单 validate | 54 | //表单 validate |
| 55 | var error = $('.alert-danger', form); | 55 | var error = $('.alert-danger', form); |
| 56 | 56 | ||
| 57 | + var validate = function (pwd) { | ||
| 58 | + var flag = true; | ||
| 59 | + for (var i = 1; i < pwd.length - 1; i++) { | ||
| 60 | + var first = pwd.charCodeAt(i - 1); | ||
| 61 | + var second = pwd.charCodeAt(i); | ||
| 62 | + var third = pwd.charCodeAt(i + 1); | ||
| 63 | + if (!(first >= 48 && third <= 57 || first >= 65 && third <= 90 || first >= 97 && third <= 122)) { | ||
| 64 | + continue; | ||
| 65 | + } | ||
| 66 | + if (third - second == 1 && second - first == 1) { | ||
| 67 | + flag = false; | ||
| 68 | + } | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + return flag; | ||
| 72 | + } | ||
| 73 | + | ||
| 57 | $.validator.addMethod("passwordrule", function(value, element) { | 74 | $.validator.addMethod("passwordrule", function(value, element) { |
| 58 | var reg = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*?[#?!@$%^&*-.]).{8,16}$/; | 75 | var reg = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*?[#?!@$%^&*-.]).{8,16}$/; |
| 59 | - // var reg = /^(?=.*[a-zA-Z])(?=.*\d).{8,16}$/; | ||
| 60 | - return this.optional(element) ||(reg.test(value)); | ||
| 61 | - }, "需包含大小写字母、数字、以及特殊符号的8-16位字符"); | 76 | + return this.optional(element) || reg.test(value) && validate(value); |
| 77 | + }, "需包含大小写字母、数字、以及特殊符号的8-16位字符,并不能有123、abc这样的连续字符"); | ||
| 62 | 78 | ||
| 63 | //表单 validate | 79 | //表单 validate |
| 64 | form.validate({ | 80 | form.validate({ |
src/main/resources/static/pages/permission/user/forceChangePWD.html
| 1 | <div class="row"> | 1 | <div class="row"> |
| 2 | -<div class="col-md-12"> | ||
| 3 | -<!-- BEGIN VALIDATION STATES--> | ||
| 4 | -<div class="portlet light portlet-fit portlet-form bordered"> | ||
| 5 | -<div class="portlet-body"> | ||
| 6 | - <form class="form-horizontal" id="forceChangePWDForm"> | ||
| 7 | - <div class="alert alert-danger display-hide"> | ||
| 8 | - <button class="close" data-close="alert"></button>您的输入有误,请检查下面的输入项 | ||
| 9 | - </div> | ||
| 10 | - <div class="form-group" style="margin-top: 60px"> | ||
| 11 | - <label class="control-label col-md-5">原始密码: | ||
| 12 | - </label> | ||
| 13 | - <div class="col-md-4"> | ||
| 14 | - <div class="input-icon right"> | ||
| 15 | - <i class="fa"></i> | ||
| 16 | - <input type="password" class="form-control" name="oldPWD" /> </div> | ||
| 17 | - </div> | 2 | + <div class="col-md-12"> |
| 3 | + <!-- BEGIN VALIDATION STATES--> | ||
| 4 | + <div class="portlet light portlet-fit portlet-form bordered"> | ||
| 5 | + <div class="portlet-body"> | ||
| 6 | + <form class="form-horizontal" id="forceChangePWDForm"> | ||
| 7 | + <div class="alert alert-danger display-hide"> | ||
| 8 | + <button class="close" data-close="alert"></button>您的输入有误,请检查下面的输入项 | ||
| 9 | + </div> | ||
| 10 | + <div class="form-group" style="margin-top: 60px"> | ||
| 11 | + <label class="control-label col-md-5">原始密码: | ||
| 12 | + </label> | ||
| 13 | + <div class="col-md-4"> | ||
| 14 | + <div class="input-icon right"> | ||
| 15 | + <i class="fa"></i> | ||
| 16 | + <input type="password" class="form-control" name="oldPWD" /> </div> | ||
| 17 | + </div> | ||
| 18 | + </div> | ||
| 19 | + <div class="form-group"> | ||
| 20 | + <label class="control-label col-md-5">输入新密码: | ||
| 21 | + </label> | ||
| 22 | + <div class="col-md-4"> | ||
| 23 | + <div class="input-icon right"> | ||
| 24 | + <i class="fa"></i> | ||
| 25 | + <input type="password" class="form-control" name="newPWD" id="newPWD"/> </div> | ||
| 26 | + </div> | ||
| 27 | + </div> | ||
| 28 | + <div class="form-group"> | ||
| 29 | + <label class="control-label col-md-5">确认新密码: | ||
| 30 | + </label> | ||
| 31 | + <div class="col-md-4"> | ||
| 32 | + <div class="input-icon right"> | ||
| 33 | + <i class="fa"></i> | ||
| 34 | + <input type="password" class="form-control" name="cnewPWD" /> </div> | ||
| 35 | + </div> | ||
| 36 | + </div> | ||
| 37 | + <div class="form-actions"> | ||
| 38 | + <div class="row"> | ||
| 39 | + <div class="col-md-offset-5 col-md-7"> | ||
| 40 | + <button type="submit" id="confirm" class="btn green">确定</button> | ||
| 41 | + </div> | ||
| 42 | + </div> | ||
| 43 | + </div> | ||
| 44 | + </form> | ||
| 45 | + </div> | ||
| 18 | </div> | 46 | </div> |
| 19 | - <div class="form-group"> | ||
| 20 | - <label class="control-label col-md-5">输入新密码: | ||
| 21 | - </label> | ||
| 22 | - <div class="col-md-4"> | ||
| 23 | - <div class="input-icon right"> | ||
| 24 | - <i class="fa"></i> | ||
| 25 | - <input type="password" class="form-control" name="newPWD" id="newPWD"/> </div> | ||
| 26 | - </div> | ||
| 27 | - </div> | ||
| 28 | - <div class="form-group"> | ||
| 29 | - <label class="control-label col-md-5">确认新密码: | ||
| 30 | - </label> | ||
| 31 | - <div class="col-md-4"> | ||
| 32 | - <div class="input-icon right"> | ||
| 33 | - <i class="fa"></i> | ||
| 34 | - <input type="password" class="form-control" name="cnewPWD" /> </div> | ||
| 35 | - </div> | ||
| 36 | - </div> | ||
| 37 | - <div class="form-actions"> | ||
| 38 | - <div class="row"> | ||
| 39 | - <div class="col-md-offset-5 col-md-7"> | ||
| 40 | - <button type="submit" id="confirm" class="btn green">确定</button> | ||
| 41 | - </div> | ||
| 42 | - </div> | ||
| 43 | - </div> | ||
| 44 | - </form> | ||
| 45 | -</div> | ||
| 46 | -</div> | ||
| 47 | -</div> | 47 | + </div> |
| 48 | </div> | 48 | </div> |
| 49 | 49 | ||
| 50 | <script> | 50 | <script> |
| 51 | -$(function(){ | ||
| 52 | - var form = $('#forceChangePWDForm'); | ||
| 53 | - //表单 validate | ||
| 54 | - var error = $('.alert-danger', form); | 51 | + $(function(){ |
| 52 | + var form = $('#forceChangePWDForm'); | ||
| 53 | + //表单 validate | ||
| 54 | + var error = $('.alert-danger', form); | ||
| 55 | + | ||
| 56 | + var validate = function (pwd) { | ||
| 57 | + var flag = true; | ||
| 58 | + for (var i = 1; i < pwd.length - 1; i++) { | ||
| 59 | + var first = pwd.charCodeAt(i - 1); | ||
| 60 | + var second = pwd.charCodeAt(i); | ||
| 61 | + var third = pwd.charCodeAt(i + 1); | ||
| 62 | + if (!(first >= 48 && third <= 57 || first >= 65 && third <= 90 || first >= 97 && third <= 122)) { | ||
| 63 | + continue; | ||
| 64 | + } | ||
| 65 | + if (third - second == 1 && second - first == 1) { | ||
| 66 | + flag = false; | ||
| 67 | + } | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + return flag; | ||
| 71 | + } | ||
| 55 | 72 | ||
| 56 | - $.validator.addMethod("passwordrule", function(value, element) { | ||
| 57 | - var reg = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*?[#?!@$%^&*-]).{8,16}$/; | ||
| 58 | - //var reg = /^(?=.*[a-zA-Z])(?=.*\d).{8,16}$/; | ||
| 59 | - return this.optional(element) ||(reg.test(value)); | ||
| 60 | - }, "需包含字母、数字的8-16位字符"); | 73 | + $.validator.addMethod("passwordrule", function(value, element) { |
| 74 | + var reg = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*?[#?!@$%^&*-.]).{8,16}$/; | ||
| 75 | + return this.optional(element) || reg.test(value) && validate(value); | ||
| 76 | + }, "需包含大小写字母、数字、以及特殊符号的8-16位字符,并不能有123、abc这样的连续字符"); | ||
| 61 | 77 | ||
| 62 | - //表单 validate | ||
| 63 | - form.validate({ | ||
| 64 | - errorElement : 'span', | ||
| 65 | - errorClass : 'help-block help-block-error', | ||
| 66 | - focusInvalid : false, | ||
| 67 | - rules : { | ||
| 68 | - 'newPWD' : { | ||
| 69 | - required : true, | ||
| 70 | - minlength: 8, | ||
| 71 | - maxlength: 16, | ||
| 72 | - passwordrule:true | ||
| 73 | - }, | ||
| 74 | - 'cnewPWD' : { | ||
| 75 | - equalTo: '#newPWD' | ||
| 76 | - } | ||
| 77 | - }, | ||
| 78 | - invalidHandler : function(event, validator) { | ||
| 79 | - error.show(); | ||
| 80 | - App.scrollTo(error, -200); | ||
| 81 | - }, | 78 | + //表单 validate |
| 79 | + form.validate({ | ||
| 80 | + errorElement : 'span', | ||
| 81 | + errorClass : 'help-block help-block-error', | ||
| 82 | + focusInvalid : false, | ||
| 83 | + rules : { | ||
| 84 | + 'newPWD' : { | ||
| 85 | + required : true, | ||
| 86 | + minlength: 6, | ||
| 87 | + maxlength: 16, | ||
| 88 | + passwordrule:true | ||
| 89 | + }, | ||
| 90 | + 'cnewPWD' : { | ||
| 91 | + equalTo: '#newPWD' | ||
| 92 | + } | ||
| 93 | + }, | ||
| 94 | + invalidHandler : function(event, validator) { | ||
| 95 | + error.show(); | ||
| 96 | + App.scrollTo(error, -200); | ||
| 97 | + }, | ||
| 82 | 98 | ||
| 83 | - highlight : function(element) { | ||
| 84 | - $(element).closest('.form-group').addClass('has-error'); | ||
| 85 | - }, | 99 | + highlight : function(element) { |
| 100 | + $(element).closest('.form-group').addClass('has-error'); | ||
| 101 | + }, | ||
| 86 | 102 | ||
| 87 | - unhighlight : function(element) { | ||
| 88 | - $(element).closest('.form-group').removeClass('has-error'); | ||
| 89 | - }, | 103 | + unhighlight : function(element) { |
| 104 | + $(element).closest('.form-group').removeClass('has-error'); | ||
| 105 | + }, | ||
| 90 | 106 | ||
| 91 | - success : function(label) { | ||
| 92 | - label.closest('.form-group').removeClass('has-error'); | ||
| 93 | - }, | ||
| 94 | - | ||
| 95 | - submitHandler : function(f) { | ||
| 96 | - var params = form.serializeJSON(); | ||
| 97 | - error.hide(); | 107 | + success : function(label) { |
| 108 | + label.closest('.form-group').removeClass('has-error'); | ||
| 109 | + }, | ||
| 98 | 110 | ||
| 99 | - var keys; | ||
| 100 | - $.ajax({ | ||
| 101 | - url: "/user/login/jCryptionKey?t="+Math.random(), | ||
| 102 | - type: "Get", | ||
| 103 | - async:false, | ||
| 104 | - data: null, | ||
| 105 | - success: function(data) { | ||
| 106 | - keys = data.publickey; | ||
| 107 | - } | ||
| 108 | - }); | ||
| 109 | - //RSA加密 | ||
| 110 | - var encrypt = new JSEncrypt(); | ||
| 111 | - encrypt.setPublicKey(keys); | ||
| 112 | - params.oldPWD = encrypt.encrypt(params.oldPWD); | ||
| 113 | - params.newPWD = encrypt.encrypt(params.newPWD); | ||
| 114 | - params.cnewPWD = encrypt.encrypt(params.cnewPWD); | ||
| 115 | - $.ajax({ | ||
| 116 | - url: '/user/changePWD', | ||
| 117 | - type: 'POST', | ||
| 118 | - traditional: true, | ||
| 119 | - data: params, | ||
| 120 | - success: function(msg){ | ||
| 121 | - layer.close(); | ||
| 122 | - } | ||
| 123 | - }); | ||
| 124 | - } | ||
| 125 | - }); | ||
| 126 | -}); | 111 | + submitHandler : function(f) { |
| 112 | + var params = form.serializeJSON(); | ||
| 113 | + error.hide(); | ||
| 114 | + var keys; | ||
| 115 | + $.ajax({ | ||
| 116 | + url: "/user/login/jCryptionKey?t="+Math.random(), | ||
| 117 | + type: "Get", | ||
| 118 | + async:false, | ||
| 119 | + data: null, | ||
| 120 | + success: function(data) { | ||
| 121 | + keys = data.publickey; | ||
| 122 | + } | ||
| 123 | + }); | ||
| 124 | + //RSA加密 | ||
| 125 | + var encrypt = new JSEncrypt(); | ||
| 126 | + encrypt.setPublicKey(keys); | ||
| 127 | + params.oldPWD = encrypt.encrypt(params.oldPWD); | ||
| 128 | + params.newPWD = encrypt.encrypt(params.newPWD); | ||
| 129 | + params.cnewPWD = encrypt.encrypt(params.cnewPWD); | ||
| 130 | + $.ajax({ | ||
| 131 | + url: '/user/changePWD', | ||
| 132 | + type: 'POST', | ||
| 133 | + traditional: true, | ||
| 134 | + data: params, | ||
| 135 | + success: function(msg){ | ||
| 136 | + layer.alert(msg); | ||
| 137 | + layer.closeAll('page'); | ||
| 138 | + } | ||
| 139 | + }); | ||
| 140 | + } | ||
| 141 | + }); | ||
| 142 | + }); | ||
| 127 | </script> | 143 | </script> |
| 128 | \ No newline at end of file | 144 | \ No newline at end of file |
src/main/resources/static/pages/permission/user/list.html
| 1 | -<div class="page-head"> | ||
| 2 | - <div class="page-title"> | ||
| 3 | - <h1>用户管理</h1> | ||
| 4 | - </div> | ||
| 5 | -</div> | ||
| 6 | - | ||
| 7 | -<ul class="page-breadcrumb breadcrumb"> | ||
| 8 | - <li><a href="/pages/home.html" data-pjax>首页</a> <i class="fa fa-circle"></i></li> | ||
| 9 | - <li><span class="active">权限管理</span> <i class="fa fa-circle"></i></li> | ||
| 10 | - <li><span class="active">用户管理</span></li> | ||
| 11 | -</ul> | ||
| 12 | - | ||
| 13 | -<div class="row"> | ||
| 14 | - <div class="col-md-12"> | ||
| 15 | - <!-- Begin: life time stats --> | ||
| 16 | - <div class="portlet light portlet-fit portlet-datatable bordered"> | ||
| 17 | - <div class="portlet-title"> | ||
| 18 | - <div class="caption"> | ||
| 19 | - <i class="fa fa-users font-dark"></i> <span | ||
| 20 | - class="caption-subject font-dark sbold uppercase">用户数据表</span> | ||
| 21 | - </div> | ||
| 22 | - <div class="actions"> | ||
| 23 | - <a class="btn btn-circle blue" href="add.html" data-pjax><i class="fa fa-plus"></i> 添加用户</a> | ||
| 24 | - | ||
| 25 | - </div> | ||
| 26 | - </div> | ||
| 27 | - <div class="portlet-body"> | ||
| 28 | - <div class="table-container" style="margin-top: 10px"> | ||
| 29 | - <table | ||
| 30 | - class="table table-striped table-bordered table-hover table-checkable" | ||
| 31 | - id="datatable_user"> | ||
| 32 | - <thead> | ||
| 33 | - <tr role="row" class="heading"> | ||
| 34 | - <th width="3%">#</th> | ||
| 35 | - <th width="15%">登录名</th> | ||
| 36 | - <th width="13%">姓名</th> | ||
| 37 | - <th width="100">所属机构</th> | ||
| 38 | - <th width="11%">角色</th> | ||
| 39 | - <th width="10%">状态</th> | ||
| 40 | - <th width="18%">最后登录时间</th> | ||
| 41 | - <th width="18%">操作</th> | ||
| 42 | - </tr> | ||
| 43 | - <tr role="row" class="filter"> | ||
| 44 | - <td></td> | ||
| 45 | - <td> | ||
| 46 | - <input type="text" class="form-control form-filter input-sm" name="userName_like"> | ||
| 47 | - </td> | ||
| 48 | - <td> | ||
| 49 | - <input type="text" class="form-control form-filter input-sm" name="name_like"> | ||
| 50 | - </td> | ||
| 51 | - <td> | ||
| 52 | - <input type="text" class="form-control form-filter input-sm" name="agencies_like"> | ||
| 53 | - </td> | ||
| 54 | - <td></td> | ||
| 55 | - <td> | ||
| 56 | - <select class="form-control form-filter " name="enabled_eq"> | ||
| 57 | - <option value="">请选择...</option> | ||
| 58 | - <option value="true">可用</option> | ||
| 59 | - <option value="false">禁用</option> | ||
| 60 | - </select> | ||
| 61 | - </td> | ||
| 62 | - <td></td> | ||
| 63 | - | ||
| 64 | - <td> | ||
| 65 | - <button class="btn btn-sm green btn-outline filter-submit margin-bottom" > | ||
| 66 | - <i class="fa fa-search"></i> 搜索</button> | ||
| 67 | - | ||
| 68 | - <button class="btn btn-sm red btn-outline filter-cancel"> | ||
| 69 | - <i class="fa fa-times"></i> 重置</button> | ||
| 70 | - </td> | ||
| 71 | - </tr> | ||
| 72 | - </thead> | ||
| 73 | - <tbody></tbody> | ||
| 74 | - </table> | ||
| 75 | - <div style="text-align: right;"> | ||
| 76 | - <ul id="pagination" class="pagination"></ul> | ||
| 77 | - </div> | ||
| 78 | - </div> | ||
| 79 | - </div> | ||
| 80 | - </div> | ||
| 81 | - </div> | ||
| 82 | -</div> | ||
| 83 | - | ||
| 84 | -<script id="user_list_temp" type="text/html"> | ||
| 85 | -{{each list as obj i}} | ||
| 86 | -<tr> | ||
| 87 | - <td style="vertical-align: middle;"> | ||
| 88 | - <!--<input type="checkbox" class="group-checkable icheck" data-id="{{obj.id}}">--> | ||
| 89 | - {{++i}} | ||
| 90 | - </td> | ||
| 91 | - <td> | ||
| 92 | - {{obj.userName}} | ||
| 93 | - </td> | ||
| 94 | - <td> | ||
| 95 | - {{obj.name}} | ||
| 96 | - </td> | ||
| 97 | - <td> | ||
| 98 | - {{obj.agencies}} | ||
| 99 | - </td> | ||
| 100 | - <td> | ||
| 101 | - {{each obj.roles as role j}} | ||
| 102 | - {{role.roleName}}、 | ||
| 103 | - {{/each}} | ||
| 104 | - </td> | ||
| 105 | - <td> | ||
| 106 | - {{if obj.enabled}} | ||
| 107 | - 可用 | ||
| 108 | - {{else}} | ||
| 109 | - 禁用 | ||
| 110 | - {{/if}} | ||
| 111 | - </td> | ||
| 112 | - <td> | ||
| 113 | - {{obj.lastLoginDate}} | ||
| 114 | - </td> | ||
| 115 | - <td> | ||
| 116 | - {{if obj.isEdit == 0}} | ||
| 117 | - <a class="btn btn-sm blue btn-outline" href="edit.html?no={{obj.id}}" data-pjax><i class="fa fa-edit"></i> 编辑</a> | ||
| 118 | - <!--<button type="button" class="btn btn-sm line_allot_btn" data-id="{{obj.id}}">线调线路分配</button>--> | ||
| 119 | - {{/if}} | ||
| 120 | - {{if obj.isAdmin}} | ||
| 121 | - <a class="btn btn-sm red btn-outline reset_password" data-id="{{obj.id}}" data-name="{{obj.userName}}" data-pjax><i class="fa fa-undo"></i> 重置密码</a> | ||
| 122 | - {{/if}} | ||
| 123 | - </td> | ||
| 124 | -</tr> | ||
| 125 | -{{/each}} | ||
| 126 | -{{if list.length == 0}} | ||
| 127 | -<tr> | ||
| 128 | - <td colspan=8><h6 class="muted">没有找到相关数据</h6></td> | ||
| 129 | -</tr> | ||
| 130 | -{{/if}} | ||
| 131 | -</script> | ||
| 132 | - | ||
| 133 | -<script> | ||
| 134 | -$(function(){ | ||
| 135 | - var page = 0, initPagination; | ||
| 136 | - var user,isAdmin = false; | ||
| 137 | - var icheckOptions = { | ||
| 138 | - checkboxClass: 'icheckbox_flat-blue', | ||
| 139 | - increaseArea: '20%' | ||
| 140 | - }; | ||
| 141 | - $.get('/user/getCurrentUser', function(data) { | ||
| 142 | - user = data; | ||
| 143 | - var roles = user.roles; | ||
| 144 | - $.each(roles,function () { | ||
| 145 | - if(this.level == 1) | ||
| 146 | - isAdmin = true; | ||
| 147 | - }) | ||
| 148 | - | ||
| 149 | - }); | ||
| 150 | - | ||
| 151 | - setTimeout(function () { | ||
| 152 | - $(document).on('click', 'a.reset_password', function () { | ||
| 153 | - var id = $(this).data('id'); | ||
| 154 | - var name = $(this).data('name'); | ||
| 155 | - swal({ | ||
| 156 | - title: "重装密码", | ||
| 157 | - text: "将登录名为"+name+"的用户,密码重置为默认密码!", | ||
| 158 | - type: "warning", | ||
| 159 | - showCancelButton: true, | ||
| 160 | - confirmButtonColor: "#DD6B55", | ||
| 161 | - confirmButtonText: "重置", | ||
| 162 | - cancelButtonText: "取消", | ||
| 163 | - closeOnConfirm: false }, | ||
| 164 | - function(){ | ||
| 165 | - $.post('/user/resetPassword',{'id':id},function(result){ | ||
| 166 | - if(result.status=='SUCCESS') { | ||
| 167 | - // 弹出添加成功提示消息 | ||
| 168 | - swal("登录名为"+name+"的用户密码重置成功!", "success"); | ||
| 169 | - } else if(result.status=='ERROR') { | ||
| 170 | - // 弹出添加失败提示消息 | ||
| 171 | - swal("重置失败!", result.msg+",请联系开发人员!", "ERROR"); | ||
| 172 | - } | ||
| 173 | - // loadPage('list.html'); | ||
| 174 | - // 发布后刷新页面 | ||
| 175 | - jsDoQuery(getParams(), true); | ||
| 176 | - }); | ||
| 177 | - }); | ||
| 178 | - }); | ||
| 179 | - jsDoQuery(null,true); | ||
| 180 | - | ||
| 181 | - //重置 | ||
| 182 | - $('tr.filter .filter-cancel').on('click', function(){ | ||
| 183 | - $('tr.filter input, select').val('').change(); | ||
| 184 | - jsDoQuery(null, true); | ||
| 185 | - }); | ||
| 186 | - | ||
| 187 | - function getParams() { | ||
| 188 | - var cells = $('tr.filter')[0].cells | ||
| 189 | - ,params = {} | ||
| 190 | - ,name; | ||
| 191 | - $.each(cells, function(i, cell){ | ||
| 192 | - var items = $('input,select', cell); | ||
| 193 | - for(var j = 0, item; item = items[j++];){ | ||
| 194 | - name = $(item).attr('name'); | ||
| 195 | - if(name){ | ||
| 196 | - params[name] = $(item).val(); | ||
| 197 | - } | ||
| 198 | - } | ||
| 199 | - }); | ||
| 200 | - return params; | ||
| 201 | - } | ||
| 202 | - | ||
| 203 | - //提交 | ||
| 204 | - $('tr.filter .filter-submit').on('click', function(){ | ||
| 205 | - jsDoQuery(getParams(), true); | ||
| 206 | - }); | ||
| 207 | - | ||
| 208 | - /* | ||
| 209 | - * 获取数据 p: 要提交的参数, pagination: 是否重新分页 | ||
| 210 | - */ | ||
| 211 | - function jsDoQuery(p, pagination){ | ||
| 212 | - var roles = new Map(); | ||
| 213 | - // 查询下级角色 | ||
| 214 | - $.ajax({ | ||
| 215 | - url: "/role/findSubordinate", | ||
| 216 | - type: "Get", | ||
| 217 | - async:false, | ||
| 218 | - data: null, | ||
| 219 | - success: function (rs) { | ||
| 220 | - if(rs.status == "SUCCESS"){ | ||
| 221 | - $.each(rs.list,function(i,obj){ | ||
| 222 | - roles[obj.id] = obj; | ||
| 223 | - }); | ||
| 224 | - } | ||
| 225 | - } | ||
| 226 | - }); | ||
| 227 | - var params = {}; | ||
| 228 | - if(p) | ||
| 229 | - params = p; | ||
| 230 | - //更新时间排序 | ||
| 231 | - params['order'] = 'lastLoginDate'; | ||
| 232 | - params['page'] = page; | ||
| 233 | - // params['id_eq'] = "1"; | ||
| 234 | - var i = layer.load(2); | ||
| 235 | - $get('/user' ,params, function(data){ | ||
| 236 | - var list = data.content; | ||
| 237 | - $.each(list, function(i, obj) { | ||
| 238 | - if(roles[obj.roles[0].id] != null && roles[obj.roles[0].id] != undefined){ | ||
| 239 | - obj.isEdit = 0; | ||
| 240 | - } else{ | ||
| 241 | - obj.isEdit = 1; | ||
| 242 | - } | ||
| 243 | - obj.isAdmin = isAdmin; | ||
| 244 | - obj.lastLoginDate = moment(obj.lastLoginDate).format("YYYY-MM-DD HH:mm:ss"); | ||
| 245 | - }); | ||
| 246 | - | ||
| 247 | - var bodyHtm = template('user_list_temp', {list: list}); | ||
| 248 | - | ||
| 249 | - $('#datatable_user tbody').html(bodyHtm) | ||
| 250 | - .find('.icheck').iCheck(icheckOptions) | ||
| 251 | - .on('ifChanged', iCheckChange); | ||
| 252 | - if(pagination && list.length > 0){ | ||
| 253 | - //重新分页 | ||
| 254 | - initPagination = true; | ||
| 255 | - showPagination(data); | ||
| 256 | - } | ||
| 257 | - layer.close(i); | ||
| 258 | - | ||
| 259 | - $('.line_allot_btn').on('click', openAllotWindow); | ||
| 260 | - }); | ||
| 261 | - } | ||
| 262 | - | ||
| 263 | - function iCheckChange(){ | ||
| 264 | - var tr = $(this).parents('tr'); | ||
| 265 | - if(this.checked) | ||
| 266 | - tr.addClass('row-active'); | ||
| 267 | - else | ||
| 268 | - tr.removeClass('row-active'); | ||
| 269 | - | ||
| 270 | - if($('#datatable_resource input.icheck:checked').length == 1) | ||
| 271 | - $('#removeButton').removeAttr('disabled'); | ||
| 272 | - else | ||
| 273 | - $('#removeButton').attr('disabled', 'disabled'); | ||
| 274 | - } | ||
| 275 | - | ||
| 276 | - function showPagination(data){ | ||
| 277 | - //分页 | ||
| 278 | - $('#pagination').jqPaginator({ | ||
| 279 | - totalPages: data.totalPages, | ||
| 280 | - visiblePages: 6, | ||
| 281 | - currentPage: page + 1, | ||
| 282 | - first: '<li class="first"><a href="javascript:void(0);">首页<\/a><\/li>', | ||
| 283 | - prev: '<li class="prev"><a href="javascript:void(0);">上一页<\/a><\/li>', | ||
| 284 | - next: '<li class="next"><a href="javascript:void(0);">下一页<\/a><\/li>', | ||
| 285 | - last: '<li class="last"><a href="javascript:void(0);">尾页<\/a><\/li>', | ||
| 286 | - page: '<li class="page"><a href="javascript:void(0);">{{page}}<\/a><\/li>', | ||
| 287 | - onPageChange: function (num, type) { | ||
| 288 | - if(initPagination){ | ||
| 289 | - initPagination = false; | ||
| 290 | - return; | ||
| 291 | - } | ||
| 292 | - | ||
| 293 | - | ||
| 294 | - page = num - 1; | ||
| 295 | - jsDoQuery(null, false); | ||
| 296 | - } | ||
| 297 | - }); | ||
| 298 | - } | ||
| 299 | - | ||
| 300 | - function openAllotWindow() { | ||
| 301 | - var id = $(this).data('id'); | ||
| 302 | - $.get('/pages/permission/user/controlAllot.html', function (content) { | ||
| 303 | - layer.open({ | ||
| 304 | - type: 1, | ||
| 305 | - area: ['600px', '395px'], | ||
| 306 | - content: content, | ||
| 307 | - title: '线路调度权限分配', | ||
| 308 | - shift: 5, | ||
| 309 | - scrollbar: false, | ||
| 310 | - success: function () { | ||
| 311 | - $('#pageRealControlAllotWrap').trigger('init', id); | ||
| 312 | - } | ||
| 313 | - }); | ||
| 314 | - }); | ||
| 315 | - } | ||
| 316 | - | ||
| 317 | - //删除 | ||
| 318 | - $('#removeButton').on('click', function(){ | ||
| 319 | - if($(this).attr('disabled')) | ||
| 320 | - return; | ||
| 321 | - | ||
| 322 | - var id = $('#datatable_resource input.icheck:checked').data('id'); | ||
| 323 | - | ||
| 324 | - removeConfirm('确定要删除选中的数据?', '/resource/' + id ,function(){ | ||
| 325 | - $('tr.filter .filter-submit').click(); | ||
| 326 | - }); | ||
| 327 | - }); | ||
| 328 | - },1000); | ||
| 329 | - | ||
| 330 | -}); | ||
| 331 | -//改变状态 | ||
| 332 | -function changeEnabled(id,enabled){ | ||
| 333 | - $get('/user/changeEnabled',{id:id,enabled:enabled},function(result){ | ||
| 334 | - jsDoQuery(null, true); | ||
| 335 | - }) | ||
| 336 | -} | 1 | +<div class="page-head"> |
| 2 | + <div class="page-title"> | ||
| 3 | + <h1>用户管理</h1> | ||
| 4 | + </div> | ||
| 5 | +</div> | ||
| 6 | + | ||
| 7 | +<ul class="page-breadcrumb breadcrumb"> | ||
| 8 | + <li><a href="/pages/home.html" data-pjax>首页</a> <i class="fa fa-circle"></i></li> | ||
| 9 | + <li><span class="active">权限管理</span> <i class="fa fa-circle"></i></li> | ||
| 10 | + <li><span class="active">用户管理</span></li> | ||
| 11 | +</ul> | ||
| 12 | + | ||
| 13 | +<div class="row"> | ||
| 14 | + <div class="col-md-12"> | ||
| 15 | + <!-- Begin: life time stats --> | ||
| 16 | + <div class="portlet light portlet-fit portlet-datatable bordered"> | ||
| 17 | + <div class="portlet-title"> | ||
| 18 | + <div class="caption"> | ||
| 19 | + <i class="fa fa-users font-dark"></i> <span | ||
| 20 | + class="caption-subject font-dark sbold uppercase">用户数据表</span> | ||
| 21 | + </div> | ||
| 22 | + <div class="actions"> | ||
| 23 | + <a class="btn btn-circle blue" href="add.html" data-pjax><i class="fa fa-plus"></i> 添加用户</a> | ||
| 24 | + | ||
| 25 | + </div> | ||
| 26 | + </div> | ||
| 27 | + <div class="portlet-body"> | ||
| 28 | + <div class="table-container" style="margin-top: 10px"> | ||
| 29 | + <table | ||
| 30 | + class="table table-striped table-bordered table-hover table-checkable" | ||
| 31 | + id="datatable_user"> | ||
| 32 | + <thead> | ||
| 33 | + <tr role="row" class="heading"> | ||
| 34 | + <th width="3%">#</th> | ||
| 35 | + <th width="10%">登录名</th> | ||
| 36 | + <th width="10%">姓名</th> | ||
| 37 | + <th width="12%">所属机构</th> | ||
| 38 | + <th width="11%">角色</th> | ||
| 39 | + <th width="10%">状态</th> | ||
| 40 | + <th width="18%">最后登录时间</th> | ||
| 41 | + <th width="26%">操作</th> | ||
| 42 | + </tr> | ||
| 43 | + <tr role="row" class="filter"> | ||
| 44 | + <td></td> | ||
| 45 | + <td> | ||
| 46 | + <input type="text" class="form-control form-filter input-sm" name="userName_like"> | ||
| 47 | + </td> | ||
| 48 | + <td> | ||
| 49 | + <input type="text" class="form-control form-filter input-sm" name="name_like"> | ||
| 50 | + </td> | ||
| 51 | + <td> | ||
| 52 | + <input type="text" class="form-control form-filter input-sm" name="agencies_like"> | ||
| 53 | + </td> | ||
| 54 | + <td></td> | ||
| 55 | + <td> | ||
| 56 | + <select class="form-control form-filter " name="enabled_eq"> | ||
| 57 | + <option value="">请选择...</option> | ||
| 58 | + <option value="true">可用</option> | ||
| 59 | + <option value="false">禁用</option> | ||
| 60 | + </select> | ||
| 61 | + </td> | ||
| 62 | + <td></td> | ||
| 63 | + | ||
| 64 | + <td> | ||
| 65 | + <button class="btn btn-sm green btn-outline filter-submit margin-bottom" > | ||
| 66 | + <i class="fa fa-search"></i> 搜索</button> | ||
| 67 | + | ||
| 68 | + <button class="btn btn-sm red btn-outline filter-cancel"> | ||
| 69 | + <i class="fa fa-times"></i> 重置</button> | ||
| 70 | + </td> | ||
| 71 | + </tr> | ||
| 72 | + </thead> | ||
| 73 | + <tbody></tbody> | ||
| 74 | + </table> | ||
| 75 | + <div style="text-align: right;"> | ||
| 76 | + <ul id="pagination" class="pagination"></ul> | ||
| 77 | + </div> | ||
| 78 | + </div> | ||
| 79 | + </div> | ||
| 80 | + </div> | ||
| 81 | + </div> | ||
| 82 | +</div> | ||
| 83 | + | ||
| 84 | +<script id="user_list_temp" type="text/html"> | ||
| 85 | +{{each list as obj i}} | ||
| 86 | +<tr> | ||
| 87 | + <td style="vertical-align: middle;"> | ||
| 88 | + <!--<input type="checkbox" class="group-checkable icheck" data-id="{{obj.id}}">--> | ||
| 89 | + {{++i}} | ||
| 90 | + </td> | ||
| 91 | + <td> | ||
| 92 | + {{obj.userName}} | ||
| 93 | + </td> | ||
| 94 | + <td> | ||
| 95 | + {{obj.name}} | ||
| 96 | + </td> | ||
| 97 | + <td> | ||
| 98 | + {{obj.agencies}} | ||
| 99 | + </td> | ||
| 100 | + <td> | ||
| 101 | + {{each obj.roles as role j}} | ||
| 102 | + {{role.roleName}}、 | ||
| 103 | + {{/each}} | ||
| 104 | + </td> | ||
| 105 | + <td> | ||
| 106 | + {{if obj.enabled}} | ||
| 107 | + 可用 | ||
| 108 | + {{else}} | ||
| 109 | + 禁用 | ||
| 110 | + {{/if}} | ||
| 111 | + </td> | ||
| 112 | + <td> | ||
| 113 | + {{obj.lastLoginDate}} | ||
| 114 | + </td> | ||
| 115 | + <td> | ||
| 116 | + {{if obj.isEdit == 0}} | ||
| 117 | + <a class="btn btn-sm blue btn-outline" href="edit.html?no={{obj.id}}" data-pjax><i class="fa fa-edit"></i> 编辑</a> | ||
| 118 | + <!--<button type="button" class="btn btn-sm line_allot_btn" data-id="{{obj.id}}">线调线路分配</button>--> | ||
| 119 | + {{/if}} | ||
| 120 | + {{if obj.isAdmin}} | ||
| 121 | + <a class="btn btn-sm red btn-outline reset_password" data-id="{{obj.id}}" data-name="{{obj.userName}}" data-pjax><i class="fa fa-undo"></i> 重置密码</a> | ||
| 122 | + {{/if}} | ||
| 123 | + {{if obj.isAdmin}} | ||
| 124 | + <a class="btn btn-sm red btn-outline unlock" data-name="{{obj.userName}}" data-pjax><i class="fa fa-unlock"></i> 解除锁定</a> | ||
| 125 | + {{/if}} | ||
| 126 | + </td> | ||
| 127 | +</tr> | ||
| 128 | +{{/each}} | ||
| 129 | +{{if list.length == 0}} | ||
| 130 | +<tr> | ||
| 131 | + <td colspan=8><h6 class="muted">没有找到相关数据</h6></td> | ||
| 132 | +</tr> | ||
| 133 | +{{/if}} | ||
| 134 | +</script> | ||
| 135 | + | ||
| 136 | +<script> | ||
| 137 | +$(function(){ | ||
| 138 | + var page = 0, initPagination; | ||
| 139 | + var user,isAdmin = false; | ||
| 140 | + var icheckOptions = { | ||
| 141 | + checkboxClass: 'icheckbox_flat-blue', | ||
| 142 | + increaseArea: '20%' | ||
| 143 | + }; | ||
| 144 | + $.get('/user/getCurrentUser', function(data) { | ||
| 145 | + user = data; | ||
| 146 | + var roles = user.roles; | ||
| 147 | + $.each(roles,function () { | ||
| 148 | + if(this.level == 1) | ||
| 149 | + isAdmin = true; | ||
| 150 | + }) | ||
| 151 | + | ||
| 152 | + }); | ||
| 153 | + | ||
| 154 | + setTimeout(function () { | ||
| 155 | + $(document).on('click', 'a.reset_password', function () { | ||
| 156 | + var id = $(this).data('id'); | ||
| 157 | + var name = $(this).data('name'); | ||
| 158 | + swal({ | ||
| 159 | + title: "重置密码", | ||
| 160 | + text: "将登录名为"+name+"的用户,密码重置为随机密码!", | ||
| 161 | + type: "warning", | ||
| 162 | + showCancelButton: true, | ||
| 163 | + confirmButtonColor: "#DD6B55", | ||
| 164 | + confirmButtonText: "重置", | ||
| 165 | + cancelButtonText: "取消", | ||
| 166 | + closeOnConfirm: false }, | ||
| 167 | + function(){ | ||
| 168 | + $.post('/user/resetPassword',{'id':id},function(result){ | ||
| 169 | + if(result.status=='SUCCESS') { | ||
| 170 | + // 弹出添加成功提示消息 | ||
| 171 | + swal("登录名为"+name+"的用户密码重置成功!", "success"); | ||
| 172 | + } else if(result.status=='ERROR') { | ||
| 173 | + // 弹出添加失败提示消息 | ||
| 174 | + swal("重置失败!", result.msg+",请联系开发人员!", "ERROR"); | ||
| 175 | + } | ||
| 176 | + // loadPage('list.html'); | ||
| 177 | + // 发布后刷新页面 | ||
| 178 | + jsDoQuery(getParams(), true); | ||
| 179 | + }); | ||
| 180 | + }); | ||
| 181 | + }).on('click', 'a.unlock', function () { | ||
| 182 | + var name = $(this).data('name'); | ||
| 183 | + swal({ | ||
| 184 | + title: "解除锁定", | ||
| 185 | + text: "将登录名为"+name+"的用户,锁定状态解除!", | ||
| 186 | + type: "warning", | ||
| 187 | + showCancelButton: true, | ||
| 188 | + confirmButtonColor: "#DD6B55", | ||
| 189 | + confirmButtonText: "重置", | ||
| 190 | + cancelButtonText: "取消", | ||
| 191 | + closeOnConfirm: false }, | ||
| 192 | + function(){ | ||
| 193 | + $.post('/user/unlock',{'userName':name},function(result){ | ||
| 194 | + if(result.status=='SUCCESS') { | ||
| 195 | + // 弹出添加成功提示消息 | ||
| 196 | + swal("登录名为"+name+"的用户锁定解除成功!", "success"); | ||
| 197 | + } else if(result.status=='ERROR') { | ||
| 198 | + // 弹出添加失败提示消息 | ||
| 199 | + swal("锁定解除失败!", result.msg+",请联系开发人员!", "ERROR"); | ||
| 200 | + } | ||
| 201 | + jsDoQuery(getParams(), true); | ||
| 202 | + }); | ||
| 203 | + }); | ||
| 204 | + }); | ||
| 205 | + jsDoQuery(null,true); | ||
| 206 | + | ||
| 207 | + //重置 | ||
| 208 | + $('tr.filter .filter-cancel').on('click', function(){ | ||
| 209 | + $('tr.filter input, select').val('').change(); | ||
| 210 | + jsDoQuery(null, true); | ||
| 211 | + }); | ||
| 212 | + | ||
| 213 | + function getParams() { | ||
| 214 | + var cells = $('tr.filter')[0].cells | ||
| 215 | + ,params = {} | ||
| 216 | + ,name; | ||
| 217 | + $.each(cells, function(i, cell){ | ||
| 218 | + var items = $('input,select', cell); | ||
| 219 | + for(var j = 0, item; item = items[j++];){ | ||
| 220 | + name = $(item).attr('name'); | ||
| 221 | + if(name){ | ||
| 222 | + params[name] = $(item).val(); | ||
| 223 | + } | ||
| 224 | + } | ||
| 225 | + }); | ||
| 226 | + return params; | ||
| 227 | + } | ||
| 228 | + | ||
| 229 | + //提交 | ||
| 230 | + $('tr.filter .filter-submit').on('click', function(){ | ||
| 231 | + jsDoQuery(getParams(), true); | ||
| 232 | + }); | ||
| 233 | + | ||
| 234 | + /* | ||
| 235 | + * 获取数据 p: 要提交的参数, pagination: 是否重新分页 | ||
| 236 | + */ | ||
| 237 | + function jsDoQuery(p, pagination){ | ||
| 238 | + var roles = new Map(); | ||
| 239 | + // 查询下级角色 | ||
| 240 | + $.ajax({ | ||
| 241 | + url: "/role/findSubordinate", | ||
| 242 | + type: "Get", | ||
| 243 | + async:false, | ||
| 244 | + data: null, | ||
| 245 | + success: function (rs) { | ||
| 246 | + if(rs.status == "SUCCESS"){ | ||
| 247 | + $.each(rs.list,function(i,obj){ | ||
| 248 | + roles[obj.id] = obj; | ||
| 249 | + }); | ||
| 250 | + } | ||
| 251 | + } | ||
| 252 | + }); | ||
| 253 | + var params = {}; | ||
| 254 | + if(p) | ||
| 255 | + params = p; | ||
| 256 | + //更新时间排序 | ||
| 257 | + params['order'] = 'lastLoginDate'; | ||
| 258 | + params['page'] = page; | ||
| 259 | + // params['id_eq'] = "1"; | ||
| 260 | + var i = layer.load(2); | ||
| 261 | + $get('/user' ,params, function(data){ | ||
| 262 | + var list = data.content; | ||
| 263 | + $.each(list, function(i, obj) { | ||
| 264 | + if(roles[obj.roles[0].id] != null && roles[obj.roles[0].id] != undefined){ | ||
| 265 | + obj.isEdit = 0; | ||
| 266 | + } else{ | ||
| 267 | + obj.isEdit = 1; | ||
| 268 | + } | ||
| 269 | + obj.isAdmin = isAdmin; | ||
| 270 | + obj.lastLoginDate = moment(obj.lastLoginDate).format("YYYY-MM-DD HH:mm:ss"); | ||
| 271 | + }); | ||
| 272 | + | ||
| 273 | + var bodyHtm = template('user_list_temp', {list: list}); | ||
| 274 | + | ||
| 275 | + $('#datatable_user tbody').html(bodyHtm) | ||
| 276 | + .find('.icheck').iCheck(icheckOptions) | ||
| 277 | + .on('ifChanged', iCheckChange); | ||
| 278 | + if(pagination && list.length > 0){ | ||
| 279 | + //重新分页 | ||
| 280 | + initPagination = true; | ||
| 281 | + showPagination(data); | ||
| 282 | + } | ||
| 283 | + layer.close(i); | ||
| 284 | + | ||
| 285 | + $('.line_allot_btn').on('click', openAllotWindow); | ||
| 286 | + }); | ||
| 287 | + } | ||
| 288 | + | ||
| 289 | + function iCheckChange(){ | ||
| 290 | + var tr = $(this).parents('tr'); | ||
| 291 | + if(this.checked) | ||
| 292 | + tr.addClass('row-active'); | ||
| 293 | + else | ||
| 294 | + tr.removeClass('row-active'); | ||
| 295 | + | ||
| 296 | + if($('#datatable_resource input.icheck:checked').length == 1) | ||
| 297 | + $('#removeButton').removeAttr('disabled'); | ||
| 298 | + else | ||
| 299 | + $('#removeButton').attr('disabled', 'disabled'); | ||
| 300 | + } | ||
| 301 | + | ||
| 302 | + function showPagination(data){ | ||
| 303 | + //分页 | ||
| 304 | + $('#pagination').jqPaginator({ | ||
| 305 | + totalPages: data.totalPages, | ||
| 306 | + visiblePages: 6, | ||
| 307 | + currentPage: page + 1, | ||
| 308 | + first: '<li class="first"><a href="javascript:void(0);">首页<\/a><\/li>', | ||
| 309 | + prev: '<li class="prev"><a href="javascript:void(0);">上一页<\/a><\/li>', | ||
| 310 | + next: '<li class="next"><a href="javascript:void(0);">下一页<\/a><\/li>', | ||
| 311 | + last: '<li class="last"><a href="javascript:void(0);">尾页<\/a><\/li>', | ||
| 312 | + page: '<li class="page"><a href="javascript:void(0);">{{page}}<\/a><\/li>', | ||
| 313 | + onPageChange: function (num, type) { | ||
| 314 | + if(initPagination){ | ||
| 315 | + initPagination = false; | ||
| 316 | + return; | ||
| 317 | + } | ||
| 318 | + | ||
| 319 | + | ||
| 320 | + page = num - 1; | ||
| 321 | + jsDoQuery(null, false); | ||
| 322 | + } | ||
| 323 | + }); | ||
| 324 | + } | ||
| 325 | + | ||
| 326 | + function openAllotWindow() { | ||
| 327 | + var id = $(this).data('id'); | ||
| 328 | + $.get('/pages/permission/user/controlAllot.html', function (content) { | ||
| 329 | + layer.open({ | ||
| 330 | + type: 1, | ||
| 331 | + area: ['600px', '395px'], | ||
| 332 | + content: content, | ||
| 333 | + title: '线路调度权限分配', | ||
| 334 | + shift: 5, | ||
| 335 | + scrollbar: false, | ||
| 336 | + success: function () { | ||
| 337 | + $('#pageRealControlAllotWrap').trigger('init', id); | ||
| 338 | + } | ||
| 339 | + }); | ||
| 340 | + }); | ||
| 341 | + } | ||
| 342 | + | ||
| 343 | + //删除 | ||
| 344 | + $('#removeButton').on('click', function(){ | ||
| 345 | + if($(this).attr('disabled')) | ||
| 346 | + return; | ||
| 347 | + | ||
| 348 | + var id = $('#datatable_resource input.icheck:checked').data('id'); | ||
| 349 | + | ||
| 350 | + removeConfirm('确定要删除选中的数据?', '/resource/' + id ,function(){ | ||
| 351 | + $('tr.filter .filter-submit').click(); | ||
| 352 | + }); | ||
| 353 | + }); | ||
| 354 | + },1000); | ||
| 355 | + | ||
| 356 | +}); | ||
| 357 | +//改变状态 | ||
| 358 | +function changeEnabled(id,enabled){ | ||
| 359 | + $get('/user/changeEnabled',{id:id,enabled:enabled},function(result){ | ||
| 360 | + jsDoQuery(null, true); | ||
| 361 | + }) | ||
| 362 | +} | ||
| 337 | </script> | 363 | </script> |
| 338 | \ No newline at end of file | 364 | \ No newline at end of file |
src/main/resources/static/pages/scheduleApp/module/common/main.js
| @@ -277,7 +277,6 @@ ScheduleApp.factory( | @@ -277,7 +277,6 @@ ScheduleApp.factory( | ||
| 277 | 277 | ||
| 278 | // 处理错误,springboot会包装返回的错误数据 | 278 | // 处理错误,springboot会包装返回的错误数据 |
| 279 | // 如:{"timestamp":1478674739246,"status":500,"error":"Internal Server Error","exception":"java.lang.ClassCastException","message":"java.lang.String cannot be cast to java.lang.Long","path":"/tidc/importfile"} | 279 | // 如:{"timestamp":1478674739246,"status":500,"error":"Internal Server Error","exception":"java.lang.ClassCastException","message":"java.lang.String cannot be cast to java.lang.Long","path":"/tidc/importfile"} |
| 280 | - | ||
| 281 | var output = []; | 280 | var output = []; |
| 282 | if (!rejection.status) { | 281 | if (!rejection.status) { |
| 283 | // alert("我擦,后台返回连个状态码都没返回,见鬼了,服务器可能重启了"); | 282 | // alert("我擦,后台返回连个状态码都没返回,见鬼了,服务器可能重启了"); |
| @@ -287,7 +286,13 @@ ScheduleApp.factory( | @@ -287,7 +286,13 @@ ScheduleApp.factory( | ||
| 287 | console.log("貌似服务端连接不上"); | 286 | console.log("貌似服务端连接不上"); |
| 288 | } else { | 287 | } else { |
| 289 | output.push("状态编码:" + rejection.status); | 288 | output.push("状态编码:" + rejection.status); |
| 290 | - output.push("错误内容:" + angular.toJson(rejection.data)); | 289 | + // output.push("错误内容:" + angular.toJson(rejection.data)); |
| 290 | + if (rejection.data) { | ||
| 291 | + output.push("错误内容:" + rejection.data.message); | ||
| 292 | + } else { | ||
| 293 | + output.push("错误内容:" + rejection.message); | ||
| 294 | + } | ||
| 295 | + | ||
| 291 | if (rejection.status == 500) { | 296 | if (rejection.status == 500) { |
| 292 | alert("服务端错误:" + "\n" + output.join("\n")); | 297 | alert("服务端错误:" + "\n" + output.join("\n")); |
| 293 | } else if (rejection.status == 407) { | 298 | } else if (rejection.status == 407) { |
| @@ -388,4 +393,4 @@ $.ajaxTransport("+binary", function(options, originalOptions, jqXHR){ | @@ -388,4 +393,4 @@ $.ajaxTransport("+binary", function(options, originalOptions, jqXHR){ | ||
| 388 | } | 393 | } |
| 389 | }; | 394 | }; |
| 390 | } | 395 | } |
| 391 | -}); | ||
| 392 | \ No newline at end of file | 396 | \ No newline at end of file |
| 397 | +}); |
src/main/resources/static/real_control_v2/alone_page/home/home_wrap.html
| 1 | -<!DOCTYPE html> | ||
| 2 | -<html lang="zh-cn"> | ||
| 3 | - | ||
| 4 | -<head> | ||
| 5 | - <meta charset="UTF-8"> | ||
| 6 | - <title>主页模拟图</title> | ||
| 7 | - <!-- uikit core style--> | ||
| 8 | - <link rel="stylesheet" href="/real_control_v2/assets/plugins/uikit-2.27.1/css/uikit.gradient.min.css" /> | ||
| 9 | - <link rel="stylesheet" href="/real_control_v2/assets/plugins/uikit-2.27.1/components/notify.gradient.min.css" merge="plugins"/> | ||
| 10 | - <link rel="stylesheet" href="/real_control_v2/assets/plugins/uikit-2.27.1/components/tooltip.gradient.min.css" merge="plugins"/> | ||
| 11 | - <link rel="stylesheet" | ||
| 12 | - href="/real_control_v2/assets/plugins/uikit-2.27.1/components/autocomplete.gradient.min.css" merge="plugins"/> | ||
| 13 | - <link rel="stylesheet" href="/real_control_v2/assets/plugins/uikit-2.27.1/components/sticky.gradient.min.css" merge="plugins"/> | ||
| 14 | - | ||
| 15 | - <!-- main style --> | ||
| 16 | - <link rel="stylesheet" href="/real_control_v2/css/main.css" /> | ||
| 17 | - <!-- home style --> | ||
| 18 | - <link rel="stylesheet" href="/real_control_v2/css/home.css" merge="custom_style"/> | ||
| 19 | - | ||
| 20 | - <!-- custom table --> | ||
| 21 | - <link rel="stylesheet" href="/real_control_v2/css/ct_table.css" merge="custom_style"/> | ||
| 22 | - <!-- jquery contextMenu style --> | ||
| 23 | - <link rel="stylesheet" href="/real_control_v2/assets/css/jquery.contextMenu.min.css" merge="plugins"/> | ||
| 24 | - <!-- formvalidation style --> | ||
| 25 | - <link rel="stylesheet" href="/real_control_v2/assets/plugins/formvalidation/formValidation.min.css" merge="plugins"/> | ||
| 26 | - <!-- js tree --> | ||
| 27 | - <link rel="stylesheet" href="/real_control_v2/assets/plugins/jstree/default/style.css" merge="plugins"/> | ||
| 28 | - <!-- tooltip css--> | ||
| 29 | - <link rel="stylesheet" href="/real_control_v2/assets/plugins/qtip/jquery.qtip.min.css" merge="plugins"/> | ||
| 30 | - <link rel="stylesheet" href="/real_control_v2/css/pace.css" merge="plugins"/> | ||
| 31 | - | ||
| 32 | - <link rel="stylesheet" href="/real_control_v2/css/modal_extend.css" merge="custom_style"/> | ||
| 33 | - <!-- perfect-scrollbar style --> | ||
| 34 | - <link rel="stylesheet" href="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.css" merge="plugins"/> | ||
| 35 | - <!-- layer 3.0.3 --> | ||
| 36 | - <link rel="stylesheet" href="/real_control_v2/assets/plugins/layer3.0.3/skin/default/layer.css" merge="plugins"/> | ||
| 37 | - <link rel="stylesheet" href="/real_control_v2/assets/plugins/layer3.0.3/skin/moon/style.css" merge="plugins"/> | ||
| 38 | - | ||
| 39 | - | ||
| 40 | - <style> | ||
| 41 | - .main-container{ | ||
| 42 | - height: 100% !important; | ||
| 43 | - } | ||
| 44 | - | ||
| 45 | - #main-tab-content{ | ||
| 46 | - padding: 0 !important; | ||
| 47 | - list-style: none; | ||
| 48 | - } | ||
| 49 | - | ||
| 50 | - .home-panel{ | ||
| 51 | - | ||
| 52 | - } | ||
| 53 | - | ||
| 54 | - #home-main-content{ | ||
| 55 | - padding: 0 !important; | ||
| 56 | - } | ||
| 57 | - | ||
| 58 | - #main-tab-content>.home-panel>#home-main-content{ | ||
| 59 | - overflow: inherit !important; | ||
| 60 | - } | ||
| 61 | - </style> | ||
| 62 | -</head> | ||
| 63 | - | ||
| 64 | -<body> | ||
| 65 | -<!--<div class="main-container" style="height: 100%;"> | ||
| 66 | -</div>--> | ||
| 67 | -<div class="main-container"> | ||
| 68 | - <ul id="main-tab-content"> | ||
| 69 | - <li class="home-panel"></li> | ||
| 70 | - </ul> | ||
| 71 | -</div> | ||
| 72 | - | ||
| 73 | - | ||
| 74 | -<!-- 地图相关 --> | ||
| 75 | -<script src="http://api.map.baidu.com/api?v=2.0&ak=IGGrr4UjwIYzatoCRFKEL8sT"></script> | ||
| 76 | -<script src="http://api.map.baidu.com/library/TrafficControl/1.4/src/TrafficControl_min.js"></script> | ||
| 77 | -<script src="/assets/js/baidu//MarkerClusterer.js" merge="plugins"></script> | ||
| 78 | -<script src="/assets/js/TransGPS.js" merge="plugins"></script> | ||
| 79 | -<!-- jquery --> | ||
| 80 | -<script src="/real_control_v2/assets/js/jquery.min.js"></script> | ||
| 81 | -<!-- jquery actual --> | ||
| 82 | -<script src="/real_control_v2/assets/js/jquery.actual.min.js" merge="plugins"></script> | ||
| 83 | -<!-- jquery.serializejson JSON序列化插件 --> | ||
| 84 | -<script src="/assets/plugins/jquery.serializejson.js" merge="plugins"></script> | ||
| 85 | -<!-- moment.js 日期处理类库 --> | ||
| 86 | -<script src="/real_control_v2/assets/plugins/moment/moment.min.js"></script> | ||
| 87 | -<script src="/real_control_v2/assets/plugins/moment/zh-cn.js"></script> | ||
| 88 | - | ||
| 89 | -<!-- flatpickr --> | ||
| 90 | -<script src="/real_control_v2/assets/plugins/flatpickr/flatpickr.min.js" merge="plugins"></script> | ||
| 91 | -<script src="/real_control_v2/assets/plugins/flatpickr/l10n/zh.js" merge="plugins"></script> | ||
| 92 | - | ||
| 93 | -<!-- perfect-scrollbar --> | ||
| 94 | -<script src="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.jquery.js" merge="plugins"></script> | ||
| 95 | -<!-- common js --> | ||
| 96 | -<script src="/real_control_v2/js/common.js"></script> | ||
| 97 | -<!-- art-template 模版引擎 --> | ||
| 98 | -<script src="/assets/plugins/template.js" merge="plugins"></script> | ||
| 99 | -<!-- d3 --> | ||
| 100 | -<script src="/assets/js/d3.min.js"></script> | ||
| 101 | -<!-- EventProxy --> | ||
| 102 | -<script src="/assets/js/eventproxy.js"></script> | ||
| 103 | -<!-- Geolib --> | ||
| 104 | -<script src="/real_control_v2/geolib/geolib.js" merge="plugins"></script> | ||
| 105 | - | ||
| 106 | -<script> | ||
| 107 | - | ||
| 108 | - | ||
| 109 | - var res_load_ep = EventProxy.create('load_home_layout', 'load_home_line_panel', 'load_data_basic', 'data-basic', function () { | ||
| 110 | - //加载主页 | ||
| 111 | - gb_home_layout.layout(function () { | ||
| 112 | - gb_home_line_panel.init(function () { | ||
| 113 | - //gps自刷新 | ||
| 114 | - gb_data_gps.fixedTimeRefresh(); | ||
| 115 | - | ||
| 116 | - $('.uk-icon-send-o.home_alone_page').remove(); | ||
| 117 | - }); | ||
| 118 | - }); | ||
| 119 | - }); | ||
| 120 | - | ||
| 121 | - function connectArr(arr, separator, transFun) { | ||
| 122 | - var rs = ''; | ||
| 123 | - $.each(arr, function (i, item) { | ||
| 124 | - if (transFun) | ||
| 125 | - item = transFun(item); | ||
| 126 | - rs += (separator + item); | ||
| 127 | - }); | ||
| 128 | - return rs.substr(separator.length); | ||
| 129 | - } | ||
| 130 | - | ||
| 131 | - var isArray = function (obj) { | ||
| 132 | - return Object.prototype.toString.call(obj) === '[object Array]'; | ||
| 133 | - }; | ||
| 134 | - | ||
| 135 | - var gb_form_validation_opts = { | ||
| 136 | - framework: 'uikit', | ||
| 137 | - locale: 'zh_CN', | ||
| 138 | - icon: { | ||
| 139 | - valid: 'uk-icon-check', | ||
| 140 | - invalid: 'uk-icon-times', | ||
| 141 | - validating: 'uk-icon-refresh' | ||
| 142 | - } | ||
| 143 | - }; | ||
| 144 | - | ||
| 145 | -</script> | ||
| 146 | - | ||
| 147 | -<!-- uikit core --> | ||
| 148 | -<script src="/real_control_v2/assets/plugins/uikit-2.27.1/uikit.min.js" merge="uikit_js"></script> | ||
| 149 | -<script src="/real_control_v2/assets/plugins/uikit-2.27.1/components/notify.min.js" merge="uikit_js"></script> | ||
| 150 | -<script src="/real_control_v2/assets/plugins/uikit-2.27.1/components/pagination.min.js" merge="uikit_js"></script> | ||
| 151 | -<script src="/real_control_v2/assets/plugins/uikit-2.27.1/components/tooltip.min.js" merge="uikit_js"></script> | ||
| 152 | -<script src="/real_control_v2/assets/plugins/uikit-2.27.1/components/sticky.min.js" merge="uikit_js"></script> | ||
| 153 | - | ||
| 154 | - | ||
| 155 | -<!-- jquery contextMenu --> | ||
| 156 | -<script src="/real_control_v2/assets/js/jquery.contextMenu.min.js" merge="plugins"></script> | ||
| 157 | -<script src="/real_control_v2/assets/js/jquery.ui.position.min.js" merge="plugins"></script> | ||
| 158 | -<!-- formvalidation- --> | ||
| 159 | -<script src="/real_control_v2/assets/plugins/formvalidation/formValidation.min.js" merge="plugins"></script> | ||
| 160 | -<script src="/real_control_v2/assets/plugins/formvalidation/zh_CN.js" merge="plugins"></script> | ||
| 161 | -<script src="/real_control_v2/assets/plugins/formvalidation/uikit.min.js" merge="plugins"></script> | ||
| 162 | -<!-- js tree --> | ||
| 163 | -<script src="/real_control_v2/assets/plugins/jstree/jstree.min.js" merge="plugins"></script> | ||
| 164 | -<!-- simple pinyin --> | ||
| 165 | -<script src="/assets/plugins/pinyin.js" merge="plugins"></script> | ||
| 166 | -<!-- qtip --> | ||
| 167 | -<script src="/real_control_v2/assets/plugins/qtip/jquery.qtip.min.js" merge="plugins"></script> | ||
| 168 | -<!-- layer 3.0.3 --> | ||
| 169 | -<script src="/real_control_v2/assets/plugins/layer3.0.3/layer.js" merge="plugins"></script> | ||
| 170 | - | ||
| 171 | -<!-- 数据 --> | ||
| 172 | -<script src="/real_control_v2/alone_page/home/alone_data_basic.js" merge="custom_js"></script> | ||
| 173 | -<script src="/real_control_v2/alone_page/home/alone_data_gps.js" merge="custom_js"></script> | ||
| 174 | -<script src="/real_control_v2/js/data/gps_abnormal.js" merge="custom_js"></script> | ||
| 175 | -<!-- 线路模拟图 --> | ||
| 176 | -<script src="/real_control_v2/js/utils/svg_chart.js" merge="custom_js"></script> | ||
| 177 | -<script src="/real_control_v2/js/utils/svg_data_convert.js" merge="custom_js"></script> | ||
| 178 | -<script src="/real_control_v2/js/utils/svg_chart_tooltip.js" merge="custom_js"></script> | ||
| 179 | -<script src="/real_control_v2/js/utils/svg_chart_map.js" merge="custom_js"></script> | ||
| 180 | - | ||
| 181 | -<!-- custom table js --> | ||
| 182 | -<script src="/real_control_v2/js/utils/ct_table.js" merge="custom_js"></script> | ||
| 183 | -<!-- home js --> | ||
| 184 | -<script src="/real_control_v2/js/home/layout.js" merge="custom_js"></script> | ||
| 185 | -<script src="/real_control_v2/js/home/line_panel.js" merge="custom_js"></script> | ||
| 186 | -<script src="/real_control_v2/js/home/context_menu.js" merge="custom_js"></script> | ||
| 187 | - | ||
| 188 | - | ||
| 189 | -<!-- 模态框扩展 --> | ||
| 190 | -<script src="/real_control_v2/js/modal_extend.js" merge="custom_js"></script> | ||
| 191 | - | ||
| 192 | -</body> | ||
| 193 | - | ||
| 194 | -</html> | 1 | +<!DOCTYPE html> |
| 2 | +<html lang="zh-cn"> | ||
| 3 | + | ||
| 4 | +<head> | ||
| 5 | + <meta charset="UTF-8"> | ||
| 6 | + <title>主页模拟图</title> | ||
| 7 | + <!-- uikit core style--> | ||
| 8 | + <link rel="stylesheet" href="/real_control_v2/assets/plugins/uikit-2.27.1/css/uikit.gradient.min.css" /> | ||
| 9 | + <link rel="stylesheet" href="/real_control_v2/assets/plugins/uikit-2.27.1/components/notify.gradient.min.css" merge="plugins"/> | ||
| 10 | + <link rel="stylesheet" href="/real_control_v2/assets/plugins/uikit-2.27.1/components/tooltip.gradient.min.css" merge="plugins"/> | ||
| 11 | + <link rel="stylesheet" | ||
| 12 | + href="/real_control_v2/assets/plugins/uikit-2.27.1/components/autocomplete.gradient.min.css" merge="plugins"/> | ||
| 13 | + <link rel="stylesheet" href="/real_control_v2/assets/plugins/uikit-2.27.1/components/sticky.gradient.min.css" merge="plugins"/> | ||
| 14 | + | ||
| 15 | + <!-- main style --> | ||
| 16 | + <link rel="stylesheet" href="/real_control_v2/css/main.css" /> | ||
| 17 | + <!-- home style --> | ||
| 18 | + <link rel="stylesheet" href="/real_control_v2/css/home.css" merge="custom_style"/> | ||
| 19 | + | ||
| 20 | + <!-- custom table --> | ||
| 21 | + <link rel="stylesheet" href="/real_control_v2/css/ct_table.css" merge="custom_style"/> | ||
| 22 | + <!-- jquery contextMenu style --> | ||
| 23 | + <link rel="stylesheet" href="/real_control_v2/assets/css/jquery.contextMenu.min.css" merge="plugins"/> | ||
| 24 | + <!-- formvalidation style --> | ||
| 25 | + <link rel="stylesheet" href="/real_control_v2/assets/plugins/formvalidation/formValidation.min.css" merge="plugins"/> | ||
| 26 | + <!-- js tree --> | ||
| 27 | + <link rel="stylesheet" href="/real_control_v2/assets/plugins/jstree/default/style.css" merge="plugins"/> | ||
| 28 | + <!-- tooltip css--> | ||
| 29 | + <link rel="stylesheet" href="/real_control_v2/assets/plugins/qtip/jquery.qtip.min.css" merge="plugins"/> | ||
| 30 | + <link rel="stylesheet" href="/real_control_v2/css/pace.css" merge="plugins"/> | ||
| 31 | + | ||
| 32 | + <link rel="stylesheet" href="/real_control_v2/css/modal_extend.css" merge="custom_style"/> | ||
| 33 | + <!-- perfect-scrollbar style --> | ||
| 34 | + <link rel="stylesheet" href="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.css" merge="plugins"/> | ||
| 35 | + <!-- layer 3.0.3 --> | ||
| 36 | + <link rel="stylesheet" href="/real_control_v2/assets/plugins/layer3.0.3/skin/default/layer.css" merge="plugins"/> | ||
| 37 | + <link rel="stylesheet" href="/real_control_v2/assets/plugins/layer3.0.3/skin/moon/style.css" merge="plugins"/> | ||
| 38 | + | ||
| 39 | + | ||
| 40 | + <style> | ||
| 41 | + .main-container{ | ||
| 42 | + height: 100% !important; | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + #main-tab-content{ | ||
| 46 | + padding: 0 !important; | ||
| 47 | + list-style: none; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + .home-panel{ | ||
| 51 | + | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + #home-main-content{ | ||
| 55 | + padding: 0 !important; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + #main-tab-content>.home-panel>#home-main-content{ | ||
| 59 | + overflow: inherit !important; | ||
| 60 | + } | ||
| 61 | + </style> | ||
| 62 | +</head> | ||
| 63 | + | ||
| 64 | +<body> | ||
| 65 | +<!--<div class="main-container" style="height: 100%;"> | ||
| 66 | +</div>--> | ||
| 67 | +<div class="main-container"> | ||
| 68 | + <ul id="main-tab-content"> | ||
| 69 | + <li class="home-panel"></li> | ||
| 70 | + </ul> | ||
| 71 | +</div> | ||
| 72 | + | ||
| 73 | + | ||
| 74 | +<!-- 地图相关 --> | ||
| 75 | +<script src="//api.map.baidu.com/api?v=2.0&ak=IGGrr4UjwIYzatoCRFKEL8sT"></script> | ||
| 76 | +<script src="//api.map.baidu.com/library/TrafficControl/1.4/src/TrafficControl_min.js"></script> | ||
| 77 | +<script src="/assets/js/baidu//MarkerClusterer.js" merge="plugins"></script> | ||
| 78 | +<script src="/assets/js/TransGPS.js" merge="plugins"></script> | ||
| 79 | +<!-- jquery --> | ||
| 80 | +<script src="/real_control_v2/assets/js/jquery.min.js"></script> | ||
| 81 | +<!-- jquery actual --> | ||
| 82 | +<script src="/real_control_v2/assets/js/jquery.actual.min.js" merge="plugins"></script> | ||
| 83 | +<!-- jquery.serializejson JSON序列化插件 --> | ||
| 84 | +<script src="/assets/plugins/jquery.serializejson.js" merge="plugins"></script> | ||
| 85 | +<!-- moment.js 日期处理类库 --> | ||
| 86 | +<script src="/real_control_v2/assets/plugins/moment/moment.min.js"></script> | ||
| 87 | +<script src="/real_control_v2/assets/plugins/moment/zh-cn.js"></script> | ||
| 88 | + | ||
| 89 | +<!-- flatpickr --> | ||
| 90 | +<script src="/real_control_v2/assets/plugins/flatpickr/flatpickr.min.js" merge="plugins"></script> | ||
| 91 | +<script src="/real_control_v2/assets/plugins/flatpickr/l10n/zh.js" merge="plugins"></script> | ||
| 92 | + | ||
| 93 | +<!-- perfect-scrollbar --> | ||
| 94 | +<script src="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.jquery.js" merge="plugins"></script> | ||
| 95 | +<!-- common js --> | ||
| 96 | +<script src="/real_control_v2/js/common.js"></script> | ||
| 97 | +<!-- art-template 模版引擎 --> | ||
| 98 | +<script src="/assets/plugins/template.js" merge="plugins"></script> | ||
| 99 | +<!-- d3 --> | ||
| 100 | +<script src="/assets/js/d3.min.js"></script> | ||
| 101 | +<!-- EventProxy --> | ||
| 102 | +<script src="/assets/js/eventproxy.js"></script> | ||
| 103 | +<!-- Geolib --> | ||
| 104 | +<script src="/real_control_v2/geolib/geolib.js" merge="plugins"></script> | ||
| 105 | + | ||
| 106 | +<script> | ||
| 107 | + | ||
| 108 | + | ||
| 109 | + var res_load_ep = EventProxy.create('load_home_layout', 'load_home_line_panel', 'load_data_basic', 'data-basic', function () { | ||
| 110 | + //加载主页 | ||
| 111 | + gb_home_layout.layout(function () { | ||
| 112 | + gb_home_line_panel.init(function () { | ||
| 113 | + //gps自刷新 | ||
| 114 | + gb_data_gps.fixedTimeRefresh(); | ||
| 115 | + | ||
| 116 | + $('.uk-icon-send-o.home_alone_page').remove(); | ||
| 117 | + }); | ||
| 118 | + }); | ||
| 119 | + }); | ||
| 120 | + | ||
| 121 | + function connectArr(arr, separator, transFun) { | ||
| 122 | + var rs = ''; | ||
| 123 | + $.each(arr, function (i, item) { | ||
| 124 | + if (transFun) | ||
| 125 | + item = transFun(item); | ||
| 126 | + rs += (separator + item); | ||
| 127 | + }); | ||
| 128 | + return rs.substr(separator.length); | ||
| 129 | + } | ||
| 130 | + | ||
| 131 | + var isArray = function (obj) { | ||
| 132 | + return Object.prototype.toString.call(obj) === '[object Array]'; | ||
| 133 | + }; | ||
| 134 | + | ||
| 135 | + var gb_form_validation_opts = { | ||
| 136 | + framework: 'uikit', | ||
| 137 | + locale: 'zh_CN', | ||
| 138 | + icon: { | ||
| 139 | + valid: 'uk-icon-check', | ||
| 140 | + invalid: 'uk-icon-times', | ||
| 141 | + validating: 'uk-icon-refresh' | ||
| 142 | + } | ||
| 143 | + }; | ||
| 144 | + | ||
| 145 | +</script> | ||
| 146 | + | ||
| 147 | +<!-- uikit core --> | ||
| 148 | +<script src="/real_control_v2/assets/plugins/uikit-2.27.1/uikit.min.js" merge="uikit_js"></script> | ||
| 149 | +<script src="/real_control_v2/assets/plugins/uikit-2.27.1/components/notify.min.js" merge="uikit_js"></script> | ||
| 150 | +<script src="/real_control_v2/assets/plugins/uikit-2.27.1/components/pagination.min.js" merge="uikit_js"></script> | ||
| 151 | +<script src="/real_control_v2/assets/plugins/uikit-2.27.1/components/tooltip.min.js" merge="uikit_js"></script> | ||
| 152 | +<script src="/real_control_v2/assets/plugins/uikit-2.27.1/components/sticky.min.js" merge="uikit_js"></script> | ||
| 153 | + | ||
| 154 | + | ||
| 155 | +<!-- jquery contextMenu --> | ||
| 156 | +<script src="/real_control_v2/assets/js/jquery.contextMenu.min.js" merge="plugins"></script> | ||
| 157 | +<script src="/real_control_v2/assets/js/jquery.ui.position.min.js" merge="plugins"></script> | ||
| 158 | +<!-- formvalidation- --> | ||
| 159 | +<script src="/real_control_v2/assets/plugins/formvalidation/formValidation.min.js" merge="plugins"></script> | ||
| 160 | +<script src="/real_control_v2/assets/plugins/formvalidation/zh_CN.js" merge="plugins"></script> | ||
| 161 | +<script src="/real_control_v2/assets/plugins/formvalidation/uikit.min.js" merge="plugins"></script> | ||
| 162 | +<!-- js tree --> | ||
| 163 | +<script src="/real_control_v2/assets/plugins/jstree/jstree.min.js" merge="plugins"></script> | ||
| 164 | +<!-- simple pinyin --> | ||
| 165 | +<script src="/assets/plugins/pinyin.js" merge="plugins"></script> | ||
| 166 | +<!-- qtip --> | ||
| 167 | +<script src="/real_control_v2/assets/plugins/qtip/jquery.qtip.min.js" merge="plugins"></script> | ||
| 168 | +<!-- layer 3.0.3 --> | ||
| 169 | +<script src="/real_control_v2/assets/plugins/layer3.0.3/layer.js" merge="plugins"></script> | ||
| 170 | + | ||
| 171 | +<!-- 数据 --> | ||
| 172 | +<script src="/real_control_v2/alone_page/home/alone_data_basic.js" merge="custom_js"></script> | ||
| 173 | +<script src="/real_control_v2/alone_page/home/alone_data_gps.js" merge="custom_js"></script> | ||
| 174 | +<script src="/real_control_v2/js/data/gps_abnormal.js" merge="custom_js"></script> | ||
| 175 | +<!-- 线路模拟图 --> | ||
| 176 | +<script src="/real_control_v2/js/utils/svg_chart.js" merge="custom_js"></script> | ||
| 177 | +<script src="/real_control_v2/js/utils/svg_data_convert.js" merge="custom_js"></script> | ||
| 178 | +<script src="/real_control_v2/js/utils/svg_chart_tooltip.js" merge="custom_js"></script> | ||
| 179 | +<script src="/real_control_v2/js/utils/svg_chart_map.js" merge="custom_js"></script> | ||
| 180 | + | ||
| 181 | +<!-- custom table js --> | ||
| 182 | +<script src="/real_control_v2/js/utils/ct_table.js" merge="custom_js"></script> | ||
| 183 | +<!-- home js --> | ||
| 184 | +<script src="/real_control_v2/js/home/layout.js" merge="custom_js"></script> | ||
| 185 | +<script src="/real_control_v2/js/home/line_panel.js" merge="custom_js"></script> | ||
| 186 | +<script src="/real_control_v2/js/home/context_menu.js" merge="custom_js"></script> | ||
| 187 | + | ||
| 188 | + | ||
| 189 | +<!-- 模态框扩展 --> | ||
| 190 | +<script src="/real_control_v2/js/modal_extend.js" merge="custom_js"></script> | ||
| 191 | + | ||
| 192 | +</body> | ||
| 193 | + | ||
| 194 | +</html> |
src/main/resources/static/real_control_v2/alone_page/map/alone_wrap.html
| 1 | -<!DOCTYPE html> | ||
| 2 | -<html lang="zh-cn"> | ||
| 3 | - | ||
| 4 | -<head> | ||
| 5 | - <meta charset="UTF-8"> | ||
| 6 | - <title>地图监控 v2.0</title> | ||
| 7 | - <!-- uikit core style--> | ||
| 8 | - <link rel="stylesheet" href="/real_control_v2/assets/plugins/uikit-2.27.1/css/uikit.gradient.min.css"/> | ||
| 9 | - <link rel="stylesheet" href="/real_control_v2/assets/plugins/uikit-2.27.1/components/notify.gradient.min.css" | ||
| 10 | - merge="plugins"/> | ||
| 11 | - <link rel="stylesheet" href="/real_control_v2/assets/plugins/uikit-2.27.1/components/tooltip.gradient.min.css" | ||
| 12 | - merge="plugins"/> | ||
| 13 | - <link rel="stylesheet" | ||
| 14 | - href="/real_control_v2/assets/plugins/uikit-2.27.1/components/autocomplete.gradient.min.css" merge="plugins"/> | ||
| 15 | - <link rel="stylesheet" href="/real_control_v2/assets/plugins/uikit-2.27.1/components/accordion.gradient.min.css" | ||
| 16 | - merge="plugins"/> | ||
| 17 | - <link rel="stylesheet" href="/real_control_v2/assets/plugins/uikit-2.27.1/components/slidenav.gradient.min.css" | ||
| 18 | - merge="plugins"/> | ||
| 19 | - <link rel="stylesheet" href="/real_control_v2/assets/plugins/uikit-2.27.1/components/sticky.gradient.min.css" | ||
| 20 | - merge="plugins"/> | ||
| 21 | - | ||
| 22 | - <!-- main style --> | ||
| 23 | - <link rel="stylesheet" href="/real_control_v2/css/main.css"/> | ||
| 24 | - <!-- north style --> | ||
| 25 | - <link rel="stylesheet" href="/real_control_v2/css/north.css" merge="custom_style"/> | ||
| 26 | - <!-- home style --> | ||
| 27 | - <link rel="stylesheet" href="/real_control_v2/css/home.css" merge="custom_style"/> | ||
| 28 | - | ||
| 29 | - <!-- js tree --> | ||
| 30 | - <link rel="stylesheet" href="/real_control_v2/assets/plugins/jstree/default/style.css" merge="plugins"/> | ||
| 31 | - | ||
| 32 | - <link rel="stylesheet" href="/real_control_v2/css/modal_extend.css" merge="custom_style"/> | ||
| 33 | - <!-- perfect-scrollbar style --> | ||
| 34 | - <link rel="stylesheet" href="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.css" | ||
| 35 | - merge="plugins"/> | ||
| 36 | - <!-- layer 3.0.3 --> | ||
| 37 | - <link rel="stylesheet" href="/real_control_v2/assets/plugins/layer3.0.3/skin/default/layer.css" merge="plugins"/> | ||
| 38 | - <link rel="stylesheet" href="/real_control_v2/assets/plugins/layer3.0.3/skin/moon/style.css" merge="plugins"/> | ||
| 39 | - | ||
| 40 | - <!-- flatpickr --> | ||
| 41 | - <link rel="stylesheet" href="/real_control_v2/assets/plugins/flatpickr/flatpickr.min.css" merge="plugins"/> | ||
| 42 | - <link rel="stylesheet" href="/real_control_v2/assets/plugins/flatpickr/themes/airbnb.css" merge="plugins"/> | ||
| 43 | - | ||
| 44 | - <link rel="stylesheet" href="/real_control_v2/css/ct_table.css" merge="custom_style"/> | ||
| 45 | - | ||
| 46 | - <style> | ||
| 47 | - .main-container .map-panel{ | ||
| 48 | - position: absolute; | ||
| 49 | - top:0; | ||
| 50 | - left: 0; | ||
| 51 | - width: 20px; | ||
| 52 | - z-index: 999; | ||
| 53 | - height: 20px; | ||
| 54 | - } | ||
| 55 | - </style> | ||
| 56 | -</head> | ||
| 57 | - | ||
| 58 | -<body> | ||
| 59 | -<div class="main-container" style="height: 100%;"> | ||
| 60 | - <span style="position: absolute;left: calc(50% - 35px);top: calc(45% - 35px);">加载中...</span> | ||
| 61 | -</div> | ||
| 62 | -<!-- 地图相关 --> | ||
| 63 | -<script src="http://api.map.baidu.com/api?v=2.0&ak=IGGrr4UjwIYzatoCRFKEL8sT"></script> | ||
| 64 | -<script src="http://api.map.baidu.com/library/TrafficControl/1.4/src/TrafficControl_min.js"></script> | ||
| 65 | -<script src="/assets/js/baidu//MarkerClusterer.js" merge="plugins"></script> | ||
| 66 | -<script src="/assets/js/TransGPS.js" merge="plugins"></script> | ||
| 67 | -<!-- 高德 --> | ||
| 68 | -<script src="http://webapi.amap.com/maps?v=1.3&key=16cb1c5043847e09ef9edafdd77befda"></script> | ||
| 69 | -<!-- jquery --> | ||
| 70 | -<script src="/real_control_v2/assets/js/jquery.min.js"></script> | ||
| 71 | -<!-- jquery actual --> | ||
| 72 | -<script src="/real_control_v2/assets/js/jquery.actual.min.js" merge="plugins"></script> | ||
| 73 | -<!-- moment.js 日期处理类库 --> | ||
| 74 | -<script src="/real_control_v2/assets/plugins/moment/moment.min.js"></script> | ||
| 75 | -<script src="/real_control_v2/assets/plugins/moment/zh-cn.js"></script> | ||
| 76 | - | ||
| 77 | -<!-- flatpickr --> | ||
| 78 | -<script src="/real_control_v2/assets/plugins/flatpickr/flatpickr.min.js" merge="plugins"></script> | ||
| 79 | -<script src="/real_control_v2/assets/plugins/flatpickr/l10n/zh.js" merge="plugins"></script> | ||
| 80 | - | ||
| 81 | -<!-- perfect-scrollbar --> | ||
| 82 | -<script src="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.jquery.js" merge="plugins"></script> | ||
| 83 | -<!-- common js --> | ||
| 84 | -<script src="/real_control_v2/js/common.js"></script> | ||
| 85 | -<!-- art-template 模版引擎 --> | ||
| 86 | -<script src="/assets/plugins/template.js" merge="plugins"></script> | ||
| 87 | -<!-- d3 --> | ||
| 88 | -<script src="/assets/js/d3.min.js"></script> | ||
| 89 | -<!-- EventProxy --> | ||
| 90 | -<script src="/assets/js/eventproxy.js"></script> | ||
| 91 | -<!-- uikit core --> | ||
| 92 | -<script src="/real_control_v2/assets/plugins/uikit-2.27.1/uikit.min.js" merge="uikit_js"></script> | ||
| 93 | -<script src="/real_control_v2/assets/plugins/uikit-2.27.1/components/notify.min.js" merge="uikit_js"></script> | ||
| 94 | -<script src="/real_control_v2/assets/plugins/uikit-2.27.1/components/tooltip.min.js" merge="uikit_js"></script> | ||
| 95 | -<script src="/real_control_v2/assets/plugins/uikit-2.27.1/components/autocomplete.min.js" merge="uikit_js"></script> | ||
| 96 | -<script src="/real_control_v2/assets/plugins/uikit-2.27.1/components/accordion.min.js" merge="uikit_js"></script> | ||
| 97 | -<script src="/real_control_v2/assets/plugins/uikit-2.27.1/components/sticky.min.js" merge="uikit_js"></script> | ||
| 98 | - | ||
| 99 | -<!-- js tree --> | ||
| 100 | -<script src="/real_control_v2/assets/plugins/jstree/jstree.min.js" merge="plugins"></script> | ||
| 101 | -<!-- layer 3.0.3 --> | ||
| 102 | -<script src="/real_control_v2/assets/plugins/layer3.0.3/layer.js" merge="plugins"></script> | ||
| 103 | - | ||
| 104 | -<!-- 模态框扩展 --> | ||
| 105 | -<script src="/real_control_v2/js/modal_extend.js" merge="custom_js"></script> | ||
| 106 | - | ||
| 107 | -<script src="/real_control_v2/alone_page/map/alone_data_basic.js" merge="custom_js"></script> | ||
| 108 | -<script src="/real_control_v2/alone_page/map/alone_data_gps.js" merge="custom_js"></script> | ||
| 109 | -<script src="/real_control_v2/js/utils/ct_table.js" merge="custom_js"></script> | ||
| 110 | -<!-- jquery.serializejson JSON序列化插件 --> | ||
| 111 | -<script src="/assets/plugins/jquery.serializejson.js" merge="uikit_js"></script> | ||
| 112 | - | ||
| 113 | -<script src="/assets/plugins/pinyin.js" merge="plugins"></script> | ||
| 114 | -</body> | ||
| 115 | -<script> | ||
| 116 | - gb_data_gps.fixedTimeRefresh(); | ||
| 117 | - var res_load_ep = EventProxy.create('data-basic', function () { | ||
| 118 | - | ||
| 119 | - //嵌入地图页面 | ||
| 120 | - $('.main-container').load('/real_control_v2/mapmonitor/real.html', function () { | ||
| 121 | - $('.map-system-msg.flex-left').remove(); | ||
| 122 | - | ||
| 123 | - $(this).append('<span class="map-panel"></span>');//判断里有JS判定这个容器是否显示 | ||
| 124 | - }); | ||
| 125 | - }); | ||
| 126 | - | ||
| 127 | - var isArray = function (obj) { | ||
| 128 | - return Object.prototype.toString.call(obj) === '[object Array]'; | ||
| 129 | - }; | ||
| 130 | -</script> | ||
| 131 | -</html> | 1 | +<!DOCTYPE html> |
| 2 | +<html lang="zh-cn"> | ||
| 3 | + | ||
| 4 | +<head> | ||
| 5 | + <meta charset="UTF-8"> | ||
| 6 | + <title>地图监控 v2.0</title> | ||
| 7 | + <!-- uikit core style--> | ||
| 8 | + <link rel="stylesheet" href="/real_control_v2/assets/plugins/uikit-2.27.1/css/uikit.gradient.min.css"/> | ||
| 9 | + <link rel="stylesheet" href="/real_control_v2/assets/plugins/uikit-2.27.1/components/notify.gradient.min.css" | ||
| 10 | + merge="plugins"/> | ||
| 11 | + <link rel="stylesheet" href="/real_control_v2/assets/plugins/uikit-2.27.1/components/tooltip.gradient.min.css" | ||
| 12 | + merge="plugins"/> | ||
| 13 | + <link rel="stylesheet" | ||
| 14 | + href="/real_control_v2/assets/plugins/uikit-2.27.1/components/autocomplete.gradient.min.css" merge="plugins"/> | ||
| 15 | + <link rel="stylesheet" href="/real_control_v2/assets/plugins/uikit-2.27.1/components/accordion.gradient.min.css" | ||
| 16 | + merge="plugins"/> | ||
| 17 | + <link rel="stylesheet" href="/real_control_v2/assets/plugins/uikit-2.27.1/components/slidenav.gradient.min.css" | ||
| 18 | + merge="plugins"/> | ||
| 19 | + <link rel="stylesheet" href="/real_control_v2/assets/plugins/uikit-2.27.1/components/sticky.gradient.min.css" | ||
| 20 | + merge="plugins"/> | ||
| 21 | + | ||
| 22 | + <!-- main style --> | ||
| 23 | + <link rel="stylesheet" href="/real_control_v2/css/main.css"/> | ||
| 24 | + <!-- north style --> | ||
| 25 | + <link rel="stylesheet" href="/real_control_v2/css/north.css" merge="custom_style"/> | ||
| 26 | + <!-- home style --> | ||
| 27 | + <link rel="stylesheet" href="/real_control_v2/css/home.css" merge="custom_style"/> | ||
| 28 | + | ||
| 29 | + <!-- js tree --> | ||
| 30 | + <link rel="stylesheet" href="/real_control_v2/assets/plugins/jstree/default/style.css" merge="plugins"/> | ||
| 31 | + | ||
| 32 | + <link rel="stylesheet" href="/real_control_v2/css/modal_extend.css" merge="custom_style"/> | ||
| 33 | + <!-- perfect-scrollbar style --> | ||
| 34 | + <link rel="stylesheet" href="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.css" | ||
| 35 | + merge="plugins"/> | ||
| 36 | + <!-- layer 3.0.3 --> | ||
| 37 | + <link rel="stylesheet" href="/real_control_v2/assets/plugins/layer3.0.3/skin/default/layer.css" merge="plugins"/> | ||
| 38 | + <link rel="stylesheet" href="/real_control_v2/assets/plugins/layer3.0.3/skin/moon/style.css" merge="plugins"/> | ||
| 39 | + | ||
| 40 | + <!-- flatpickr --> | ||
| 41 | + <link rel="stylesheet" href="/real_control_v2/assets/plugins/flatpickr/flatpickr.min.css" merge="plugins"/> | ||
| 42 | + <link rel="stylesheet" href="/real_control_v2/assets/plugins/flatpickr/themes/airbnb.css" merge="plugins"/> | ||
| 43 | + | ||
| 44 | + <link rel="stylesheet" href="/real_control_v2/css/ct_table.css" merge="custom_style"/> | ||
| 45 | + | ||
| 46 | + <style> | ||
| 47 | + .main-container .map-panel{ | ||
| 48 | + position: absolute; | ||
| 49 | + top:0; | ||
| 50 | + left: 0; | ||
| 51 | + width: 20px; | ||
| 52 | + z-index: 999; | ||
| 53 | + height: 20px; | ||
| 54 | + } | ||
| 55 | + </style> | ||
| 56 | +</head> | ||
| 57 | + | ||
| 58 | +<body> | ||
| 59 | +<div class="main-container" style="height: 100%;"> | ||
| 60 | + <span style="position: absolute;left: calc(50% - 35px);top: calc(45% - 35px);">加载中...</span> | ||
| 61 | +</div> | ||
| 62 | +<!-- 地图相关 --> | ||
| 63 | +<script src="//api.map.baidu.com/api?v=2.0&ak=IGGrr4UjwIYzatoCRFKEL8sT"></script> | ||
| 64 | +<script src="//api.map.baidu.com/library/TrafficControl/1.4/src/TrafficControl_min.js"></script> | ||
| 65 | +<script src="/assets/js/baidu//MarkerClusterer.js" merge="plugins"></script> | ||
| 66 | +<script src="/assets/js/TransGPS.js" merge="plugins"></script> | ||
| 67 | +<!-- 高德 --> | ||
| 68 | +<script src="//webapi.amap.com/maps?v=1.3&key=16cb1c5043847e09ef9edafdd77befda"></script> | ||
| 69 | +<!-- jquery --> | ||
| 70 | +<script src="/real_control_v2/assets/js/jquery.min.js"></script> | ||
| 71 | +<!-- jquery actual --> | ||
| 72 | +<script src="/real_control_v2/assets/js/jquery.actual.min.js" merge="plugins"></script> | ||
| 73 | +<!-- moment.js 日期处理类库 --> | ||
| 74 | +<script src="/real_control_v2/assets/plugins/moment/moment.min.js"></script> | ||
| 75 | +<script src="/real_control_v2/assets/plugins/moment/zh-cn.js"></script> | ||
| 76 | + | ||
| 77 | +<!-- flatpickr --> | ||
| 78 | +<script src="/real_control_v2/assets/plugins/flatpickr/flatpickr.min.js" merge="plugins"></script> | ||
| 79 | +<script src="/real_control_v2/assets/plugins/flatpickr/l10n/zh.js" merge="plugins"></script> | ||
| 80 | + | ||
| 81 | +<!-- perfect-scrollbar --> | ||
| 82 | +<script src="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.jquery.js" merge="plugins"></script> | ||
| 83 | +<!-- common js --> | ||
| 84 | +<script src="/real_control_v2/js/common.js"></script> | ||
| 85 | +<!-- art-template 模版引擎 --> | ||
| 86 | +<script src="/assets/plugins/template.js" merge="plugins"></script> | ||
| 87 | +<!-- d3 --> | ||
| 88 | +<script src="/assets/js/d3.min.js"></script> | ||
| 89 | +<!-- EventProxy --> | ||
| 90 | +<script src="/assets/js/eventproxy.js"></script> | ||
| 91 | +<!-- uikit core --> | ||
| 92 | +<script src="/real_control_v2/assets/plugins/uikit-2.27.1/uikit.min.js" merge="uikit_js"></script> | ||
| 93 | +<script src="/real_control_v2/assets/plugins/uikit-2.27.1/components/notify.min.js" merge="uikit_js"></script> | ||
| 94 | +<script src="/real_control_v2/assets/plugins/uikit-2.27.1/components/tooltip.min.js" merge="uikit_js"></script> | ||
| 95 | +<script src="/real_control_v2/assets/plugins/uikit-2.27.1/components/autocomplete.min.js" merge="uikit_js"></script> | ||
| 96 | +<script src="/real_control_v2/assets/plugins/uikit-2.27.1/components/accordion.min.js" merge="uikit_js"></script> | ||
| 97 | +<script src="/real_control_v2/assets/plugins/uikit-2.27.1/components/sticky.min.js" merge="uikit_js"></script> | ||
| 98 | + | ||
| 99 | +<!-- js tree --> | ||
| 100 | +<script src="/real_control_v2/assets/plugins/jstree/jstree.min.js" merge="plugins"></script> | ||
| 101 | +<!-- layer 3.0.3 --> | ||
| 102 | +<script src="/real_control_v2/assets/plugins/layer3.0.3/layer.js" merge="plugins"></script> | ||
| 103 | + | ||
| 104 | +<!-- 模态框扩展 --> | ||
| 105 | +<script src="/real_control_v2/js/modal_extend.js" merge="custom_js"></script> | ||
| 106 | + | ||
| 107 | +<script src="/real_control_v2/alone_page/map/alone_data_basic.js" merge="custom_js"></script> | ||
| 108 | +<script src="/real_control_v2/alone_page/map/alone_data_gps.js" merge="custom_js"></script> | ||
| 109 | +<script src="/real_control_v2/js/utils/ct_table.js" merge="custom_js"></script> | ||
| 110 | +<!-- jquery.serializejson JSON序列化插件 --> | ||
| 111 | +<script src="/assets/plugins/jquery.serializejson.js" merge="uikit_js"></script> | ||
| 112 | + | ||
| 113 | +<script src="/assets/plugins/pinyin.js" merge="plugins"></script> | ||
| 114 | +</body> | ||
| 115 | +<script> | ||
| 116 | + gb_data_gps.fixedTimeRefresh(); | ||
| 117 | + var res_load_ep = EventProxy.create('data-basic', function () { | ||
| 118 | + | ||
| 119 | + //嵌入地图页面 | ||
| 120 | + $('.main-container').load('/real_control_v2/mapmonitor/real.html', function () { | ||
| 121 | + $('.map-system-msg.flex-left').remove(); | ||
| 122 | + | ||
| 123 | + $(this).append('<span class="map-panel"></span>');//判断里有JS判定这个容器是否显示 | ||
| 124 | + }); | ||
| 125 | + }); | ||
| 126 | + | ||
| 127 | + var isArray = function (obj) { | ||
| 128 | + return Object.prototype.toString.call(obj) === '[object Array]'; | ||
| 129 | + }; | ||
| 130 | +</script> | ||
| 131 | +</html> |
src/main/resources/static/real_control_v2/main.html
| @@ -110,12 +110,12 @@ | @@ -110,12 +110,12 @@ | ||
| 110 | </script> | 110 | </script> |
| 111 | 111 | ||
| 112 | <!-- 地图相关 --> | 112 | <!-- 地图相关 --> |
| 113 | -<script src="http://api.map.baidu.com/api?v=2.0&ak=IGGrr4UjwIYzatoCRFKEL8sT"></script> | ||
| 114 | -<script src="http://api.map.baidu.com/library/TrafficControl/1.4/src/TrafficControl_min.js"></script> | 113 | +<script src="//api.map.baidu.com/api?v=2.0&ak=IGGrr4UjwIYzatoCRFKEL8sT"></script> |
| 114 | +<script src="//api.map.baidu.com/library/TrafficControl/1.4/src/TrafficControl_min.js"></script> | ||
| 115 | <script src="/assets/js/baidu//MarkerClusterer.js" merge="plugins"></script> | 115 | <script src="/assets/js/baidu//MarkerClusterer.js" merge="plugins"></script> |
| 116 | <script src="/assets/js/TransGPS.js" merge="plugins"></script> | 116 | <script src="/assets/js/TransGPS.js" merge="plugins"></script> |
| 117 | <!-- 高德 --> | 117 | <!-- 高德 --> |
| 118 | -<script src="http://webapi.amap.com/maps?v=1.3&key=16cb1c5043847e09ef9edafdd77befda"></script> | 118 | +<script src="//webapi.amap.com/maps?v=1.3&key=16cb1c5043847e09ef9edafdd77befda"></script> |
| 119 | <!-- jquery --> | 119 | <!-- jquery --> |
| 120 | <script src="/real_control_v2/assets/js/jquery.min.js"></script> | 120 | <script src="/real_control_v2/assets/js/jquery.min.js"></script> |
| 121 | <!-- jquery actual --> | 121 | <!-- jquery actual --> |
| @@ -236,7 +236,7 @@ | @@ -236,7 +236,7 @@ | ||
| 236 | </div> | 236 | </div> |
| 237 | </script> | 237 | </script> |
| 238 | <script id="cp_plat_msg_template" type="text/html"> | 238 | <script id="cp_plat_msg_template" type="text/html"> |
| 239 | - <div class="multi_plat_msg_pop uk-animation-slide-bottom" data-type="{{type}}" data-id="{{id}}" data-confirm="{{responseState}}" data-ts="{{ts}}"> | 239 | + <div class="multi_plat_msg_pop uk-animation-slide-bottom" data-type="{{type}}" data-id="{{id}}" data-title="{{responseState}}" data-ts="{{ts}}"> |
| 240 | <div> | 240 | <div> |
| 241 | <span class="title">应急预案</span> | 241 | <span class="title">应急预案</span> |
| 242 | <span class="text"> {{instructionsContent}}</span> | 242 | <span class="text"> {{instructionsContent}}</span> |
| @@ -244,9 +244,19 @@ | @@ -244,9 +244,19 @@ | ||
| 244 | </div> | 244 | </div> |
| 245 | </div> | 245 | </div> |
| 246 | </script> | 246 | </script> |
| 247 | +<script id="mt_plat_msg_template" type="text/html"> | ||
| 248 | + <div class="multi_plat_msg_pop uk-animation-slide-bottom" style="background-color: #0aae0a;" data-type="{{type}}" data-confirm="维修保养计划" data-line="{{line}}" data-zbh="{{zbh}}" data-bydj="{{bydj}}" data-bysj="{{dateTimeStr}}" data-bydd="{{bydd}}"> | ||
| 249 | + <div> | ||
| 250 | + <span class="title">维修保养计划</span> | ||
| 251 | + <span class="text"> {{zbh}} {{timeStr}} 进场保养</span> | ||
| 252 | + <span class="desc">--浦东公交维修库</span> | ||
| 253 | + </div> | ||
| 254 | + </div> | ||
| 255 | +</script> | ||
| 247 | 256 | ||
| 248 | <script src="/real_control_v2/js/safe_driv/safeDriv.js" merge="custom_js"></script> | 257 | <script src="/real_control_v2/js/safe_driv/safeDriv.js" merge="custom_js"></script> |
| 249 | <script src="/real_control_v2/js/con_plan/conPlan.js" merge="custom_js"></script> | 258 | <script src="/real_control_v2/js/con_plan/conPlan.js" merge="custom_js"></script> |
| 259 | +<script src="/real_control_v2/js/mt_plan/mtPlan.js" merge="custom_js"></script> | ||
| 250 | <!-- #### 安全驾驶 end ### --> | 260 | <!-- #### 安全驾驶 end ### --> |
| 251 | 261 | ||
| 252 | <!-- 打电话 --> | 262 | <!-- 打电话 --> |
| @@ -266,7 +276,7 @@ | @@ -266,7 +276,7 @@ | ||
| 266 | </div> | 276 | </div> |
| 267 | </div> | 277 | </div> |
| 268 | <div class="uk-form-row"> | 278 | <div class="uk-form-row"> |
| 269 | - <label class="uk-form-label" ">分机号:</label> | 279 | + <label class="uk-form-label">分机号:</label> |
| 270 | <div class="uk-form-controls"> | 280 | <div class="uk-form-controls"> |
| 271 | <input type="text" name="dn" value="" > | 281 | <input type="text" name="dn" value="" > |
| 272 | </div> | 282 | </div> |