-
-
Notifications
You must be signed in to change notification settings - Fork 665
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
506 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset='utf-8' /> | ||
<title>Add a GeoJSON polygon</title> | ||
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' /> | ||
<script src='../dist/maplibre-gl-dev.js'></script> | ||
<link href='../dist/maplibre-gl.css' rel='stylesheet' /> | ||
<style> | ||
body { margin: 0; padding: 0; } | ||
#map { position: absolute; top: 0; bottom: 0; width: 100%; } | ||
</style> | ||
</head> | ||
<body> | ||
<div id='map'></div> | ||
<script> | ||
const delta = -7; | ||
var map = new maplibregl.Map({ | ||
container: 'map', | ||
// style: {version: 8, layers: [], sources: {}}, | ||
style: 'https://demotiles.maplibre.org/style.json', | ||
center: [-73 + delta, 34], | ||
zoom: 7 | ||
}); | ||
|
||
map.on('load', function () { | ||
map.addSource('shape1', | ||
{ | ||
'type': 'geojson', | ||
'data': { | ||
'features': [ | ||
{ | ||
'type': 'Feature', | ||
'properties': { | ||
'color': 'red', | ||
'height': 0, | ||
'base_height': 0 | ||
}, | ||
'geometry': { | ||
'type': 'MultiPolygon', | ||
'coordinates': [ | ||
[// first polygon | ||
[// first ring | ||
[-73 + delta, 35], [-69 + delta, 35], [-69 + delta, 34], [-73 + delta, 34], [-73. + delta, 35] | ||
] | ||
] | ||
] | ||
} | ||
}, | ||
{ | ||
'type': 'Feature', | ||
'properties': { | ||
'color': 'rgba(0,255,0,255)', | ||
'height': 0, | ||
'base_height': 0 | ||
}, | ||
'geometry': { | ||
'type': 'MultiPolygon', | ||
'coordinates': [ | ||
[// first polygon | ||
[// first ring | ||
[-74 + delta, 35], [-70 + delta, 35], [-70 + delta, 34], [-74 + delta, 34], [-74 + delta, 35] | ||
] | ||
] | ||
] | ||
} | ||
} | ||
], | ||
'type': 'FeatureCollection' | ||
} | ||
} | ||
); | ||
|
||
const paint2d = { | ||
// Get the fill-extrusion-color from the source 'color' property. | ||
// 'fill-color': 'red', | ||
'fill-color': ['get', 'color'], | ||
// Make extrusions slightly opaque for see through indoor walls. | ||
'fill-opacity': 0.5, | ||
'fill-per-layer-opacity': true, | ||
'fill-outline-color': 'rgba(255,0,0,1)' | ||
}; | ||
map.addLayer({ | ||
'id': 'shape1', | ||
'type': 'fill', | ||
'source': 'shape1', | ||
'paint': paint2d | ||
}); | ||
}); | ||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
uniform sampler2D u_image; | ||
uniform float u_opacity; | ||
varying vec2 v_pos; | ||
|
||
void main() { | ||
vec4 color = texture2D(u_image, v_pos); | ||
gl_FragColor = color * u_opacity; | ||
|
||
#ifdef OVERDRAW_INSPECTOR | ||
gl_FragColor = vec4(1.0); | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
uniform mat4 u_matrix; | ||
uniform vec2 u_world; | ||
attribute vec2 a_pos; | ||
varying vec2 v_pos; | ||
|
||
void main() { | ||
gl_Position = u_matrix * vec4(a_pos * u_world, 0, 1); | ||
|
||
v_pos.x = a_pos.x; | ||
v_pos.y = 1.0 - a_pos.y; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#pragma mapbox: define highp vec4 color | ||
#pragma mapbox: define lowp float opacity | ||
|
||
void main() { | ||
#pragma mapbox: initialize highp vec4 color | ||
#pragma mapbox: initialize lowp float opacity | ||
|
||
gl_FragColor = color; | ||
|
||
#ifdef OVERDRAW_INSPECTOR | ||
gl_FragColor = vec4(1.0); | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
attribute vec2 a_pos; | ||
|
||
uniform mat4 u_matrix; | ||
|
||
#pragma mapbox: define highp vec4 color | ||
#pragma mapbox: define lowp float opacity | ||
|
||
void main() { | ||
#pragma mapbox: initialize highp vec4 color | ||
#pragma mapbox: initialize lowp float opacity | ||
|
||
gl_Position = u_matrix * vec4(a_pos, 0, 1); | ||
} |
Oops, something went wrong.