How to use the mapbox-gl.LngLat function in mapbox-gl

To help you get started, we’ve selected a few mapbox-gl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SuperMap / iClient-JavaScript / test / mapboxgl / overlay / GraphThemeLayerSpec.js View on Github external
it('addFeatures, removeFeatures, getShapesByFeatureID', () => {
        var graphThemeLayer;
        var features = [];
        for (var i = 0, len = chinaConsumptionLevel.length; i < len; i++) {
            // 省居民消费水平(单位:元)信息
            var provinceInfo = chinaConsumptionLevel[i];
            var geo = new mapboxgl.LngLat(provinceInfo[1], provinceInfo[2]);
            var attrs = {};
            attrs.NAME = provinceInfo[0];
            attrs.CON2009 = provinceInfo[3];
            attrs.CON2010 = provinceInfo[4];
            attrs.CON2011 = provinceInfo[5];
            attrs.CON2012 = provinceInfo[6];
            attrs.CON2013 = provinceInfo[7];
            var fea = new ThemeFeature(geo, attrs);
            features.push(fea);
        }
        graphThemeLayer = new Graph("GraphThemeLayer", "Bar",
            {
                map: map,
                attributions: " ",
                themeFields: ["CON2009", "CON2010", "CON2011", "CON2012", "CON2013"],
                opacity: 0.9,
github SuperMap / iClient-JavaScript / test / mapboxgl / services / GetFeaturesByBoundsSpec.js View on Github external
it('GetFeaturesByBoundsParameters:targetPrj', done => {
    var sw = new mapboxgl.LngLat(-20, -20);
    var ne = new mapboxgl.LngLat(20, 20);
    var lngLatBounds = new mapboxgl.LngLatBounds(sw, ne);
    var boundsParam = new GetFeaturesByBoundsParameters({
      datasetNames: ["World:Capitals"],
      bounds: lngLatBounds,
      targetPrj: { "epsgCode": 4326 }
    });
    var service = new FeatureService(url);

    spyOn(FetchRequest, 'commit').and.callFake((method, testUrl, params, options) => {
      var paramsObj = JSON.parse(params.replace(/'/g, '"'));
      expect(paramsObj.targetPrj.epsgCode).toEqual(4326);
      return Promise.resolve(new Response(JSON.stringify(getFeaturesResultJson)));
    });
    service.getFeaturesByBounds(boundsParam, (result) => {
      serviceResult = result;
      boundsParam.destroy();
github SuperMap / iClient-JavaScript / test / mapboxgl / mapping / WebMapSpec.js View on Github external
setTimeout(() => {

	        expect(datavizWebmap.credentialKey).toBeUndefined();
	        expect(datavizWebmap.credentialValue).toBeUndefined();

	        var map = datavizWebmap.map;
	        expect(map.getZoom()).toBe(8);
	        expect(map.getCenter()).toEqual(new mapboxgl.LngLat(116.46675928388001, 40.15816517545865));
	        expect(datavizWebmap.mapParams.title).toBe('RestMap');
	        expect(datavizWebmap.mapParams.description).toBe('');
	        done();
	    }, 1000)
	});
github plotly / plotly.js / src / plots / mapbox / mapbox.js View on Github external
proto.project = function(v) {
    return this.map.project(new mapboxgl.LngLat(v[0], v[1]));
};
github SuperMap / iClient-JavaScript / src / mapboxgl / overlay / HeatMapLayer.js View on Github external
getPixelXY(coordinate) {
        var pixelP, map = this.map;
        if (coordinate instanceof Point || coordinate instanceof GeoText) {
            let tempPoint = map.project(new mapboxgl.LngLat(coordinate.x, coordinate.y));
            pixelP = {x: parseInt(tempPoint.x), y: parseInt(tempPoint.y)};
        }
        if (coordinate instanceof LonLat) {
            let tempPoint = map.project(new mapboxgl.LngLat(coordinate.lon, coordinate.lat));
            pixelP = {x: parseInt(tempPoint.x), y: parseInt(tempPoint.y)};
        }
        return pixelP;
    }
github QwantResearch / erdapfel / src / mapbox / pin_point.js View on Github external
move(rawCenter, accuracy) {
    this.marker.setLngLat(new LngLat(rawCenter[0], rawCenter[1]))
    this.circle.update(rawCenter, accuracy, POLYCIRCLE_POINT_COUNT)
  }
github SuperMap / iClient-JavaScript / src / mapboxgl / overlay / HeatMapLayer.js View on Github external
getPixelXY(coordinate) {
        var pixelP, map = this.map;
        if (coordinate instanceof Point || coordinate instanceof GeoText) {
            let tempPoint = map.project(new mapboxgl.LngLat(coordinate.x, coordinate.y));
            pixelP = {x: parseInt(tempPoint.x), y: parseInt(tempPoint.y)};
        }
        if (coordinate instanceof LonLat) {
            let tempPoint = map.project(new mapboxgl.LngLat(coordinate.lon, coordinate.lat));
            pixelP = {x: parseInt(tempPoint.x), y: parseInt(tempPoint.y)};
        }
        return pixelP;
    }
github SuperMap / iClient-JavaScript / src / mapboxgl / overlay / mapv / MapvRenderer.js View on Github external
if (self.options.size) {
                self.options._size = self.options.size / zoomUnit;
            }
            if (self.options.width) {
                self.options._width = self.options.width / zoomUnit;
            }
            if (self.options.height) {
                self.options._height = self.options.height / zoomUnit;
            }
        } else {
            self.options._size = self.options.size;
            self.options._height = self.options.height;
            self.options._width = self.options.width;
        }

        var worldPoint = map.project(new mapboxgl.LngLat(0, 0));
        this.drawContext(context, data, self.options, worldPoint);

        self.options.updateCallback && self.options.updateCallback(time);
    }