Coder Social home page Coder Social logo

maptalks.mapboxgl's Introduction

maptalks.mapboxgl

NPM Version

A plugin to add mapbox-gl-js as a layer for maptalks.js.

screenshot

Tips

This is just a temporary solution for vector tilelayer

The webgl context of maptalks and the webgl context of mapboxgl will not be shared

Please familiarize yourself with the above when you use the plugin, and it is recommended to use the webgl ecology library from maptalks maptalks-gl-layers

Examples

Install

  • Install with npm: npm install maptalks.mapboxgl.
  • Download from dist directory.
  • Use unpkg CDN: https://unpkg.com/maptalks.mapboxgl/dist/maptalks.mapboxgl.min.js

Usage

As a plugin, maptalks.mapboxgl must be loaded after maptalks.js and mapbox-gl.js in browsers.

<script type="text/javascript" src="https://unpkg.com/maptalks/dist/maptalks.min.js"></script>
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.36.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.36.0/mapbox-gl.css' rel='stylesheet' />
<script type="text/javascript" src="https://unpkg.com/maptalks.mapboxgl/dist/maptalks.mapboxgl.min.js"></script>
<script>
var mapboxglLayer = new maptalks.MapboxglLayer('tile',{
        glOptions : {
            'style' : 'mapbox://styles/mapbox/light-v9'
        }
    }).addTo(map);
</script>

Supported Browsers

IE 11, Chrome, Firefox, other modern and mobile browsers support WebGL.

API Reference

MapboxglLayer is a subclass of maptalks.Layer and inherits all the methods of its parent.

Constructor

new maptalks.MapboxglLayer(id, options)

getGlMap()

get mapbox-gl-js map instance used by the layer

Returns Map

toJSON()

export the layer's JSON.

var json = mapboxglLayer.toJSON();

Returns Object

Contributing

We welcome any kind of contributions including issue reportings, pull requests, documentation corrections, feature requests and any other helps.

Develop

The only source file is index.js.

It is written in ES6, transpiled by babel and tested with mocha and expect.js.

Scripts

  • Install dependencies
$ npm install
  • Watch source changes and generate runnable bundle repeatedly
$ gulp watch
  • Tests
$ npm test
  • Watch source changes and run tests repeatedly
$ gulp tdd
  • Package and generate minified bundles to dist directory
$ gulp minify
  • Lint
$ npm run lint

maptalks.mapboxgl's People

Contributors

1dent1ty avatar deyihu avatar fuzhenn avatar jakob-fuchs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

maptalks.mapboxgl's Issues

npm install maptalks.mapboxgl. 出错!

执行
npm install maptalks.mapboxgl.
出错

npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/maptalks.mapboxgl. - Not found
npm ERR! 404
npm ERR! 404 'maptalks.mapboxgl.@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

ES6 Import

I'm trying to import the MapboxGL plugin the following way:

  import * as MapTalks from 'maptalks/dist/maptalks';
  import 'maptalks/dist/maptalks.css';
  import { MapboxglLayer } from 'maptalks.mapboxgl';

Getting the following error message:

./node_modules/maptalks.mapboxgl/dist/maptalks.mapboxgl.es.js Module not found: Error: Can't resolve 'mapboxgl' in '/home/xxx/xxx/xxx/app/node_modules/maptalks.mapboxgl/dist'

Any ideas why that is not working?

Cannot click on mapbox control

I added a search control from mapbox, but couldn't click on it.

It's like mapbox layer is simply merged to canvas. But if you use tab to get to the search box, it still intractable.

Do you have any suggestion?
image

there is a problem on: http://maptalks.org/maptalks.mapboxgl/demo/

Uncaught TypeError: this._renderer.onAdd is not a function
at MapboxglLayer.o._initRenderer (maptalks.min.js:6)
at MapboxglLayer.o.load (maptalks.min.js:6)
at l._loadAllLayers (maptalks.min.js:6)
at l._Load (maptalks.min.js:6)
at new l (maptalks.min.js:6)
at (index):35

