polylines tooltip content
This commit is contained in:
@@ -1,5 +1,48 @@
|
||||
// pages/api/talas_v5_DB/pois/updateLocation.js
|
||||
import mysql from "mysql";
|
||||
import mysql from "mysql2/promise";
|
||||
|
||||
// Erstellen eines Pools von Datenbankverbindungen
|
||||
const pool = mysql.createPool({
|
||||
host: process.env.DB_HOST,
|
||||
user: process.env.DB_USER,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_NAME,
|
||||
port: process.env.DB_PORT,
|
||||
charset: "utf8mb4",
|
||||
waitForConnections: true,
|
||||
connectionLimit: 10,
|
||||
queueLimit: 0,
|
||||
});
|
||||
|
||||
export default async function handler(req, res) {
|
||||
if (req.method !== "POST") {
|
||||
res.setHeader("Allow", ["POST"]);
|
||||
return res.status(405).end(`Method ${req.method} Not Allowed`);
|
||||
}
|
||||
|
||||
const { id, latitude, longitude } = req.body;
|
||||
|
||||
if (!id || latitude === undefined || longitude === undefined) {
|
||||
return res.status(400).json({ error: "id, latitude, und longitude sind erforderlich" });
|
||||
}
|
||||
|
||||
const query = "UPDATE poi SET position = POINT(?, ?) WHERE idPoi = ?";
|
||||
|
||||
try {
|
||||
const [result] = await pool.query(query, [longitude, latitude, id]);
|
||||
|
||||
if (result.affectedRows > 0) {
|
||||
res.status(200).json({ success: true });
|
||||
} else {
|
||||
res.status(404).json({ error: "POI nicht gefunden" });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Fehler beim Aktualisieren der Position:", error);
|
||||
res.status(500).json({ error: "Ein Fehler ist aufgetreten" });
|
||||
}
|
||||
}
|
||||
|
||||
/* import mysql from "mysql";
|
||||
import util from "util";
|
||||
|
||||
const dbConfig = {
|
||||
@@ -36,4 +79,4 @@ export default async function handler(req, res) {
|
||||
} finally {
|
||||
connection.end();
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
Reference in New Issue
Block a user