Closed thunder-gzy closed 4 months ago
I just wrote a post about working with Martin
and Openlayers
and MBTiles
. And a demo Openlayers
code is here:
import "./style.css";
import { Map, View } from "ol";
import MVT from "ol/format/MVT.js";
import TileLayer from "ol/layer/Tile";
import OSM from "ol/source/OSM";
import VectorTileLayer from "ol/layer/VectorTile.js";
import VectorTileSource from "ol/source/VectorTile.js";
let my_layer = new VectorTileLayer({
source: new VectorTileSource({
format: new MVT(),
url: "http://localhost:3000/world_cities/{z}/{x}/{y}",
}),
});
const map = new Map({
target: "map",
layers: [
new TileLayer({
source: new OSM(),
}),
my_layer,
],
view: new View({
center: [0, 0],
zoom: 2,
}),
});
By accessing http://127.0.0.1:8243/catalog, you can get the table information in the postgresql database, but how to call these vector data in the front end? Is there a demo?