mapbox does not come up

thanks for your work

拖动过程中mapbox地图会滞后

在拖动过程中,mapbox 底图会明显滞后于maptalks图层。使用同样的方法集成3D高德和百度地图,也是一样的滞后感。原因可能是mapbox的jumpTo是异步的。
问题:有没有更好的方式集成3D底图,比如mapbox和高德地图?

vt矢量图层可以支持局部平面坐标系不

1、我使用vt图层目前只能支持加载坐标为经纬度的geojson,在某些情况下,我的geojson为局部坐标系,就无法使用,vt怎么支持局部平面坐标系
image

2、我数据库使用pg数据库,我想使用矢量切片技术加载,这个加载能通过指定spatialReference来区别是经纬度和局部平面坐标系吗
image

Correct way to update map style?

I'm trying to update the style of my base layer, these two methods work but they add a new layer instead of updating the existing one:

        map.setBaseLayer(new MapboxglLayer('map', {
          glOptions: {
            style: selectedStyleUrl,
          }
        }));
        const baseLayer = map.getBaseLayer();
        baseLayer.config({
          glOptions: {
            style: selectedStyleUrl,
          }
        });
        baseLayer.load();

So I always end up with a lot of layers, which is not desirable for performance reasons. Any ideas how I can fix that?

I can go into the DOM manually and remove the layer but that doesn't seem to be the best solution. baseLayer.remove() doesn't seem to fix this.

当使用MapboxglLayer读取mapbox的style作为地图时,在倾斜地图后,再旋转地图,已经绘制的线要素会发生无规律偏移

创建一个地图,style自行替换
var map = new maptalks.Map('map', {
center: [114, 31],
zoom: 10,
baseLayer: new maptalks.MapboxglLayer('tile', {
glOptions: {
'style': 'http://ip/styles/style.json'
}
})
});
var layer = new maptalks.VectorLayer('vector', {forceRenderOnMoving: true}).addTo(map);

再加入一段线,线务必多于三个点

var start = [114, 31],
middle1 = [114, 31.05],
middle2 = [114.05, 31.05],
end = [114.05, 31.08];
var coords = [start, middle1, middle2, end]
var arrow = new maptalks.LineString(
coords,
{
'id': 'arrow',
'arrowStyle': 'classic',
'arrowPlacement': 'vertex-last'
}
) .addTo(layer);

然后倾斜地图45度角或其他倾斜角度,再旋转地图即可见效果
引入的相关库如下:

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/maptalks/dist/maptalks.min.js"></script> <script src='https://api.tiles.mapbox.com/mapbox-gl-js/v1.5.1/mapbox-gl.js'></script> <script type="text/javascript" src="https://unpkg.com/maptalks.mapboxgl/dist/maptalks.mapboxgl.min.js"></script>

地图实例设置cssFilter不起作用

使用MapboxglLayer,给地图实例设置cssFilter不起作用,如何设置
cssFilter baseLayer : new MapboxglLayer('mapboxgl',{
glOptions : {
'style' : 'mapbox://styles/mapbox/satellite-v9',
},
cssFilter: 'filter: invert(0) sepia(0) saturate(1.25) hue-rotate(0deg) brightness(1.15) contrast(1.35) grayscale(0.5)'
})

epsg:4326

设置4326投影地图调用mapboxgl图层会出现异常,另,还有没有别的方式调用矢量切片

Zooming glitches on Hi DPI displays

Zooming does not work properly on devices with DPI > 100%. It zooms in at the position where I scroll or pinch with 2 fingers, but after finishing the zoom interaction, the map snaps to another point. As this points is mostly about half the distance from the top and left, I guess that some mouse/finger coordinates are not multiplied with window.devicePixelRatio somewhere.

Error when using custom style

I tried making custom style with Mapbox Studio and published it. When I used it on mapbox.gl in itself, it works. But when I used it on this plugin, some errors occured.

This is how I instantiate the layer:
image

and this is the error on my console:
image

It result in a blank map.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.