{"id":16074,"date":"2025-06-24T14:25:07","date_gmt":"2025-06-24T12:25:07","guid":{"rendered":"https:\/\/www.whynotbirds.com\/?page_id=16074"},"modified":"2025-06-24T14:25:08","modified_gmt":"2025-06-24T12:25:08","slug":"gps-test","status":"publish","type":"page","link":"https:\/\/www.whynotbirds.com\/en\/gps-test\/","title":{"rendered":"gps test"},"content":{"rendered":"\n<!DOCTYPE html>\n<html lang=\"da\">\n<head>\n  <meta charset=\"UTF-8\" \/>\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" \/>\n  <title>Fugleobservation med GPS &#038; Leaflet (Debug)<\/title>\n\n  <link \n    rel=\"stylesheet\" \n    href=\"https:\/\/unpkg.com\/leaflet@1.9.4\/dist\/leaflet.css\" \n    crossorigin=\"\"\n  \/>\n  <style>\n    html, body {\n      height: 100%;\n      margin: 0; padding: 0;\n      font-family: Arial, sans-serif;\n      max-width: 480px;\n      margin-left: auto;\n      margin-right: auto;\n      padding: 1rem;\n    }\n    #map {\n      height: 300px;\n      width: 100%;\n      margin-top: 1rem;\n      border: 1px solid #ccc;\n      border-radius: 6px;\n    }\n  <\/style>\n<\/head>\n<body>\n\n<h1>Fugleobservation (Debug)<\/h1>\n<div id=\"gpsStatus\">Status: Starter op\u2026<\/div>\n\n<div id=\"map\"><\/div>\n\n<script src=\"https:\/\/unpkg.com\/leaflet@1.9.4\/dist\/leaflet.js\" crossorigin=\"\"><\/script>\n<script>\n  let map;\n  let markersLayer;\n\n  const gpsStatus = document.getElementById('gpsStatus');\n\n  function initMap() {\n    console.log('initMap() kaldt');\n    map = L.map('map').setView([56, 10], 6);\n\n    L.tileLayer('https:\/\/{s}.tile.openstreetmap.org\/{z}\/{x}\/{y}.png', {\n      maxZoom: 19,\n      attribution: '&copy; OpenStreetMap contributors'\n    }).addTo(map);\n\n    markersLayer = L.layerGroup().addTo(map);\n    console.log('Kort initialiseret');\n  }\n\n  function getGPS() {\n    console.log('getGPS() kaldt');\n    if (!navigator.geolocation) {\n      gpsStatus.textContent = 'GPS underst\u00f8ttes ikke af din browser.';\n      console.error('Geolocation ikke underst\u00f8ttet');\n      return;\n    }\n\n    gpsStatus.textContent = 'Henter GPS-position\u2026';\n\n    navigator.geolocation.getCurrentPosition(position => {\n      console.log('GPS position modtaget:', position.coords);\n      gpsStatus.textContent = `GPS klar: Lat ${position.coords.latitude.toFixed(5)}, Lon ${position.coords.longitude.toFixed(5)}`;\n\n      if(map) {\n        map.setView([position.coords.latitude, position.coords.longitude], 13);\n        L.marker([position.coords.latitude, position.coords.longitude])\n          .addTo(markersLayer)\n          .bindPopup('Din position')\n          .openPopup();\n      }\n    }, error => {\n      gpsStatus.textContent = 'Kan ikke hente GPS-position: ' + error.message;\n      console.error('GPS error:', error);\n    }, {\n      enableHighAccuracy: true,\n      timeout: 10000,\n      maximumAge: 0\n    });\n  }\n\n  window.onload = () => {\n    console.log('window.onload');\n    initMap();\n    getGPS();\n  };\n<\/script>\n\n<\/body>\n<\/html>\n","protected":false},"excerpt":{"rendered":"<p>Fugleobservation med GPS &#038; Leaflet (Debug) Fugleobservation (Debug) Status: Starter op\u2026<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_oct_exclude_from_cache":false,"footnotes":""},"class_list":["post-16074","page","type-page","status-publish","hentry"],"_elementor_controls_usage":"","_wp_page_template":"","themo_transparent_header":"off","themo_hide_title":"off","themo_page_layout":"full","_wpml_word_count":"","_edit_lock":"1750767909:1","_elementor_page_settings":"","themo_header_content_style":"","themo_alt_logo":"","_wpml_media_featured":"1","_wpml_media_duplicate":"1","_edit_last":"1","_elementor_edit_mode":"","_elementor_data":"","_elementor_version":"","_elementor_template_type":"","_wpml_location_migration_done":"","_alp_processed":"","_icl_lang_duplicate_of":"","_last_translation_edit_mode":"","_wpml_post_translation_editor_native":"","cmplz_hide_cookiebanner":"","_elementor_page_assets":[],"_elementor_css":"","burst_total_pageviews_count":"","_elementor_template_widget_type":"","_top_nav_excluded":"","_cms_nav_minihome":"","_vcv-sourceChecksum":"","vcvSourceCssFileUrl":"","_vcv-globalCssMigrated":"","_elementor_popup_display_settings":"","_wp_suggested_privacy_policy_content":"","_cmplz_scanned_post":"1","_wp_trash_meta_status":"","_wp_trash_meta_time":"","_wp_desired_post_slug":"","_links":{"self":[{"href":"https:\/\/www.whynotbirds.com\/en\/wp-json\/wp\/v2\/pages\/16074","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.whynotbirds.com\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.whynotbirds.com\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.whynotbirds.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.whynotbirds.com\/en\/wp-json\/wp\/v2\/comments?post=16074"}],"version-history":[{"count":1,"href":"https:\/\/www.whynotbirds.com\/en\/wp-json\/wp\/v2\/pages\/16074\/revisions"}],"predecessor-version":[{"id":16075,"href":"https:\/\/www.whynotbirds.com\/en\/wp-json\/wp\/v2\/pages\/16074\/revisions\/16075"}],"wp:attachment":[{"href":"https:\/\/www.whynotbirds.com\/en\/wp-json\/wp\/v2\/media?parent=16074"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}