Fix mapbox-gl maps
This commit is contained in:
parent
24e7b2fec4
commit
c339f7d275
4 changed files with 20 additions and 19 deletions
|
@ -356,15 +356,18 @@ class NotesController extends Controller
|
||||||
$icon = $icon ?? 'marker';
|
$icon = $icon ?? 'marker';
|
||||||
|
|
||||||
return '{
|
return '{
|
||||||
"type": "Feature",
|
"type": "FeatureCollection",
|
||||||
"geometry": {
|
"features": [{
|
||||||
"type": "Point",
|
"type": "Feature",
|
||||||
"coordinates": [' . $longitude . ', ' . $latitude . ']
|
"geometry": {
|
||||||
},
|
"type": "Point",
|
||||||
"properties": {
|
"coordinates": [' . $longitude . ', ' . $latitude . ']
|
||||||
"title": "' . $title . '",
|
},
|
||||||
"icon": "' . $icon . '"
|
"properties": {
|
||||||
}
|
"title": "' . $title . '",
|
||||||
|
"icon": "' . $icon . '"
|
||||||
|
}
|
||||||
|
}]
|
||||||
}';
|
}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
13
resources/assets/es6/mapbox-utils.js
vendored
13
resources/assets/es6/mapbox-utils.js
vendored
|
@ -41,8 +41,7 @@ const makeMapMenu = (map) => {
|
||||||
export default function addMap(div, position = null, places = null) {
|
export default function addMap(div, position = null, places = null) {
|
||||||
let dataLatitude = div.dataset.latitude;
|
let dataLatitude = div.dataset.latitude;
|
||||||
let dataLongitude = div.dataset.longitude;
|
let dataLongitude = div.dataset.longitude;
|
||||||
let dataId = div.dataset.id;
|
let data = window['geojson'+div.dataset.id];
|
||||||
let data = window['geojson'+dataId];
|
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
data = {
|
data = {
|
||||||
'type': 'FeatureCollection',
|
'type': 'FeatureCollection',
|
||||||
|
@ -94,15 +93,13 @@ export default function addMap(div, position = null, places = null) {
|
||||||
map.addControl(new mapboxgl.NavigationControl());
|
map.addControl(new mapboxgl.NavigationControl());
|
||||||
div.appendChild(makeMapMenu(map));
|
div.appendChild(makeMapMenu(map));
|
||||||
map.on('load', function () {
|
map.on('load', function () {
|
||||||
map.addSource('points', {
|
|
||||||
'type': 'geojson',
|
|
||||||
'data': data
|
|
||||||
});
|
|
||||||
map.addLayer({
|
map.addLayer({
|
||||||
'id': 'points',
|
'id': 'points',
|
||||||
'interactive': true,
|
|
||||||
'type': 'symbol',
|
'type': 'symbol',
|
||||||
'source': 'points',
|
'source': {
|
||||||
|
'type': 'geojson',
|
||||||
|
'data': data
|
||||||
|
},
|
||||||
'layout': {
|
'layout': {
|
||||||
'icon-image': '{icon}-15',
|
'icon-image': '{icon}-15',
|
||||||
'text-field': '{title}',
|
'text-field': '{title}',
|
||||||
|
|
4
resources/assets/es6/maps.js
vendored
4
resources/assets/es6/maps.js
vendored
|
@ -1,8 +1,8 @@
|
||||||
//maps.js
|
//maps.js
|
||||||
import addMapTo from './mapbox-utils';
|
import addMap from './mapbox-utils';
|
||||||
|
|
||||||
let mapDivs = document.querySelectorAll('.map');
|
let mapDivs = document.querySelectorAll('.map');
|
||||||
|
|
||||||
for (var div of mapDivs) {
|
for (var div of mapDivs) {
|
||||||
addMapTo(div);
|
addMap(div);
|
||||||
}
|
}
|
||||||
|
|
1
webpack.config.js
vendored
1
webpack.config.js
vendored
|
@ -15,6 +15,7 @@ const config = {
|
||||||
},
|
},
|
||||||
devtool: 'source-map',
|
devtool: 'source-map',
|
||||||
module: {
|
module: {
|
||||||
|
noParse: [/(mapbox-gl)\.js$/],
|
||||||
loaders: [
|
loaders: [
|
||||||
{
|
{
|
||||||
test: /\.js$/,
|
test: /\.js$/,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue