openlayers添加弹出框
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <link rel="stylesheet" href="lib/OpenLayers/ol.css" type="text/css">
- <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
- <script src="lib/OpenLayers/ol.js"></script>
- <script src="olStyle/Light.js"></script>
- <title>Document</title>
- <style>
- html,
- body {
- width: 100%;
- height: 100%;
- margin: 0;
- }
- .map {
- width: 100%;
- height: 100%;
- background: #f6f6f4;
- }
- input[type=range] {
- -webkit-appearance: none;
- width: 300px;
- border-radius: 10px;
- /*这个属性设置使填充进度条时的图形为圆角*/
- }
- input[type=range]::-webkit-slider-thumb {
- -webkit-appearance: none;
- }
- input[type=range]::-webkit-slider-runnable-track {
- height: 15px;
- border-radius: 10px;
- /*将轨道设为圆角的*/
- box-shadow: 0 1px 1px #65bdd3, inset 0 .125em .125em #127f9b;
- /*轨道内置阴影效果*/
- }
- input[type=range]:focus {
- outline: none;
- }
- input[type=range]::-webkit-slider-thumb {
- -webkit-appearance: none;
- height: 25px;
- width: 25px;
- margin-top: -5px;
- /*使滑块超出轨道部分的偏移量相等*/
- background: #08c1e6;
- border-radius: 50%;
- /*外观设置为圆形*/
- border: solid 0.125em rgba(49, 155, 187, 0.5);
- /*设置边框*/
- box-shadow: 0 .125em .125em #08c1e6;
- /*添加底部阴影*/
- }
- /**
- 下面是弹框样式
- */
- .ol-popup {
- position: absolute;
- background-color: white;
- -webkit-filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2));
- filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2));
- border-radius: 10px;
- border: 1px solid #cccccc;
- bottom: 12px;
- left: -50px;
- min-width: 280px;
- }
- .ol-popup:after,
- .ol-popup:before {
- top: 100%;
- border: solid transparent;
- content: " ";
- height: 0;
- width: 0;
- position: absolute;
- pointer-events: none;
- }
- .ol-popup:after {
- border-top-color: white;
- border-width: 10px;
- left: 48px;
- margin-left: -10px;
- }
- .ol-popup:before {
- border-top-color: #cccccc;
- border-width: 11px;
- left: 48px;
- margin-left: -11px;
- }
- .ol-popup-closer {
- text-decoration: none;
- position: absolute;
- top: 0px;
- right: 8px;
- }
- .ol-popup-closer:after {
- content: "✖";
- }
- .popup-top {
- background-color: #eeeeee;
- height: 30px;
- line-height: 30px;
- border-top-left-radius: 5px;
- border-top-right-radius: 5px;
- }
- .popup-title {
- padding-left: 10px;
- }
- .popup-content {
- padding: 10px;
- }
- .popup-content ul {
- list-style: none;
- padding: 0px;
- margin: 0px;
- font-size: 12px;
- }
- </style>
- </head>
- <body>
- <input type="button" id="tempstop" value="暂停" />
- <input type="button" id="start" value="开始" />
- <input type="button" id="stop" value="停止" />
- <input type="button" id="next" value="前进" />
- <input type="button" id="prev" value="后退" />
- <input type="range" id="sudu" value="800" max="2000" min="100" step="100" />
- <div id="map" class="map" data-id="11"></div>
- <div id="popup" class="ol-popup">
- <div class="popup-top">
- <span class="popup-title">当前坐标信息</span>
- <a href="#" id="popup-closer" class="ol-popup-closer"></a>
- </div>
- <div class="popup-content">
- <ul id="popup-content">
- </ul>
- </div>
- </div>
- </body>
- </html>
- <script type="text/javascript">
- var points = [
- [120.27194738388057, 36.3357839481728,new Date()]
- , [120.27194738388057, 36.33528166973691,new Date()]
- , [120.2717328071594, 36.33459124591144,new Date()]
- , [120.27145385742186, 36.333882530121315,new Date()]
- , [120.270938873291, 36.33315652189482,new Date()]
- , [120.27091741561887, 36.332741657013344,new Date()]
- , [120.2705955505371, 36.33213664176766,new Date()]
- , [120.27070283889768, 36.33139333089085,new Date()]
- , [120.27057409286496, 36.33087473770719,new Date()]
- , [120.27108907699584, 36.33006226811251,new Date()]
- , [120.27177572250363, 36.32987211443067,new Date()]
- , [120.27271986007688, 36.329664673521194,new Date()]
- , [120.27357816696164, 36.32918064258463,new Date()]
- , [120.27342796325681, 36.32826443293632,new Date()]
- , [120.27364253997803, 36.32753837235599,new Date()]
- , [120.27447938919066, 36.327088902892015,new Date()]
- , [120.2756381034851, 36.326795017609925,new Date()]
- , [120.27731180191037, 36.32632825635429,new Date()]
- , [120.27881383895873, 36.32601708063062,new Date()]
- , [120.28033733367917, 36.32572319130615,new Date()]
- , [120.28138875961302, 36.32570590366433,new Date()]
- , [120.2832770347595, 36.32555031471519,new Date()]
- , [120.28469324111937, 36.32555031471519,new Date()]
- , [120.28591632843013, 36.32548116397142,new Date()]
- , [120.2876543998718, 36.325412013166286,new Date()]
- , [120.2888774871826, 36.325412013166286,new Date()]
- , [120.29087305068967, 36.3253774377407,new Date()]
- , [120.29175281524657, 36.32485880451607,new Date()]
- , [120.29284715652466, 36.3245649108233,new Date()]
- ]
- var map;
- var container = document.getElementById('popup');
- var content = document.getElementById('popup-content');
- var closer = document.getElementById('popup-closer');
- var overlay = new ol.Overlay({
- element: container,
- autoPan: true,
- autoPanAnimation: {
- duration: 50
- }
- });
- closer.onclick = function () {
- overlay.setPosition(undefined);
- closer.blur();
- return false;
- };
- //轨迹
- var layer = new ol.layer.Vector({
- source: new ol.source.Vector(),
- style: new ol.style.Style({
- fill: new ol.style.Fill({
- color: 'rgba(255, 0, 0, 0.5)'
- }),
- stroke: new ol.style.Stroke({
- color: 'red',
- width: 2
- })
- })
- });
- //样式
- var style = new ol.style.Style({
- image: new ol.style.Circle({
- radius: 5,
- snapToPixel: false,
- fill: new ol.style.Fill({ color: 'rgba(30,144,255,1)' }),
- stroke: new ol.style.Stroke({
- color: 'rgb(30,144,255)', width: 2
- })
- })
- });
- //地图初始化
- function InitMap() {
- map = new ol.Map({
- layers: [new ol.layer.Vector({
- source: new ol.source.Vector(),
- style: function (feature, resolution) {
- switch (feature.get('layer')) {
- case 'poi':
- poiStyle.getText().setText(feature.get('name'));
- return poiStyle;
- case 'boundary': return boundaryStyle;
- case 'lawn': return lawnStyle;
- case 'road':
- roadStyle.getText().setText(feature.get('name'));
- return (resolution < 2) ? roadStyle : null;
- case 'building':
- return buildingStyle(feature, resolution);
- case 'other':
- otherStyle.getText().setText(feature.get('name'));
- return otherStyle;
- default: return null;
- }
- }
- }), layer],
- overlays: [overlay],
- target: 'map',
- view: new ol.View({
- center: ol.proj.fromLonLat([120.277, 36.330]),
- minZoom: 1,
- zoom: 16
- })
- });
- }
- var pointStyle = new ol.style.Style({
- //把点的样式换成ICON图标
- fill: new ol.style.Fill({
- //填充颜色
- color: 'rgba(37,241,239,0.2)'
- }),
- //图形样式,主要适用于点样式
- image: new ol.style.Circle({
- //半径大小
- radius: 5,
- //填充
- fill: new ol.style.Fill({
- //填充颜色
- color: 'rgba(255,0,0,0.3)'
- })
- })
- });
- /*显示并编辑区域**********************************************************************************/
- function AddPolygon() {
- layer.getSource().clear();
- for (var i = 0; i < points.length; i++) {
- if (i == 0) {
- AddPoint(style, points[i], i);
- } else {
- AddPoint(pointStyle, points[i], i);
- }
- }
- }
- function AddPoint(style, lnglat, id) {
- var newFeature = new ol.Feature({
- geometry: new ol.geom.Point(ol.proj.fromLonLat(lnglat))
- });
- //设置点的样式
- newFeature.setStyle(style);
- newFeature.setId("PlayPoints" + id)
- //将当前要素添加到矢量数据源中
- layer.getSource().addFeature(newFeature);
- }
- InitMap();
- map.on('click', function (evt) {
- // var coordinate = evt.coordinate;
- // var hdms = JSON.stringify(coordinate);
- var pixel = map.getEventPixel(evt.originalEvent);
- var feature = map.forEachFeatureAtPixel(pixel, function (feature) { return feature; });//查询方式有很多
- var html = ''
- if (feature) {
- var id = feature.getId();
- if (id == undefined) {
- return false;
- }
- id = id.replace('PlayPoints', '');
- html += "<li>上传时间:" + points[id][2] + "</li>"
- content.innerHTML = html;
- overlay.setPosition(ol.proj.fromLonLat(points[id]));
- }
- });
- layer.getSource().clear();
- AddPolygon();
- //动画
- var index = 0;
- var playInterval
- var trackPlay = {};
- trackPlay.start = function () {
- if (index == 0) {
- layer.getSource().clear();
- }
- var speed = 2000 / $("#sudu").val() * 50
- $("#sudu").attr("disabled", "disabled")
- playInterval = setInterval(() => {
- if (index == 0) {
- AddPoint(style, points[index], index);
- } else {
- AddPoint(pointStyle, points[index], index);
- }
- index = index + 1;
- if (index >= points.length) {
- trackPlay.stop();
- }
- }, speed)
- }
- trackPlay.stop = function () {
- index = 0;
- // if (trackPlay.stop) {
- clearInterval(playInterval);
- $("#sudu").removeAttr("disabled")
- // }
- }
- trackPlay.pause = function () {
- // if (trackPlay.stop) {
- clearInterval(playInterval);
- $("#sudu").removeAttr("disabled")
- // }
- }
- trackPlay.next = function () {
- if (index >= points.length) {
- return false;
- }
- AddPoint(pointStyle, points[index], index);
- index = index + 1;
- }
- trackPlay.prev = function () {
- if (index == 0) {
- return false;
- }
- index = index - 1;
- var feature = this.getLastFeature();
- layer.getSource().removeFeature(feature);
- }
- trackPlay.getLastFeature = function () {
- return layer.getSource().getFeatureById("PlayPoints" + index);
- }
- $("#tempstop").click(function () {
- trackPlay.pause();
- })
- $("#start").click(function () {
- trackPlay.start();
- })
- $("#stop").click(function () {
- trackPlay.stop();
- AddPolygon();
- })
- $("#next").click(function () {
- trackPlay.next();
- })
- $("#prev").click(function () {
- trackPlay.prev();
- })
- </script>
openlayers添加弹出框的更多相关文章
- JSP中添加弹出框
JSP中添加弹出框 %> <script language="javascript" type="text/javascript"> aler ...
- JavaScript插件——弹出框
(JavaScript插件——弹出框) 前言 阅读之前您也可以到Bootstrap3.0入门学习系列导航中进行查看http://www.cnblogs.com/aehyok/p/3404867.htm ...
- 弹出框,先弹出遮罩有透明度灰色100%高宽,置顶z-index:999---再弹出框最顶部z-index:9999
<div class="mask"></div> <div class="maskbox"> <form id=&qu ...
- Bootstrap-Plugin:弹出框(Popover)插件
ylbtech-Bootstrap-Plugin:弹出框(Popover)插件 1.返回顶部 1. Bootstrap 弹出框(Popover)插件 弹出框(Popover)与工具提示(Tooltip ...
- Django:popup弹出框简单应用实例
效果:在p1.html页面点击,弹出p2的弹出框,填写数据,在 popup_response页面处理数据 1.url设置 urlpatterns = patterns( url(r'^p1.html' ...
- 【iOS】UIAlertController 弹出框
UIAlertView 虽然还能用,但已经废弃了.因此以后尽量用 UIAlertController.示例代码如下: UIAlertController *alert = [UIAlertContro ...
- easyui tree datagrid动态添加表头和表格数据,动态弹出框,修改和删除按钮
1.要有获取表头的URL和表格的URL 背景:点击树的一个节点,就加载一个表格,这个表格是动态的,表头和表格数据都是动态的 解决方案:需要两个URL,一个是获取表头的URL,一个是获取表格数据的URL ...
- elementUI 弹出框添加可自定义拖拽和拉伸功能,并处理边界问题
开发完后台管理系统的弹出框模块,被添加拖拽和拉伸功能,看了很多网上成熟的帖子引到项目里总有一点问题,下面是根据自己的需求实现的步骤: 首先在vue项目中创建一个js文件eg:dialog.js imp ...
- Bootstrap方法为页面添加一个弹出框
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
随机推荐
- pytoch之 encoder,decoder
import torch import torch.nn as nn import torch.utils.data as Data import torchvision import matplot ...
- Webpack之(progressive web application) - PWA中的 Service Workers 是什么
学习文档:https://webpack.docschina.org/guides/progressive-web-application/ 参考文档:https://developers.googl ...
- IO流之File对象
File类: 用来将文件或者文件夹封装成对象 方便对文件与文件夹的属性等信息进行操作(因为流只能操作文件中的数据) File对象可以作为参考传递给流的构造函数 上下级文件夹之间使用分隔符分开: 在Wi ...
- Debian 10 安装无线网卡驱动 (rtl8822be)
apt install firmware-realtek
- bootstrap-daterangepicker
1,依赖关系 使用之前需要引用bootstrap.css daterangpicker.css jquery.js boostrap.js moment.js daterangpi ...
- UI自动化技术在高德的实践
一.背景汽车导航作为ToB业务,需要满足不同汽车厂商在功能和风格上体现各自特色的需求.针对这种情况,传统的UI开发方式,基本上是一对一的特别定制.但是这种方式动辄就要500~600人日的工作量投入,成 ...
- 2、CentOS7密码重置
一.重启系统,在开机过程中,快速按下键盘上的方向键↑和↓.目的是告知引导程序,我们需要在引导页面选择不同的操作,以便让引导程序暂停. 以下是暂停后的界面,可以查看下方的英文可知↑和↓的作用. 二. ...
- 在pycharm中如何设置代码对齐竖线
方法:启动pycharm软件,打开一个文件,点 file 菜单,选择 settings,在弹出的setting菜单中依次选择editor-->general-->appearance,然后 ...
- Openshift V3系列各组件版本
Openshift V3.* 系列各组件版本 Components 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.9 3.10 3.11 Core Components dock ...
- Android开发中按钮的语法
按钮的主要作用就是触发一个动作,所以会用到监听器. 如何为按钮添加单机事件监听器: 1.匿名内部类作为单机事件监听器 案例: 首先在.xml文件中添加一个按钮一,然后设置其id属性,然后在main里获 ...