openlayers渲染mapbox gl的vector tile
准备条件
https://openlayers.org/en/v4.6.5/build/ol.js
https://cdn.polyfill.io/v2/polyfill.min.js
DEMO
<!DOCTYPE html>
<html>
<head>
<title>Mapbox Vector Tiles</title>
<link rel="stylesheet"
href="https://openlayers.org/en/v4.6.5/css/ol.css" type="text/css">
<!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
<script
src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
<script src="https://openlayers.org/en/v4.6.5/build/ol.js"></script>
<script
src="https://openlayers.org/en/v4.6.5/examples/resources/mapbox-streets-v6-style.js"></script>
<style>
.map {
background: #f8f4f0;
}
</style>
</head>
<body>
<div id="map" class="map"></div>
<script>
var key = 'Your Mapbox access token from http://mapbox.com/ here'; var map = new ol.Map(
{
interactions : ol.interaction.defaults().extend(
[ new ol.interaction.DragRotateAndZoom() ]),
layers : [ new ol.layer.VectorTile(
{ declutter : true,
source : new ol.source.VectorTile(
{
attributions : '© <a href="https://www.mapbox.com/map-feedback/">Mapbox</a> '
+ '© <a href="https://www.openstreetmap.org/copyright">'
+ 'OpenStreetMap contributors</a>',
format : new ol.format.MVT(),
url : 'https://osm2vectortiles-0.tileserver.com/v2/{z}/{x}/{y}.pbf'
}),
style : createMapboxStreetsV6Style(
ol.style.Style, ol.style.Fill,
ol.style.Stroke, ol.style.Icon,
ol.style.Text)
}) ],
target : 'map',
view : new ol.View({
center : [ 0, 0 ],
zoom : 2
})
});
</script>
</body>
</html>
效果

注意点
openlayers渲染mapbox vector tile并不像leaflet整合mapbox-gl那样(采用的mapbox-gl渲染引擎),而是采用openlayers自己的引擎
openlayers渲染mapbox gl的vector tile的更多相关文章
- leaflet渲染mapbox gl的矢量数据
准备条件 1.mapbox-gl.js mapbox-gl.css 2.leaflet-mapbox-gl.js https://github.com/mapbox/mapbox-gl-leaflet ...
- mapbox.gl文字标注算法基本介绍
Well-placed labels can be the difference between a sloppy map and a beautiful one. Labels need to cl ...
- 使用GeoServer+OpenLayers发布和调用WMTS、Vector Tile矢量切片服务 | Publishing and Calling WMTS, Vector Tile Service Using GeoServer + OpenLayers
Web GIS系列: 1.搭建简易Web GIS网站:使用GeoServer+PostgreSQL+PostGIS+OpenLayers3 2.使用GeoServer+QGIS发布WMTS服务 3.使 ...
- mapbox.gl源码解析——基本架构与数据渲染流程
加载地图 Mapbox GL JS是一个JavaScript库,使用WebGL渲染交互式矢量瓦片地图和栅格瓦片地图.WebGL渲染意味着高性能,MapboxGL能够渲染大量的地图要素,拥有流畅的交互以 ...
- 矢量切片(Vector tile)
说明:本月的主要工作都是围绕制作矢量切片这一个核心问题进行的,所以2月的主题就以这个问题为主,目前分支出来的一些内容主要包括了TMS(Tile map service),OpenLayers3中的Pr ...
- 矢量切片(Vector tile)番外一:Proj4js
说明:番外篇是对正篇矢量切片(Vector tile)中提到的一些值得继续延伸的关注点继续进行探索和学习,所涉及的内容以解决实际问题为主要导向. 一.新的需求? 在完成了矢量切片的工作后,新的需求出现 ...
- 【GISER && Painter】矢量切片(Vector tile)
说明:本月的主要工作都是围绕制作矢量切片这一个核心问题进行的,所以2月的主题就以这个问题为主,目前分支出来的一些内容主要包括了TMS(Tile map service),OpenLayers3中的Pr ...
- 【GISER && Painter】矢量切片(Vector tile)番外一:Proj4js
说明:番外篇是对正篇矢量切片(Vector tile)中提到的一些值得继续延伸的关注点继续进行探索和学习,所涉及的内容以解决实际问题为主要导向. 一.新的需求? 在完成了矢量切片的工作后,新的需求出现 ...
- Vector Tile
Mapbox Vector Tile Specification A specification for encoding tiled vector data. <?XML:NAMESPACE ...
随机推荐
- (转载)SVM-基础(五)
作为支持向量机系列的基本篇的最后一篇文章,我在这里打算简单地介绍一下用于优化 dual 问题的 Sequential Minimal Optimization (SMO) 方法.确确实实只是简单介绍一 ...
- flask中jinjia2模板使用详解2
接上文 注释的使用 在jinjia2模板中,使用{# #}进行代码注释,如下所示 运行后发现,注释不会被render出来 去掉空行 两种方法可以去掉jinjia2模板中的空白行,一是设置jinjia2 ...
- Spring Boot 整合 Mybatis Annotation 注解的完整 Web 案例
摘要: 原创出处 www.bysocket.com 「泥瓦匠BYSocket 」欢迎转载,保留摘要,谢谢! 『 公司需要人.产品.业务和方向,方向又要人.产品.业务和方向,方向… 循环』 本文提纲一. ...
- C语言老司机学Python (四)
字符串格式化: 可以使用类似c语言中sprintf函数的方法进行格式化,但是函数名称是print() 如:print('常量 PI 的值近似为:%5.3f.' % var_PI) 注意var_PI ...
- 前端js,后台python实现RSA非对称加密
先熟悉使用 在后台使用RSA实现秘钥生产,加密,解密; # -*- encoding:utf-8 -*- import base64 from Crypto import Random from Cr ...
- python更新数据库脚本两种方法
最近项目的两次版本迭代中,根据业务需求的变化,需要对数据库进行更新,两次分别使用了不同的方式进行更新. 第一种:使用python的MySQLdb模块利用原生的sql语句进行更新 import MySQ ...
- 最短路径问题(Floyd-Warshall模板)
#include<bits/stdc++.h> using namespace std; int n; int x,y; ][]; ][]; int m,s,t; int main() { ...
- datanode启动不起来的各种原因
一般在数据节点的log日志信息里能找到导致启动不起来的原因. 1.Namenode和Datanode的NamenodeID不一致 描述:一般在集群多次重新格式化HDFS之后,或者刚安装时会碰到.日志信 ...
- Tomcat启动过程源码解读
根据Tomcat源码来看一下Tomcat启动过程都做了什么 部分代码为主要流程代码,删去了try-catch以及一些校验逻辑,方便理解主流程 先来一张启动过程时序图,了解一下启动顺序 Tomcat启动 ...
- R语言︱ 数据库SQL-R连接与SQL语句执行(RODBC、sqldf包)
要学的东西太多,无笔记不能学~~ 欢迎关注公众号,一起分享学习笔记,记录每一颗"贝壳"~ --------------------------- 数据库是极其重要的R语言数据导入源 ...