add: center item map

v0.5
rrr-marble 4 years ago
parent ae818080f1
commit f4bda7a837

@ -38,7 +38,8 @@
</div> </div>
<va-card id="map" class="content-container map-container"> <va-card id="map" class="content-container map-container">
<item-map-component v-if="detailsLoaded" :internal_id="this.itemDetails.internal_id" /> <item-map-component v-if="detailsLoaded" :internal_id="this.itemDetails.internal_id"
:x_coord="this.itemDetails.x_coord" :y_coord="this.itemDetails.y_coord" />
<h3 v-else>map is loading</h3> <h3 v-else>map is loading</h3>
</va-card> </va-card>
<va-card id="contact" class="content-container"> <va-card id="contact" class="content-container">

@ -15,6 +15,12 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
x_coord: {
required: true,
},
y_coord: {
required: true,
},
}, },
setup(props, _context) { setup(props, _context) {
const mapContainer = shallowRef(null); const mapContainer = shallowRef(null);
@ -23,8 +29,6 @@ export default {
onMounted(() => { onMounted(() => {
const apiKey = "pk.eyJ1IjoiZ2hlcm1hbnQiLCJhIjoiY2pncDUwcnRmNDQ4ZjJ4czdjZXMzaHZpNyJ9.3rFyYRRtvLUngHm027HZ7A"; const apiKey = "pk.eyJ1IjoiZ2hlcm1hbnQiLCJhIjoiY2pncDUwcnRmNDQ4ZjJ4czdjZXMzaHZpNyJ9.3rFyYRRtvLUngHm027HZ7A";
const initialState = { lng: 37.625, lat: 55.751, zoom: 5 };
map.value = markRaw(new maplibregl.Map({ map.value = markRaw(new maplibregl.Map({
container: mapContainer.value, // container id container: mapContainer.value, // container id
// DOCS: https://maplibre.org/maplibre-gl-js-docs/style-spec/ // DOCS: https://maplibre.org/maplibre-gl-js-docs/style-spec/
@ -33,33 +37,27 @@ export default {
sources: {}, sources: {},
layers: [] layers: []
}, },
center: [37.625, 55.751], // starting position [lng, lat] // we cut our map below, compensate for it while centering
center: [props.y_coord, props.x_coord - 25], // starting position [lng, lat]
zoom: 2, // starting zoom zoom: 2, // starting zoom
maxZoom: 10 maxZoom: 10
})); }));
map.value.on('load', () => { map.value.on('load', () => {
map.value.addSource('countries', { map.value.addSource('basemap-source', {
'type': 'vector', 'type': 'raster',
"tiles": [`https://api.mapbox.com/v4/ghermant.aq1p7k29/{z}/{x}/{y}.mvt?access_token=${apiKey}`] 'tiles': [`https://api.mapbox.com/styles/v1/ghermant/cl8vg2r97001m14o4c2qzw9t6/tiles/256/{z}/{x}/{y}@2x?access_token=${apiKey}`]
}); })
map.value.addLayer( map.value.addLayer(
{ {
'id': 'countries-layer', 'id': 'basemap-layer',
'type': 'line', 'type': 'raster',
'source': 'countries', 'source': 'basemap-source',
'source-layer': 'ne_110m_admin_0_countries-cz6wwp', 'paint': {}
'paint': {
"line-color": "blue",
"line-width": 3
},
'filter': ["==", ["get", "NAME"], "Russia"],
"maxzoom": 4
} }
); );
map.value.addSource('samples', { map.value.addSource('samples', {
'type': 'vector', 'type': 'vector',
"tiles": ["http://localhost:8080/martin/public.geodata/{z}/{x}/{y}.pbf"], "tiles": ["http://localhost:8080/martin/public.geodata/{z}/{x}/{y}.pbf"],
@ -74,7 +72,7 @@ export default {
'paint': { 'paint': {
'circle-stroke-width': 1, 'circle-stroke-width': 1,
'circle-stroke-color': '#FFFFFF', 'circle-stroke-color': '#FFFFFF',
'circle-color': 'yellow', 'circle-color': '#d95f0e',
'circle-opacity': 0.8, 'circle-opacity': 0.8,
'circle-radius': 16 'circle-radius': 16
}, },

Loading…
Cancel
Save