[FAQ] 지도/로컬 API 문의 전 꼭 읽어 주세요.
GPS 데이터를 카카오맵 API에 보내면
1.해당 차량의 속도를 확인할 수 있다?
2.해당 차량이 도로기준속도를 준수/위반하고 있다?
에 대한 정보를 받을 수 있을까요?
또는 제공하는 API가 있을까요?
[FAQ] 지도/로컬 API 문의 전 꼭 읽어 주세요.
GPS 데이터를 카카오맵 API에 보내면
1.해당 차량의 속도를 확인할 수 있다?
2.해당 차량이 도로기준속도를 준수/위반하고 있다?
에 대한 정보를 받을 수 있을까요?
또는 제공하는 API가 있을까요?
Hello, @이찬우7794
Kakao Maps API does not currently provide direct GPS speed data and speed limit checks. However, here is a solution you can implement:
Note: these values are approximate and cannot provide 100% accurate information.
// Calculate speed between GPS coordinates
function calculateSpeed(prevPosition, currentPosition, timeElapsed) {
// Calculate distance between two points (in meters)
const distance = kakao.maps.geometry.getDistance(
new kakao.maps.LatLng(prevPosition.lat, prevPosition.lng),
new kakao.maps.LatLng(currentPosition.lat, currentPosition.lng)
);
// Calculate speed (km/h)
const speedKmh = (distance / timeElapsed) * 3.6;
return speedKmh;
}
class SpeedMonitor {
constructor() {
this.positions = [];
this.speedLimits = {
'highway': 100,
'urban': 50,
'residential': 30
};
}
addPosition(position, timestamp) {
if (this.positions.length > 0) {
const prevPosition = this.positions[this.positions.length - 1];
const timeElapsed = (timestamp - prevPosition.timestamp) / 1000; // second
const currentSpeed = calculateSpeed(
prevPosition,
position,
timeElapsed
);
// Check speed limit
return this.checkSpeedLimit(currentSpeed);
}
this.positions.push({...position, timestamp});
return null;
}
checkSpeedLimit(currentSpeed) {
// Determine speed limit according to road type
const speedLimit = this.speedLimits.urban; // Example: urban limit
return {
currentSpeed: currentSpeed,
speedLimit: speedLimit,
isViolating: currentSpeed > speedLimit
};
}
}
const speedMonitor = new SpeedMonitor();
// Get and check GPS data
navigator.geolocation.watchPosition((position) => {
const result = speedMonitor.addPosition({
lat: position.coords.latitude,
lng: position.coords.longitude
}, Date.now());
if (result) {
console.log(`Current Speed: ${result.currentSpeed} km/h`);
console.log(`Speed Limit: ${result.speedLimit} km/h`);
console.log(`Limit Violation: ${result.isViolating ? 'Yes' : 'No'}`);
}
});
You can filter GPS data for more accurate results
You can optimize time intervals for speed calculations
Note 2: This solution will provide approximate values. For more accurate results, professional speed measurement systems should be used.
도로 구간 속도 또한 제공하고 있지 않습니다.
별도로 데이터를 수급해주세요.
As lea.ju said, this data cannot be provided. You need to find a way to solve this. I will try to find a solution when I have time, but since it is a time-consuming process, I may not be able to respond to the issue immediately.