Openlayers實(shí)現(xiàn)擴(kuò)散動(dòng)態(tài)點(diǎn)的方法是什么?這個(gè)問(wèn)題可能是我們?nèi)粘W(xué)習(xí)或工作經(jīng)常見(jiàn)到的。希望通過(guò)這個(gè)問(wèn)題能讓你收獲頗深。下面是小編給大家?guī)?lái)的參考內(nèi)容,讓我們一起來(lái)看看吧!
成都創(chuàng)新互聯(lián)成立十載來(lái),這條路我們正越走越好,積累了技術(shù)與客戶資源,形成了良好的口碑。為客戶提供成都網(wǎng)站建設(shè)、網(wǎng)站制作、網(wǎng)站策劃、網(wǎng)頁(yè)設(shè)計(jì)、域名注冊(cè)、網(wǎng)絡(luò)營(yíng)銷、VI設(shè)計(jì)、網(wǎng)站改版、漏洞修補(bǔ)等服務(wù)。網(wǎng)站是否美觀、功能強(qiáng)大、用戶體驗(yàn)好、性價(jià)比高、打開(kāi)快等等,這些對(duì)于網(wǎng)站建設(shè)都非常重要,成都創(chuàng)新互聯(lián)通過(guò)對(duì)建站技術(shù)性的掌握、對(duì)創(chuàng)意設(shè)計(jì)的研究為客戶提供一站式互聯(lián)網(wǎng)解決方案,攜手廣大客戶,共同發(fā)展進(jìn)步。在openlayers中制作危險(xiǎn)源標(biāo)識(shí)可以需要?jiǎng)討B(tài)擴(kuò)散的點(diǎn)(有很多種方法 可以加入jpg動(dòng)圖,也可以寫(xiě)css動(dòng)畫(huà)) 這里提供一種思路用openlayer自帶的方法寫(xiě) 并給予詳細(xì)的方法注釋供初學(xué)者學(xué)習(xí) (所有jar包都是在線的代碼可以復(fù)制過(guò)去直接用)
<!DOCTYPE html> <html> <head> <title>Icon Symbolizer</title> <link rel="stylesheet" href="https://openlayers.org/en/v3.20.1/css/ol.css" rel="external nofollow" type="text/css"> <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script> <script src="https://openlayers.org/en/v3.20.1/build/ol.js"></script> <script src="https://code.jquery.com/jquery-2.2.3.min.js"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="external nofollow" > <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <style> #map { position: relative; } #popup { cursor: pointer; } </style> </head> <body> <div id="map" class="map"></div> <div id="styleType"> </div> <script> //水紋擴(kuò)散 var bingMap = new ol.layer.Tile({ source :new ol.source.XYZ({ crossOrigin: 'anonymous', url:'http://www.google.cn/maps/vt?lyrs=m@189&gl=cn&x={x}&y={y}&z={z}' }) }); var map = new ol.Map({ layers: [bingMap], target: 'map', view: new ol.View({ center: ol.proj.transform([112.91, 28.21], 'EPSG:4326', 'EPSG:3857'), zoom: 5 }) }); var source = new ol.source.Vector({ wrapX: false }); var vector = new ol.layer.Vector({ source: source }); map.addLayer(vector); function addRandomFeature() { var geom = new ol.geom.Point(ol.proj.fromLonLat([112.91, 28.21])); var feature = new ol.Feature(geom); source.addFeature(feature); } var duration = 1000; function flash(feature) { var start = new Date().getTime(); //進(jìn)行地圖水波渲染 var listenerKey = map.on('postcompose', animate); function animate(event) { //獲取幾何圖形 var vectorContext = event.vectorContext; //獲取當(dāng)前渲染幀狀態(tài) var frameState = event.frameState; //添加一個(gè)OpenLayers.Geometry幾何對(duì)象 var flashGeom = feature.getGeometry().clone(); //渲染幀狀已占時(shí)間 var elapsed = frameState.time - start; //已占比率 var elapsedRatio = elapsed / duration; // radius半徑為5結(jié)束為30 var radius = ol.easing.easeOut(elapsedRatio) * 25 + 5; //不透漸變消失 var opacity = ol.easing.easeOut(1 - elapsedRatio); //Circle樣式 var style = new ol.style.Style({ image: new ol.style.Circle({ radius: radius, stroke: new ol.style.Stroke({ color: 'rgba(255, 0, 0, ' + opacity + ')', width: 1 + opacity }) }) }); //給幾何圖形添加樣式 vectorContext.setStyle(style); //將幾何體渲染到畫(huà)布中 vectorContext.drawGeometry(flashGeom); if (elapsed > duration) { start = frameState.time ; ; } //請(qǐng)求地圖渲染(在下一個(gè)動(dòng)畫(huà)幀處) map.render(); } } //數(shù)據(jù)源添加圖層 source.on('addfeature', function(e) { flash(e.feature); }); addRandomFeature() </script> </body> </html>
當(dāng)前標(biāo)題:Openlayers實(shí)現(xiàn)擴(kuò)散動(dòng)態(tài)點(diǎn)的方法是什么-創(chuàng)新互聯(lián)
轉(zhuǎn)載來(lái)源:http://bm7419.com/article22/dpcocc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站、網(wǎng)站設(shè)計(jì)、網(wǎng)站收錄、定制網(wǎng)站、企業(yè)網(wǎng)站制作、ChatGPT
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容