maplibre-gl 3.0.1 → 3.2.0-pre.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/build/generate-doc-images.ts +73 -0
- package/build/generate-docs.ts +100 -0
- package/build/generate-shaders.ts +39 -6
- package/build/generate-struct-arrays.ts +9 -12
- package/build/readme.md +0 -5
- package/dist/maplibre-gl-csp-worker.js +1 -1
- package/dist/maplibre-gl-csp-worker.js.map +1 -1
- package/dist/maplibre-gl-csp.js +1 -1
- package/dist/maplibre-gl-csp.js.map +1 -1
- package/dist/maplibre-gl-dev.js +3368 -3420
- package/dist/maplibre-gl-dev.js.map +1 -1
- package/dist/maplibre-gl.d.ts +3861 -3489
- package/dist/maplibre-gl.js +4 -4
- package/dist/maplibre-gl.js.map +1 -1
- package/package.json +44 -40
- package/src/data/array_types.g.ts +14 -48
- package/src/data/bucket/circle_bucket.ts +11 -14
- package/src/data/bucket/fill_bucket.test.ts +6 -6
- package/src/data/bucket/fill_bucket.ts +10 -12
- package/src/data/bucket/fill_extrusion_bucket.ts +11 -13
- package/src/data/bucket/heatmap_bucket.ts +3 -6
- package/src/data/bucket/line_attributes.ts +1 -2
- package/src/data/bucket/line_attributes_ext.ts +1 -2
- package/src/data/bucket/line_bucket.test.ts +5 -5
- package/src/data/bucket/line_bucket.ts +18 -21
- package/src/data/bucket/pattern_attributes.ts +1 -3
- package/src/data/bucket/pattern_bucket_features.ts +3 -3
- package/src/data/bucket/symbol_bucket.test.ts +5 -5
- package/src/data/bucket/symbol_bucket.ts +12 -15
- package/src/data/bucket.ts +7 -11
- package/src/data/dem_data.test.ts +1 -1
- package/src/data/dem_data.ts +1 -1
- package/src/data/evaluation_feature.ts +4 -5
- package/src/data/extent.ts +1 -4
- package/src/data/feature_index.ts +14 -13
- package/src/data/feature_position_map.test.ts +4 -4
- package/src/data/feature_position_map.ts +1 -1
- package/src/data/index_array_type.ts +0 -1
- package/src/data/load_geometry.test.ts +1 -1
- package/src/data/load_geometry.ts +3 -4
- package/src/data/program_configuration.ts +6 -11
- package/src/data/segment.ts +9 -6
- package/src/geo/edge_insets.test.ts +1 -1
- package/src/geo/edge_insets.ts +34 -24
- package/src/geo/lng_lat.test.ts +1 -1
- package/src/geo/lng_lat.ts +60 -43
- package/src/geo/lng_lat_bounds.test.ts +2 -2
- package/src/geo/lng_lat_bounds.ts +88 -68
- package/src/geo/mercator_coordinate.test.ts +2 -2
- package/src/geo/mercator_coordinate.ts +33 -26
- package/src/geo/transform.test.ts +3 -3
- package/src/geo/transform.ts +58 -79
- package/src/gl/color_mode.ts +1 -3
- package/src/gl/context.ts +39 -21
- package/src/gl/cull_face_mode.ts +1 -3
- package/src/gl/depth_mode.ts +1 -3
- package/src/gl/framebuffer.ts +5 -4
- package/src/gl/index_buffer.ts +5 -4
- package/src/gl/render_pool.test.ts +2 -2
- package/src/gl/render_pool.ts +5 -5
- package/src/gl/state.test.ts +1 -1
- package/src/gl/stencil_mode.ts +1 -3
- package/src/gl/types.ts +14 -14
- package/src/gl/value.ts +12 -4
- package/src/gl/vertex_buffer.test.ts +2 -2
- package/src/gl/vertex_buffer.ts +10 -16
- package/src/gl/webgl2.ts +12 -0
- package/src/index.test.ts +2 -2
- package/src/index.ts +121 -113
- package/src/render/draw_background.ts +7 -9
- package/src/render/draw_circle.ts +13 -15
- package/src/render/draw_collision_debug.ts +11 -13
- package/src/render/draw_custom.ts +6 -8
- package/src/render/draw_debug.test.ts +4 -4
- package/src/render/draw_debug.ts +8 -10
- package/src/render/draw_fill.test.ts +13 -13
- package/src/render/draw_fill.ts +9 -11
- package/src/render/draw_fill_extrusion.ts +10 -12
- package/src/render/draw_heatmap.ts +13 -14
- package/src/render/draw_hillshade.ts +10 -12
- package/src/render/draw_line.ts +9 -9
- package/src/render/draw_raster.ts +9 -11
- package/src/render/draw_symbol.test.ts +16 -16
- package/src/render/draw_symbol.ts +15 -16
- package/src/render/draw_terrain.ts +11 -11
- package/src/render/glyph_atlas.ts +10 -1
- package/src/render/glyph_manager.test.ts +3 -3
- package/src/render/glyph_manager.ts +7 -7
- package/src/render/image_atlas.ts +6 -3
- package/src/render/image_manager.ts +3 -5
- package/src/render/line_atlas.test.ts +1 -1
- package/src/render/line_atlas.ts +19 -14
- package/src/render/painter.ts +86 -66
- package/src/render/program/background_program.ts +2 -2
- package/src/render/program/circle_program.ts +5 -5
- package/src/render/program/clipping_mask_program.ts +1 -1
- package/src/render/program/collision_program.ts +4 -4
- package/src/render/program/debug_program.ts +1 -1
- package/src/render/program/fill_extrusion_program.ts +3 -3
- package/src/render/program/fill_program.ts +3 -3
- package/src/render/program/heatmap_program.ts +5 -5
- package/src/render/program/hillshade_program.ts +7 -7
- package/src/render/program/line_program.ts +6 -6
- package/src/render/program/pattern.ts +3 -3
- package/src/render/program/raster_program.ts +2 -2
- package/src/render/program/symbol_program.ts +2 -2
- package/src/render/program/terrain_program.ts +1 -1
- package/src/render/program.ts +19 -20
- package/src/render/render_to_texture.test.ts +15 -15
- package/src/render/render_to_texture.ts +10 -10
- package/src/render/terrain.test.ts +38 -7
- package/src/render/terrain.ts +103 -67
- package/src/render/texture.ts +9 -8
- package/src/render/uniform_binding.test.ts +1 -1
- package/src/render/uniform_binding.ts +8 -2
- package/src/render/update_pattern_positions_in_program.ts +5 -5
- package/src/render/vertex_array_object.ts +9 -8
- package/src/shaders/README.md +2 -2
- package/src/shaders/_prelude.fragment.glsl.g.ts +1 -1
- package/src/shaders/_prelude.vertex.glsl.g.ts +1 -1
- package/src/shaders/background.fragment.glsl.g.ts +1 -1
- package/src/shaders/background.vertex.glsl.g.ts +1 -1
- package/src/shaders/background_pattern.fragment.glsl.g.ts +1 -1
- package/src/shaders/background_pattern.vertex.glsl.g.ts +1 -1
- package/src/shaders/circle.fragment.glsl.g.ts +1 -1
- package/src/shaders/circle.vertex.glsl.g.ts +1 -1
- package/src/shaders/clipping_mask.fragment.glsl.g.ts +1 -1
- package/src/shaders/clipping_mask.vertex.glsl.g.ts +1 -1
- package/src/shaders/collision_box.fragment.glsl.g.ts +1 -1
- package/src/shaders/collision_box.vertex.glsl.g.ts +1 -1
- package/src/shaders/collision_circle.fragment.glsl.g.ts +1 -1
- package/src/shaders/collision_circle.vertex.glsl.g.ts +1 -1
- package/src/shaders/debug.fragment.glsl.g.ts +1 -1
- package/src/shaders/debug.vertex.glsl.g.ts +1 -1
- package/src/shaders/encode_attribute.ts +0 -2
- package/src/shaders/fill.fragment.glsl.g.ts +1 -1
- package/src/shaders/fill.vertex.glsl.g.ts +1 -1
- package/src/shaders/fill_extrusion.fragment.glsl.g.ts +1 -1
- package/src/shaders/fill_extrusion.vertex.glsl.g.ts +1 -1
- package/src/shaders/fill_extrusion_pattern.fragment.glsl.g.ts +1 -1
- package/src/shaders/fill_extrusion_pattern.vertex.glsl.g.ts +1 -1
- package/src/shaders/fill_outline.fragment.glsl.g.ts +1 -1
- package/src/shaders/fill_outline.vertex.glsl.g.ts +1 -1
- package/src/shaders/fill_outline_pattern.fragment.glsl.g.ts +1 -1
- package/src/shaders/fill_outline_pattern.vertex.glsl.g.ts +1 -1
- package/src/shaders/fill_pattern.fragment.glsl.g.ts +1 -1
- package/src/shaders/fill_pattern.vertex.glsl.g.ts +1 -1
- package/src/shaders/heatmap.fragment.glsl.g.ts +1 -1
- package/src/shaders/heatmap.vertex.glsl.g.ts +1 -1
- package/src/shaders/heatmap_texture.fragment.glsl.g.ts +1 -1
- package/src/shaders/heatmap_texture.vertex.glsl.g.ts +1 -1
- package/src/shaders/hillshade.fragment.glsl.g.ts +1 -1
- package/src/shaders/hillshade.vertex.glsl.g.ts +1 -1
- package/src/shaders/hillshade_prepare.fragment.glsl.g.ts +1 -1
- package/src/shaders/hillshade_prepare.vertex.glsl.g.ts +1 -1
- package/src/shaders/line.fragment.glsl.g.ts +1 -1
- package/src/shaders/line.vertex.glsl.g.ts +1 -1
- package/src/shaders/line_gradient.fragment.glsl.g.ts +1 -1
- package/src/shaders/line_gradient.vertex.glsl.g.ts +1 -1
- package/src/shaders/line_pattern.fragment.glsl.g.ts +1 -1
- package/src/shaders/line_pattern.vertex.glsl.g.ts +1 -1
- package/src/shaders/line_sdf.fragment.glsl.g.ts +1 -1
- package/src/shaders/line_sdf.vertex.glsl.g.ts +1 -1
- package/src/shaders/raster.fragment.glsl.g.ts +1 -1
- package/src/shaders/raster.vertex.glsl.g.ts +1 -1
- package/src/shaders/shaders.ts +6 -8
- package/src/shaders/symbol_icon.fragment.glsl.g.ts +1 -1
- package/src/shaders/symbol_icon.vertex.glsl.g.ts +1 -1
- package/src/shaders/symbol_sdf.fragment.glsl.g.ts +1 -1
- package/src/shaders/symbol_sdf.vertex.glsl.g.ts +1 -1
- package/src/shaders/symbol_text_and_icon.fragment.glsl.g.ts +1 -1
- package/src/shaders/symbol_text_and_icon.vertex.glsl.g.ts +1 -1
- package/src/shaders/terrain.fragment.glsl.g.ts +1 -1
- package/src/shaders/terrain.vertex.glsl.g.ts +1 -1
- package/src/shaders/terrain_coords.fragment.glsl.g.ts +1 -1
- package/src/shaders/terrain_depth.fragment.glsl.g.ts +1 -1
- package/src/source/canvas_source.test.ts +6 -6
- package/src/source/canvas_source.ts +46 -60
- package/src/source/geojson_source.test.ts +5 -5
- package/src/source/geojson_source.ts +71 -55
- package/src/source/geojson_source_diff.ts +39 -2
- package/src/source/geojson_worker_source.test.ts +3 -3
- package/src/source/geojson_worker_source.ts +20 -26
- package/src/source/geojson_wrapper.test.ts +3 -3
- package/src/source/geojson_wrapper.ts +2 -4
- package/src/source/image_source.test.ts +9 -8
- package/src/source/image_source.ts +49 -35
- package/src/source/load_tilejson.ts +2 -2
- package/src/source/pixels_to_tile_units.ts +2 -3
- package/src/source/query_features.test.ts +3 -3
- package/src/source/query_features.ts +50 -19
- package/src/source/raster_dem_tile_source.test.ts +3 -3
- package/src/source/raster_dem_tile_source.ts +28 -14
- package/src/source/raster_dem_tile_worker_source.test.ts +2 -2
- package/src/source/raster_dem_tile_worker_source.ts +3 -5
- package/src/source/raster_tile_source.test.ts +3 -3
- package/src/source/raster_tile_source.ts +38 -11
- package/src/source/rtl_text_plugin.ts +4 -1
- package/src/source/source.ts +67 -59
- package/src/source/source_cache.test.ts +7 -7
- package/src/source/source_cache.ts +24 -40
- package/src/source/source_state.ts +2 -5
- package/src/source/terrain_source_cache.test.ts +8 -8
- package/src/source/terrain_source_cache.ts +42 -27
- package/src/source/tile.test.ts +3 -3
- package/src/source/tile.ts +32 -38
- package/src/source/tile_bounds.ts +2 -4
- package/src/source/tile_cache.test.ts +2 -2
- package/src/source/tile_cache.ts +20 -30
- package/src/source/tile_id.ts +11 -2
- package/src/source/vector_tile_source.test.ts +14 -14
- package/src/source/vector_tile_source.ts +32 -22
- package/src/source/vector_tile_worker_source.test.ts +4 -4
- package/src/source/vector_tile_worker_source.ts +12 -24
- package/src/source/video_source.test.ts +5 -5
- package/src/source/video_source.ts +20 -27
- package/src/source/worker.ts +6 -8
- package/src/source/worker_source.ts +6 -8
- package/src/source/worker_tile.test.ts +5 -5
- package/src/source/worker_tile.ts +13 -16
- package/src/style/create_style_layer.ts +31 -26
- package/src/style/evaluation_parameters.ts +5 -4
- package/src/style/format_section_override.test.ts +2 -2
- package/src/style/format_section_override.ts +1 -1
- package/src/style/light.test.ts +2 -2
- package/src/style/light.ts +3 -5
- package/src/style/load_glyph_range.test.ts +1 -1
- package/src/style/load_glyph_range.ts +3 -3
- package/src/style/load_sprite.test.ts +1 -1
- package/src/style/load_sprite.ts +3 -3
- package/src/style/parse_glyph_pbf.ts +1 -1
- package/src/style/pauseable_placement.ts +7 -9
- package/src/style/properties.ts +4 -53
- package/src/style/query_utils.ts +3 -3
- package/src/style/style.test.ts +22 -19
- package/src/style/style.ts +118 -84
- package/src/style/style_glyph.ts +6 -0
- package/src/style/style_image.ts +38 -32
- package/src/style/style_layer/background_style_layer.ts +2 -4
- package/src/style/style_layer/circle_style_layer.ts +7 -6
- package/src/style/style_layer/custom_style_layer.ts +26 -51
- package/src/style/style_layer/fill_extrusion_style_layer.ts +4 -6
- package/src/style/style_layer/fill_style_layer.ts +5 -7
- package/src/style/style_layer/heatmap_style_layer.ts +8 -7
- package/src/style/style_layer/hillshade_style_layer.ts +2 -4
- package/src/style/style_layer/line_style_layer.ts +6 -8
- package/src/style/style_layer/overlap_mode.test.ts +3 -3
- package/src/style/style_layer/overlap_mode.ts +3 -0
- package/src/style/style_layer/raster_style_layer.ts +2 -4
- package/src/style/style_layer/symbol_style_layer.ts +6 -8
- package/src/style/style_layer/typed_style_layer.ts +7 -7
- package/src/style/style_layer.test.ts +5 -5
- package/src/style/style_layer.ts +7 -6
- package/src/style/style_layer_index.test.ts +1 -1
- package/src/style/style_layer_index.ts +3 -5
- package/src/style/zoom_history.ts +1 -3
- package/src/symbol/anchor.test.ts +1 -1
- package/src/symbol/anchor.ts +1 -3
- package/src/symbol/check_max_angle.test.ts +8 -2
- package/src/symbol/check_max_angle.ts +10 -13
- package/src/symbol/clip_line.test.ts +1 -1
- package/src/symbol/clip_line.ts +6 -9
- package/src/symbol/collision_feature.test.ts +2 -2
- package/src/symbol/collision_feature.ts +7 -12
- package/src/symbol/collision_index.test.ts +2 -2
- package/src/symbol/collision_index.ts +5 -11
- package/src/symbol/cross_tile_symbol_index.test.ts +2 -2
- package/src/symbol/cross_tile_symbol_index.ts +5 -7
- package/src/symbol/get_anchors.ts +2 -2
- package/src/symbol/grid_index.test.ts +1 -1
- package/src/symbol/grid_index.ts +4 -5
- package/src/symbol/merge_lines.test.ts +1 -1
- package/src/symbol/merge_lines.ts +1 -1
- package/src/symbol/opacity_state.ts +1 -3
- package/src/symbol/path_interpolator.test.ts +1 -1
- package/src/symbol/path_interpolator.ts +1 -3
- package/src/symbol/placement.ts +9 -9
- package/src/symbol/projection.ts +61 -34
- package/src/symbol/quads.ts +7 -11
- package/src/symbol/shaping.ts +1 -1
- package/src/symbol/symbol_layout.ts +9 -12
- package/src/symbol/symbol_size.ts +1 -1
- package/src/symbol/symbol_style_layer.test.ts +4 -4
- package/src/symbol/transform_text.ts +2 -2
- package/src/types/callback.ts +14 -14
- package/src/types/cancelable.ts +3 -0
- package/src/types/transferable.ts +3 -0
- package/src/ui/anchor.ts +4 -0
- package/src/ui/camera.test.ts +6 -6
- package/src/ui/camera.ts +378 -347
- package/src/ui/control/attribution_control.test.ts +1 -1
- package/src/ui/control/attribution_control.ts +34 -30
- package/src/ui/control/control.ts +14 -20
- package/src/ui/control/fullscreen_control.test.ts +1 -1
- package/src/ui/control/fullscreen_control.ts +20 -25
- package/src/ui/control/geolocate_control.test.ts +5 -5
- package/src/ui/control/geolocate_control.ts +180 -193
- package/src/ui/control/logo_control.ts +20 -16
- package/src/ui/control/navigation_control.test.ts +1 -1
- package/src/ui/control/navigation_control.ts +44 -40
- package/src/ui/control/scale_control.test.ts +1 -1
- package/src/ui/control/scale_control.ts +30 -21
- package/src/ui/control/terrain_control.test.ts +1 -1
- package/src/ui/control/terrain_control.ts +15 -20
- package/src/ui/default_locale.ts +1 -3
- package/src/ui/events.ts +544 -1255
- package/src/ui/handler/box_zoom.test.ts +2 -2
- package/src/ui/handler/box_zoom.ts +16 -11
- package/src/ui/handler/click_zoom.ts +11 -3
- package/src/ui/handler/cooperative_gestures.test.ts +3 -3
- package/src/ui/handler/dblclick_zoom.test.ts +1 -1
- package/src/ui/handler/drag_handler.ts +30 -22
- package/src/ui/handler/drag_move_state_manager.ts +1 -1
- package/src/ui/handler/drag_pan.test.ts +2 -2
- package/src/ui/handler/drag_rotate.test.ts +3 -3
- package/src/ui/handler/keyboard.test.ts +2 -2
- package/src/ui/handler/keyboard.ts +22 -13
- package/src/ui/handler/map_event.test.ts +2 -2
- package/src/ui/handler/map_event.ts +1 -1
- package/src/ui/handler/mouse.ts +1 -1
- package/src/ui/handler/mouse_rotate.test.ts +3 -3
- package/src/ui/handler/scroll_zoom.test.ts +3 -3
- package/src/ui/handler/scroll_zoom.ts +45 -52
- package/src/ui/handler/shim/dblclick_zoom.ts +12 -6
- package/src/ui/handler/shim/drag_pan.ts +34 -14
- package/src/ui/handler/shim/drag_rotate.ts +20 -12
- package/src/ui/handler/shim/two_fingers_touch.ts +24 -18
- package/src/ui/handler/tap_drag_zoom.test.ts +113 -0
- package/src/ui/handler/tap_drag_zoom.ts +18 -10
- package/src/ui/handler/tap_recognizer.ts +1 -1
- package/src/ui/handler/tap_zoom.ts +4 -3
- package/src/ui/handler/touch_pan.ts +3 -2
- package/src/ui/handler/transform-provider.ts +4 -6
- package/src/ui/handler/two_fingers_touch.test.ts +3 -3
- package/src/ui/handler/two_fingers_touch.ts +64 -47
- package/src/ui/handler_inertia.ts +4 -4
- package/src/ui/handler_manager.ts +86 -52
- package/src/ui/hash.test.ts +1 -1
- package/src/ui/hash.ts +21 -28
- package/src/ui/map/isMoving.test.ts +3 -3
- package/src/ui/map/isRotating.test.ts +3 -3
- package/src/ui/map/isZooming.test.ts +3 -3
- package/src/ui/map.test.ts +107 -7
- package/src/ui/map.ts +831 -670
- package/src/ui/map_events.test.ts +1 -1
- package/src/ui/marker.test.ts +35 -15
- package/src/ui/marker.ts +214 -135
- package/src/ui/popup.test.ts +2 -2
- package/src/ui/popup.ts +167 -135
- package/src/util/actor.test.ts +7 -7
- package/src/util/actor.ts +25 -22
- package/src/util/ajax.ts +37 -17
- package/src/util/browser.test.ts +1 -1
- package/src/util/browser.ts +4 -8
- package/src/util/classify_rings.test.ts +1 -1
- package/src/util/classify_rings.ts +1 -1
- package/src/util/color_ramp.ts +0 -2
- package/src/util/config.ts +8 -3
- package/src/util/debug.ts +0 -2
- package/src/util/dictionary_coder.ts +1 -4
- package/src/util/dispatcher.test.ts +3 -3
- package/src/util/dispatcher.ts +4 -9
- package/src/util/dom.ts +1 -1
- package/src/util/evented.ts +23 -18
- package/src/util/find_pole_of_inaccessibility.test.ts +1 -1
- package/src/util/find_pole_of_inaccessibility.ts +4 -5
- package/src/util/global_worker_pool.ts +2 -3
- package/src/util/image.ts +10 -4
- package/src/util/image_request.test.ts +3 -3
- package/src/util/image_request.ts +15 -14
- package/src/util/is_char_in_unicode_block.ts +1 -3
- package/src/util/offscreen_canvas_supported.ts +1 -1
- package/src/util/performance.ts +1 -2
- package/src/util/request_manager.ts +4 -0
- package/src/util/resolve_tokens.test.ts +1 -1
- package/src/util/resolve_tokens.ts +3 -6
- package/src/util/script_detection.ts +1 -4
- package/src/util/smart_wrap.ts +3 -5
- package/src/util/struct_array.ts +18 -14
- package/src/util/style.ts +2 -2
- package/src/util/task_queue.test.ts +1 -1
- package/src/util/task_queue.ts +1 -3
- package/src/util/test/mock_webgl.ts +10 -1
- package/src/util/test/util.ts +2 -2
- package/src/util/throttle.test.ts +1 -1
- package/src/util/throttle.ts +1 -2
- package/src/util/throttled_invoker.ts +1 -5
- package/src/util/transferable_grid_index.test.ts +1 -1
- package/src/util/transferable_grid_index.ts +1 -3
- package/src/util/util.test.ts +1 -14
- package/src/util/util.ts +44 -107
- package/src/util/vectortile_to_geojson.ts +13 -3
- package/src/util/verticalize_punctuation.ts +1 -1
- package/src/util/web_worker.ts +2 -2
- package/src/util/web_worker_transfer.ts +11 -8
- package/src/util/webp_supported.ts +5 -7
- package/src/util/worker_pool.test.ts +1 -1
- package/src/util/worker_pool.ts +4 -5
package/README.md
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
# MapLibre GL JS
|
|
4
4
|
|
|
5
|
+
[](LICENSE.txt) [](https://www.npmjs.com/package/maplibre-gl) [](https://github.com/maplibre/maplibre-gl-js/actions/workflows/ci.yml) [](https://opensource.org/licenses/BSD-3-Clause) [](https://codecov.io/gh/maplibre/maplibre-gl-js)
|
|
6
|
+
|
|
5
7
|
**[MapLibre GL JS](https://maplibre.org/maplibre-gl-js-docs/api/)** is an open-source library for publishing maps on your websites or webview based apps. Fast displaying of maps is possible thanks to GPU-accelerated vector tile rendering.
|
|
6
8
|
|
|
7
9
|
It originated as an open-source fork of [mapbox-gl-js](https://github.com/mapbox/mapbox-gl-js), before their switch to a non-OSS license in December 2020. The library's initial versions (1.x) were intended to be a drop-in replacement for the Mapbox’s OSS version (1.x) with additional functionality, but have evolved a lot since then.
|
|
8
10
|
|
|
9
|
-
[](LICENSE.txt)[](https://www.npmjs.com/package/maplibre-gl)[](https://github.com/maplibre/maplibre-gl-js/actions/workflows/ci.yml)[](https://opensource.org/licenses/BSD-3-Clause)
|
|
10
|
-
|
|
11
11
|
## Getting Started
|
|
12
12
|
|
|
13
13
|
Include the JavaScript and CSS files in the `<head>` of your HTML file.
|
|
@@ -64,11 +64,11 @@ The overall migration happens by uninstalling `mapbox-gl` and installing `maplib
|
|
|
64
64
|
|
|
65
65
|
#### Compatibility branch
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
MapLibre GL JS v1 is completely backward compatible with Mapbox GL JS v1. This compatibility branch (named 1.x) is tagged v1 on npm, and its current version is 1.15.3.
|
|
68
68
|
|
|
69
69
|
#### CDN Links
|
|
70
70
|
|
|
71
|
-
> MapLibre GL JS is distributed via [unpkg.com](https://unpkg.com). For more information, please see [MapLibre GL is on unpkg.com](./documents_and_diagrams/README-unpkg.md#maplibre-gl-on-unpkgcom).
|
|
71
|
+
> MapLibre GL JS is distributed via [unpkg.com](https://unpkg.com). For more information, please see [MapLibre GL JS is on unpkg.com](./documents_and_diagrams/README-unpkg.md#maplibre-gl-on-unpkgcom).
|
|
72
72
|
|
|
73
73
|
```diff
|
|
74
74
|
- <script src="https://api.mapbox.com/mapbox-gl-js/v#.#.#/mapbox-gl.js"></script>
|
|
@@ -105,10 +105,10 @@ You can find the official status of the backing community and steering committee
|
|
|
105
105
|
|
|
106
106
|
### Avoid Fragmentation
|
|
107
107
|
|
|
108
|
-
If you depend on a free software alternative to `mapbox-gl-js`, please consider joining our effort! Anyone with a stake in a healthy community-led fork is welcome to help us figure out our next steps. We welcome contributors and leaders! MapLibre GL already represents the combined efforts of a few early fork efforts, and we all benefit from "one project" rather than "our way". If you know of other forks, please reach out to them and direct them here.
|
|
108
|
+
If you depend on a free software alternative to `mapbox-gl-js`, please consider joining our effort! Anyone with a stake in a healthy community-led fork is welcome to help us figure out our next steps. We welcome contributors and leaders! MapLibre GL JS already represents the combined efforts of a few early fork efforts, and we all benefit from "one project" rather than "our way". If you know of other forks, please reach out to them and direct them here.
|
|
109
109
|
|
|
110
110
|
|
|
111
|
-
> **MapLibre GL** is developed following [Semantic Versioning (2.0.0)](https://semver.org/spec/v2.0.0.html).
|
|
111
|
+
> **MapLibre GL JS** is developed following [Semantic Versioning (2.0.0)](https://semver.org/spec/v2.0.0.html).
|
|
112
112
|
|
|
113
113
|
### Bounties
|
|
114
114
|
|
|
@@ -187,4 +187,4 @@ Please keep in mind: Unauthorized backports are the biggest threat to the MapLib
|
|
|
187
187
|
|
|
188
188
|
## License
|
|
189
189
|
|
|
190
|
-
**MapLibre GL** is licensed under the [3-Clause BSD license](./LICENSE.txt).
|
|
190
|
+
**MapLibre GL JS** is licensed under the [3-Clause BSD license](./LICENSE.txt).
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import puppeteer from 'puppeteer';
|
|
4
|
+
import packageJson from '../package.json' assert { type: 'json' };
|
|
5
|
+
|
|
6
|
+
const exampleName = process.argv[2];
|
|
7
|
+
const examplePath = path.resolve('test', 'examples');
|
|
8
|
+
|
|
9
|
+
const browser = await puppeteer.launch({headless: exampleName === 'all'});
|
|
10
|
+
|
|
11
|
+
const page = await browser.newPage();
|
|
12
|
+
// set viewport and double deviceScaleFactor to get a closer shot of the map
|
|
13
|
+
await page.setViewport({
|
|
14
|
+
width: 600,
|
|
15
|
+
height: 250,
|
|
16
|
+
deviceScaleFactor: 2
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
async function createImage(exampleName) {
|
|
20
|
+
// get the example contents
|
|
21
|
+
const html = fs.readFileSync(path.resolve(examplePath, `${exampleName}.html`), 'utf-8');
|
|
22
|
+
|
|
23
|
+
await page.setContent(html.replaceAll('../../dist', `https://unpkg.com/maplibre-gl@${packageJson.version}/dist`));
|
|
24
|
+
|
|
25
|
+
// Wait for map to load, then wait two more seconds for images, etc. to load.
|
|
26
|
+
await page
|
|
27
|
+
.waitForFunction('map.loaded()')
|
|
28
|
+
.then(async () => {
|
|
29
|
+
// Wait for 5 seconds on 3d model examples, since this takes longer to load.
|
|
30
|
+
const waitTime = exampleName.includes('3d-model') ? 5000 : 1500;
|
|
31
|
+
await new Promise((resolve) => {
|
|
32
|
+
console.log(`waiting for ${waitTime} ms`);
|
|
33
|
+
setTimeout(resolve, waitTime);
|
|
34
|
+
});
|
|
35
|
+
})
|
|
36
|
+
// map.loaded() does not evaluate to true within 3 seconds, it's probably an animated example.
|
|
37
|
+
// In this case we take the screenshot immediately.
|
|
38
|
+
.catch(() => {
|
|
39
|
+
console.log(`Timed out waiting for map load on ${exampleName}.`);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
await page
|
|
43
|
+
.screenshot({
|
|
44
|
+
path: `./docs/assets/examples/${exampleName}.png`,
|
|
45
|
+
type: 'png',
|
|
46
|
+
clip: {
|
|
47
|
+
x: 0,
|
|
48
|
+
y: 0,
|
|
49
|
+
width: 600,
|
|
50
|
+
height: 250
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
.then(() => console.log(`Created ./docs/assets/examples/${exampleName}.png`))
|
|
54
|
+
.catch((err) => {
|
|
55
|
+
console.log(err);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (exampleName === 'all') {
|
|
60
|
+
const allFiles = fs.readdirSync(examplePath).filter(f => f.endsWith('html'));
|
|
61
|
+
console.log(`Generating ${allFiles.length} images.`);
|
|
62
|
+
for (const file of allFiles) {
|
|
63
|
+
await createImage(file);
|
|
64
|
+
}
|
|
65
|
+
} else if (exampleName) {
|
|
66
|
+
await createImage(exampleName);
|
|
67
|
+
} else {
|
|
68
|
+
throw new Error(
|
|
69
|
+
'\n Usage: npm run generate-images <file-name|all>\nExample: npm run generate-images 3d-buildings'
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
await browser.close();
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import typedocConfig from '../typedoc.json' assert {type: 'json'};
|
|
4
|
+
import packageJson from '../package.json' assert {type: 'json'};
|
|
5
|
+
|
|
6
|
+
type HtmlDoc = {
|
|
7
|
+
title: string;
|
|
8
|
+
description: string;
|
|
9
|
+
mdFileName: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function generateAPIIntroMarkdown(lines: string[]): string {
|
|
13
|
+
let intro = `# Intro
|
|
14
|
+
|
|
15
|
+
This file is intended as a reference for the important and public classes of this API.
|
|
16
|
+
We reccomend looking at the [expamples](../example/index.md) as they will help you the most to start with MapLibre.
|
|
17
|
+
|
|
18
|
+
Most of the classes wirtten here have an "Options" object for initialization, it is recommended to check which options exist.
|
|
19
|
+
|
|
20
|
+
`;
|
|
21
|
+
intro += lines.map(l => l.replace('../', './')).join('\n');
|
|
22
|
+
return intro;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function generateMarkdownForExample(title: string, description: string, file: string, htmlContent: string): string {
|
|
26
|
+
return `
|
|
27
|
+
# ${title}
|
|
28
|
+
|
|
29
|
+
${description}
|
|
30
|
+
|
|
31
|
+
<iframe src="../${file}" width="100%" style="border:none; height:400px"></iframe>
|
|
32
|
+
|
|
33
|
+
\`\`\`html
|
|
34
|
+
${htmlContent}
|
|
35
|
+
\`\`\`
|
|
36
|
+
`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function generateMarkdownIndexFileOfAllExamples(indexArray: HtmlDoc[]): string {
|
|
40
|
+
let indexMarkdown = '# Overview \n\n';
|
|
41
|
+
for (const indexArrayItem of indexArray) {
|
|
42
|
+
indexMarkdown += `
|
|
43
|
+
## [${indexArrayItem.title}](./${indexArrayItem.mdFileName})
|
|
44
|
+
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
${indexArrayItem.description}
|
|
48
|
+
`;
|
|
49
|
+
}
|
|
50
|
+
return indexMarkdown;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (!fs.existsSync(typedocConfig.out)) {
|
|
54
|
+
throw new Error('Please run typedoc generation first!');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
fs.rmSync(path.join(typedocConfig.out, 'README.md'));
|
|
58
|
+
fs.rmSync(path.join(typedocConfig.out, 'modules.md'));
|
|
59
|
+
// Intro file for the API
|
|
60
|
+
const modulesFolder = path.join(typedocConfig.out, 'modules');
|
|
61
|
+
const content = fs.readFileSync(path.join(modulesFolder, `${typedocConfig.internalModule}.md`), 'utf-8');
|
|
62
|
+
let lines = content.split('\n');
|
|
63
|
+
const classesLineIndex = lines.indexOf(lines.find(l => l.endsWith('Classes')) as string);
|
|
64
|
+
lines = lines.splice(2, classesLineIndex - 2);
|
|
65
|
+
const contentString = generateAPIIntroMarkdown(lines);
|
|
66
|
+
fs.writeFileSync(path.join(typedocConfig.out, 'README.md'), contentString);
|
|
67
|
+
|
|
68
|
+
// Examples manupilation
|
|
69
|
+
const examplesDocsFolder = path.join('docs', 'examples');
|
|
70
|
+
if (fs.existsSync(examplesDocsFolder)) {
|
|
71
|
+
fs.rmSync(examplesDocsFolder, {recursive: true, force: true});
|
|
72
|
+
}
|
|
73
|
+
fs.mkdirSync(examplesDocsFolder);
|
|
74
|
+
const examplesFolder = path.join('test', 'examples');
|
|
75
|
+
const files = fs.readdirSync(examplesFolder).filter(f => f.endsWith('html'));
|
|
76
|
+
const maplibreUnpgk = `https://unpkg.com/maplibre-gl@${packageJson.version}/`;
|
|
77
|
+
const indexArray = [] as HtmlDoc[];
|
|
78
|
+
for (const file of files) {
|
|
79
|
+
const htmlFile = path.join(examplesFolder, file);
|
|
80
|
+
let htmlContent = fs.readFileSync(htmlFile, 'utf-8');
|
|
81
|
+
htmlContent = htmlContent.replace(/\.\.\/\.\.\//g, maplibreUnpgk);
|
|
82
|
+
htmlContent = htmlContent.replace(/-dev.js/g, '.js');
|
|
83
|
+
const htmlContentLines = htmlContent.split('\n');
|
|
84
|
+
const title = htmlContentLines.find(l => l.includes('<title'))?.replace('<title>', '').replace('</title>', '').trim();
|
|
85
|
+
const description = htmlContentLines.find(l => l.includes('og:description'))?.replace(/.*content=\"(.*)\".*/, '$1');
|
|
86
|
+
fs.writeFileSync(path.join(examplesDocsFolder, file), htmlContent);
|
|
87
|
+
const mdFileName = file.replace('.html', '.md');
|
|
88
|
+
indexArray.push({
|
|
89
|
+
title: title!,
|
|
90
|
+
description: description!,
|
|
91
|
+
mdFileName
|
|
92
|
+
});
|
|
93
|
+
const exampleMarkdown = generateMarkdownForExample(title, description, file, htmlContent);
|
|
94
|
+
fs.writeFileSync(path.join(examplesDocsFolder, mdFileName), exampleMarkdown);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const indexMarkdown = generateMarkdownIndexFileOfAllExamples(indexArray);
|
|
98
|
+
fs.writeFileSync(path.join(examplesDocsFolder, 'index.md'), indexMarkdown);
|
|
99
|
+
|
|
100
|
+
console.log('Docs generation completed, to see it in action run\n docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material');
|
|
@@ -12,18 +12,51 @@ console.log('Generating shaders');
|
|
|
12
12
|
* It will also create a simple package.json file to allow importing this package in webpack
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
const
|
|
16
|
-
for (const file of
|
|
15
|
+
const vertex = globSync('./src/shaders/*.vertex.glsl');
|
|
16
|
+
for (const file of vertex) {
|
|
17
17
|
const code = fs.readFileSync(file, 'utf8');
|
|
18
|
-
const content = glslToTs(code);
|
|
18
|
+
const content = glslToTs(code, 'vertex');
|
|
19
19
|
const fileName = path.join('.', 'src', 'shaders', `${file.split(path.sep).splice(-1)}.g.ts`);
|
|
20
20
|
fs.writeFileSync(fileName, content);
|
|
21
21
|
}
|
|
22
|
-
console.log(`Finished converting ${files.length} glsl files`);
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
console.log(`Finished converting ${vertex.length} vertex shaders`);
|
|
24
|
+
|
|
25
|
+
const fragment = globSync('./src/shaders/*.fragment.glsl');
|
|
26
|
+
for (const file of fragment) {
|
|
27
|
+
const code = fs.readFileSync(file, 'utf8');
|
|
28
|
+
const content = glslToTs(code, 'fragment');
|
|
29
|
+
const fileName = path.join('.', 'src', 'shaders', `${file.split(path.sep).splice(-1)}.g.ts`);
|
|
30
|
+
fs.writeFileSync(fileName, content);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
console.log(`Finished converting ${fragment.length} fragment shaders`);
|
|
34
|
+
|
|
35
|
+
function glslToTs(code: string, type: 'fragment'|'vertex'): string {
|
|
36
|
+
code = code
|
|
37
|
+
.trim(); // strip whitespace at the start/end
|
|
38
|
+
|
|
39
|
+
// WebGL1 Compat -- Start
|
|
40
|
+
|
|
41
|
+
if (type === 'fragment') {
|
|
42
|
+
code = code
|
|
43
|
+
.replace(/\bin\s/g, 'varying ') // For fragment shaders, replace "in " with "varying "
|
|
44
|
+
.replace('out highp vec4 fragColor;', '');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (type === 'vertex') {
|
|
48
|
+
code = code
|
|
49
|
+
.replace(/\bin\s/g, 'attribute ') // For vertex shaders, replace "in " with "attribute "
|
|
50
|
+
.replace(/\bout\s/g, 'varying '); // For vertex shaders, replace "out " with "varying "
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
code = code
|
|
54
|
+
.replace(/fragColor/g, 'gl_FragColor')
|
|
55
|
+
.replace(/texture\(/g, 'texture2D(');
|
|
56
|
+
|
|
57
|
+
// WebGL1 Compat -- End
|
|
58
|
+
|
|
25
59
|
code = code
|
|
26
|
-
.trim() // strip whitespace at the start/end
|
|
27
60
|
.replace(/\s*\/\/[^\n]*\n/g, '\n') // strip double-slash comments
|
|
28
61
|
.replace(/\n+/g, '\n') // collapse multi line breaks
|
|
29
62
|
.replace(/\n\s+/g, '\n') // strip indentation
|
|
@@ -19,9 +19,9 @@ import rasterBoundsAttributes from '../src/data/raster_bounds_attributes';
|
|
|
19
19
|
import circleAttributes from '../src/data/bucket/circle_attributes';
|
|
20
20
|
import fillAttributes from '../src/data/bucket/fill_attributes';
|
|
21
21
|
import fillExtrusionAttributes from '../src/data/bucket/fill_extrusion_attributes';
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import patternAttributes from '../src/data/bucket/pattern_attributes';
|
|
22
|
+
import {lineLayoutAttributes} from '../src/data/bucket/line_attributes';
|
|
23
|
+
import {lineLayoutAttributesExt} from '../src/data/bucket/line_attributes_ext';
|
|
24
|
+
import {patternAttributes} from '../src/data/bucket/pattern_attributes';
|
|
25
25
|
// symbol layer specific arrays
|
|
26
26
|
import {
|
|
27
27
|
symbolLayoutAttributes,
|
|
@@ -144,8 +144,8 @@ const layoutAttributes = {
|
|
|
144
144
|
fill: fillAttributes,
|
|
145
145
|
'fill-extrusion': fillExtrusionAttributes,
|
|
146
146
|
heatmap: circleAttributes,
|
|
147
|
-
line:
|
|
148
|
-
lineExt:
|
|
147
|
+
line: lineLayoutAttributes,
|
|
148
|
+
lineExt: lineLayoutAttributesExt,
|
|
149
149
|
pattern: patternAttributes
|
|
150
150
|
};
|
|
151
151
|
for (const name in layoutAttributes) {
|
|
@@ -236,7 +236,6 @@ function emitStructArrayLayout(locals) {
|
|
|
236
236
|
|
|
237
237
|
output.push(
|
|
238
238
|
` *
|
|
239
|
-
* @private
|
|
240
239
|
*/
|
|
241
240
|
class ${structArrayLayoutClass} extends StructArray {`);
|
|
242
241
|
|
|
@@ -349,7 +348,8 @@ function emitStructArray(locals) {
|
|
|
349
348
|
|
|
350
349
|
if (includeStructAccessors && !useComponentGetters) {
|
|
351
350
|
output.push(
|
|
352
|
-
|
|
351
|
+
`/** */
|
|
352
|
+
class ${structTypeClass} extends Struct {
|
|
353
353
|
_structArray: ${structArrayClass};`);
|
|
354
354
|
|
|
355
355
|
for (const {name, member, component} of components) {
|
|
@@ -384,9 +384,7 @@ export type ${structTypeClass.replace('Struct', '')} = ${structTypeClass};
|
|
|
384
384
|
} // end 'if (includeStructAccessors)'
|
|
385
385
|
|
|
386
386
|
output.push(
|
|
387
|
-
`/**
|
|
388
|
-
* @private
|
|
389
|
-
*/
|
|
387
|
+
`/** */
|
|
390
388
|
export class ${structArrayClass} extends ${structArrayLayoutClass} {`);
|
|
391
389
|
|
|
392
390
|
if (useComponentGetters) {
|
|
@@ -407,8 +405,7 @@ export class ${structArrayClass} extends ${structArrayLayoutClass} {`);
|
|
|
407
405
|
output.push(
|
|
408
406
|
` /**
|
|
409
407
|
* Return the ${structTypeClass} at the given location in the array.
|
|
410
|
-
* @param
|
|
411
|
-
* @private
|
|
408
|
+
* @param index The index of the element.
|
|
412
409
|
*/
|
|
413
410
|
get(index: number): ${structTypeClass} {
|
|
414
411
|
return new ${structTypeClass}(this, index);
|
package/build/readme.md
CHANGED
|
@@ -29,9 +29,6 @@ Rollup is generating 3 files throughout the process of bundling:
|
|
|
29
29
|
|
|
30
30
|
These 3 files are then referenced and used by the `bundle_prelude.js` file. It allows loading the web wroker code automatically in web workers without any extra effort from someone who would like to use the library, i.e. it simply works.
|
|
31
31
|
|
|
32
|
-
### check-bundle-size.js
|
|
33
|
-
This file is used by CI to make sure the bundle size is kept constant
|
|
34
|
-
|
|
35
32
|
<hr>
|
|
36
33
|
|
|
37
34
|
### `npm run codegen`
|
|
@@ -43,8 +40,6 @@ Generates `data/array_types.ts`, which consists of:
|
|
|
43
40
|
- Specific named `StructArray` subclasses, when type-specific struct accessors are needed (e.g., `CollisionBoxArray`)
|
|
44
41
|
#### generate-style-code.ts
|
|
45
42
|
Generates the various `style/style_layer/[layer type]_style_layer_properties.ts` code files based on the content of `v8.json`. These files provide the type signatures for the paint and layout properties for each type of style layer.
|
|
46
|
-
#### generate-style-spec.ts
|
|
47
|
-
Generates `style-spec/types.ts` based on the content of `v8.json`. This provides the type signatures for a style specification (sources, layers, etc.).
|
|
48
43
|
<hr>
|
|
49
44
|
|
|
50
45
|
### Generate Release Nodes
|