קבלת מיקום GPS
פונקציה זו מאפשרת לקבל את המיקום הנוכחי של המשתמש במערכת הייחוס Web Mercator (EPSG:3857).
govmap.getGPSLocation();
דוגמה:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="https://www.govmap.gov.il/govmap/api/govmap.api.js" defer onload="initGovMap()"></script>
<script type="text/javascript">
function initGovMap() {
govmap.createMap('map', {
token: 'YOUR_API_TOKEN',
layers: ["GASSTATIONS"],
showXY: true,
identifyOnClick: true,
isEmbeddedToggle: false,
background: "1",
layersMode: 1,
zoomButtons:false
});
}
function showExample(){
govmap.getGPSLocation().then(response => console.log(response));
}
</script>
</head>
<body>
<div id="map" style="width:600px;height:600px;"></div>
<button onClick="showExample()">Show Example</button>
</body>
</html>
תשובה:
{
"timestamp": 1758654000000,
"coords": {
"accuracy": 10773.082609388584,
"latitude": 31.7767234,
"longitude": 35.2370834,
"altitude": null,
"altitudeAccuracy": null,
"heading": null,
"speed": null
}
}