קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
כברירת מחדל, נתונים נטענים רק פעם אחת על ידי קישורים ל-Google Earth. כדי למנוע התיישנות של נתוני KML, ניתן לציין refreshMode ב-onExpire לכל הנתונים שנטענים על ידי רכיב <href> (ברכיב קישור או רכיב סמל). כברירת מחדל, כותרות התפוגה של ה-HTTP מציינות את מועד התפוגה. אפשר גם לציין זמן פקיעת תוקף ב-KML NetworkLinkControl. השעה מבוטאת כתאריך XML. (ראו סכימת XML חלק 2: סוגי נתונים מהדורה שנייה). אם צוינו כותרות HTTP וזמני תפוגה של KML, זמן התפוגה של KML מקבל עדיפות.
דוגמה 1: תפוגה באמצעות זמן התפוגה של שרת HTTP
זוהי דוגמה בלבד. הוא מציג שכבת-על עם סמל שמגדיר refreshMode ל-onExpire. מכיוון שלא הוגדר זמן תפוגה של KML, בדוגמה הזו נעשה שימוש בזמן התפוגה של שרת ה-HTTP.
<?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://www.opengis.net/kml/2.2"> <Document> <name>refreshMode onExpire</name> <Snippet maxLines="10"> Image automatically reloads according to http server expiration. </Snippet> <GroundOverlay> <Icon> <href>http://www.someserver.com/image.jpeg</href> <refreshMode>onExpire</refreshMode> </Icon> <LatLonBox> <!-- from edit session in earth --> <!-- The roof of a building in the Presidio --> <north>37.80385180177469</north> <east>-122.4558710620651</east> <south>37.80337403503347</south> <west>-122.4564295653771</west> </LatLonBox> </GroundOverlay> </Document> </kml>
דוגמה 2: דוגמה עם זמן תפוגה של KML
הדוגמה הבאה מספקת סמן בקואורדינטות שנבחרו באופן אקראי. בדוגמה הזו מופיע קישור עם refreshMode: onExpire. במקרה כזה, התאריך/שעה של התפוגה מוגדרים (בסקריפט של Python) באמצעות רכיב ה-KML החדש <expires>. מועד התפוגה של ה-KML מקבל עדיפות על פני כל פרק זמן שהיה מוגדר בכותרות ה-HTTP.
הנה קישור Network KML המכיל את הקישור עם האלמנטים <href> ו-<refreshMode>:
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2022-12-20 (שעון UTC)."],[[["\u003cp\u003eBy default, Google Earth loads data only once, but you can refresh KML data using the \u003ccode\u003erefreshMode\u003c/code\u003e tag set to \u003ccode\u003eonExpire\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eExpiration times can be set using HTTP headers or the KML \u003ccode\u003e<expires>\u003c/code\u003e element within a \u003ccode\u003e<NetworkLinkControl>\u003c/code\u003e, with the KML element taking precedence.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003e<expires>\u003c/code\u003e element utilizes the XML dateTime format to specify the refresh time.\u003c/p\u003e\n"],["\u003cp\u003eTwo examples demonstrate refreshing data based on HTTP server expiration and a specific KML-defined expiration time, respectively, using \u003ccode\u003e<href>\u003c/code\u003e and \u003ccode\u003e<refreshMode>\u003c/code\u003e within a \u003ccode\u003e<Link>\u003c/code\u003e element.\u003c/p\u003e\n"]]],[],null,["# Expiration\n\nBy default, data is loaded only once by Links into Google Earth. To prevent KML data from becoming stale, you can specify a *refreshMode* of *onExpire* for any data loaded by an \\\u003chref\\\u003e element (in a Link or Icon element). By default, HTTP expiration headers specify the expiration time. You can also now specify an *expires* time in a KML NetworkLinkControl. The time is expressed as an XML dateTime (see [XML Schema Part 2: Datatypes Second Edition](http://www.w3.org/TR/xmlschema-2/#dateTime)). If both HTTP headers and KML expiration times are specified, the KML expiration time takes precedence.\n\nExample 1: Expiration using HTTP server expiration time\n=======================================================\n\nThis example is for illustration only. It shows a GroundOverlay with an Icon that sets a *refreshMode* of *onExpire*. Since no KML expiration time is set, this example uses the HTTP server expiration time. \n\n```\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003ckml xmlns=\"http://www.opengis.net/kml/2.2\"\u003e\n\u003cDocument\u003e\n \u003cname\u003erefreshMode onExpire\u003c/name\u003e\n \u003cSnippet maxLines=\"10\"\u003e\n Image automatically reloads according to http\n server expiration.\n \u003c/Snippet\u003e\n \u003cGroundOverlay\u003e\n \u003cIcon\u003e\n \u003chref\u003ehttp://www.someserver.com/image.jpeg\u003c/href\u003e\n \u003crefreshMode\u003eonExpire\u003c/refreshMode\u003e\n \u003c/Icon\u003e\n \u003cLatLonBox\u003e\n \u003c!-- from edit session in earth --\u003e\n \u003c!-- The roof of a building in the Presidio --\u003e\n \u003cnorth\u003e37.80385180177469\u003c/north\u003e\n \u003ceast\u003e-122.4558710620651\u003c/east\u003e\n \u003csouth\u003e37.80337403503347\u003c/south\u003e\n \u003cwest\u003e-122.4564295653771\u003c/west\u003e\n \u003c/LatLonBox\u003e\n \u003c/GroundOverlay\u003e\n\u003c/Document\u003e\n\u003c/kml\u003e\n```\n\nExample 2: Example using KML expiration time\n============================================\n\nThe following example delivers a Placemark at randomly selected coordinates. This example includes a Link with a *refreshMode* of *onExpire*. In this case, the expiration date/time is specified (in a Python script) using the new KML \\\u003cexpires\\\u003e element. This KML expiration time takes precedence over any time that may have been specified in the HTTP headers.\n\nHere is the KML NetworkLink containing the Link with the \\\u003chref\\\u003e and \\\u003crefreshMode\\\u003e elements: \n\n```\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003ckml xmlns=\"http://www.opengis.net/kml/2.2\"\u003e\n\u003cDocument\u003e\n \u003cNetworkLink\u003e\n \u003cLink\u003e\n \u003chref\u003ehttp://dev.someserver.com/cgi-bin/expires.py\u003c/href\u003e\n \u003crefreshMode\u003eonExpire\u003c/refreshMode\u003e\n \u003c/Link\u003e\n \u003c/NetworkLink\u003e\n\u003c/Document\u003e\n\u003c/kml\u003e\n```\n\nThis is the Python script that sets an expires time of \\[*now* + 11 seconds\\] and refreshes the Placemark's coordinates: \n\n```\n#!/usr/bin/python\n\nimport random\nimport time\n\nlat = random.random() * 180. - 90.\nlon = random.random() * 360. - 180.\n\nnow = time.time()\nfuture = time.gmtime(now + 11)\ny = future[0]\nmo = future[1]\nd = future[2]\nh = future[3]\nmi = future[4]\ns = future[5]\niso8601 = '%04d-%02d-%02dT%02d:%02d:%02dZ' % (y,mo,d,h,mi,s)\n\nprint 'Content-type: application/vnd.google-earth.kml+xml'\nprint\n\nprint '\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e'\nprint '\u003ckml xmlns=\\\"http://www.opengis.net/kml/2.2\\\"\u003e'\n\n# must be child of \u003ckml\u003e\nprint '\u003cNetworkLinkControl\u003e'\nprint '\u003cexpires\u003e%s\u003c/expires\u003e' % iso8601\nprint '\u003c/NetworkLinkControl\u003e'\n\nprint '\u003cPlacemark\u003e'\nprint '\u003cname\u003eplacemark expires %s\u003c/name\u003e' % iso8601\nprint '\u003cPoint\u003e'\nprint '\u003ccoordinates\u003e%f,%f,0\u003c/coordinates\u003e' % (lon,lat)\nprint '\u003c/Point\u003e'\nprint '\u003c/Placemark\u003e'\n\nprint '\u003c/kml\u003e'\n```\n\n[Back to top](#top)"]]