Skip to content

Commit

Permalink
更新google map
Browse files Browse the repository at this point in the history
  • Loading branch information
estea8968 committed Apr 16, 2024
1 parent dbea5f7 commit f719d30
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="google" value="notranslate">
<link rel="shortcut icon" href="static/favicon.ico">
<title>OSEP_scratch 1120411</title>
<title>OSEP_scratch 1130416</title>

</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion app/lib.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -414813,7 +414813,7 @@ var googleMap = /*#__PURE__*/function () {
}

openGoogleMapWindow.document.write('];');
openGoogleMapWindow.document.write("\n var map;\n var marker = [];\n var infoWindow = [];\n var windowOpened;\n\n function initMap() {\n var target = document.getElementById(\"map\");\n var latMax = lat_Max();\n var latMin = lat_Min();\n var lngMax = lng_Max();\n var lngMin = lng_Min();\n var bounds = new google.maps.LatLngBounds(\n { lat: latMax, lng: lngMin },\n { lat: latMin, lng: lngMax }\n );\n\n map = new google.maps.Map(\n target, {\n center: {\n lat: latMax,\n lng: lngMin\n }, zoom: 16,\n });\n setData(markerData);\n if (markerData.length > 1) map.fitBounds(bounds);\n }\n\n function lat_Max() {\n var a = 0;\n for (var i = 0; i < markerData.length; i++)\n if (markerData[i].lat > a) a = markerData[i].lat;\n return a;\n }\n \n function lat_Min() {\n var b = 1000;\n for (var i = 0; i < markerData.length; i++)\n if (markerData[i].lat < b) b = markerData[i].lat;\n return b;\n }\n \n function lng_Max() {\n var c = 0;\n for (var i = 0; i < markerData.length; i++)\n if (markerData[i].lng > c) c = markerData[i].lng;\n return c;\n }\n \n function lng_Min() {\n var d = 1000;\n for (var i = 0; i < markerData.length; i++)\n if (markerData[i].lng < d) d = markerData[i].lng;\n return d;\n }\n\n function setData(markerData) {\n var sidebar_html = '\u5EA7\u6A19\u6E05\u55AE\uFF1A<br>';\n for (var i = 0; i < markerData.length; i++) {\n addMarker(i, markerData[i].lat, markerData[i].lng, markerData[i].label, markerData[i].color, markerData[i].remark, markerData[i].length, markerData[i].width);\n var name = markerData[i][\"label\"];\n sidebar_html += '<b>' + (i + 1) + '.</b> <a href=\"javascript:openWindow(' + i + ')\">' + name + '</a><br />';\n }\n document.getElementById(\"sidebar\").innerHTML = sidebar_html;\n }\n\n function addMarker(i, lat, lng, label, color, remark, length, width) {\n var markerLatLng = new google.maps.LatLng({ lat: lat, lng: lng, });\n var pinImage = 'https://chart.googleapis.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|' + color;\n marker[i] = new google.maps.Marker({\n position: markerLatLng,\n map: map,\n icon: {\n url: pinImage,\n scaledSize: new google.maps.Size(width, length)\n }\n });\n const contentString = '<h2>' + label + '</h2><p style=\"font-size:16px;font-weight:bold;\">' + remark + '</p>';\n infoWindow[i] = new google.maps.InfoWindow({ content: contentString });\n markerEvent(i);\n }\n\n function markerEvent(i) {\n marker[i].addListener(\"click\",\n function () {\n if (windowOpened) windowOpened.close();\n infoWindow[i].open(map, marker[i]);\n windowOpened = infoWindow[i];\n }\n );\n }\n \n function openWindow(i) {\n if (windowOpened) windowOpened.close();\n infoWindow[i].open(map, marker[i]);\n windowOpened = infoWindow[i];\n }\n\n </script>\n </body>\n \n </html>\n ");
openGoogleMapWindow.document.write("\n var map;\n var marker = [];\n var infoWindow = [];\n var windowOpened;\n\n function initMap() {\n var target = document.getElementById(\"map\");\n var latMax = lat_Max();\n var latMin = lat_Min();\n var lngMax = lng_Max();\n var lngMin = lng_Min();\n var bounds = new google.maps.LatLngBounds(\n { lat: latMax, lng: lngMin },\n { lat: latMin, lng: lngMax }\n );\n\n map = new google.maps.Map(\n target, {\n center: {\n lat: latMax,\n lng: lngMin\n }, zoom: 16,\n });\n setData(markerData);\n if (markerData.length > 1) map.fitBounds(bounds);\n }\n\n function lat_Max() {\n var a = 0;\n for (var i = 0; i < markerData.length; i++)\n if (markerData[i].lat > a) a = markerData[i].lat;\n return a;\n }\n \n function lat_Min() {\n var b = 1000;\n for (var i = 0; i < markerData.length; i++)\n if (markerData[i].lat < b) b = markerData[i].lat;\n return b;\n }\n \n function lng_Max() {\n var c = 0;\n for (var i = 0; i < markerData.length; i++)\n if (markerData[i].lng > c) c = markerData[i].lng;\n return c;\n }\n \n function lng_Min() {\n var d = 1000;\n for (var i = 0; i < markerData.length; i++)\n if (markerData[i].lng < d) d = markerData[i].lng;\n return d;\n }\n\n function setData(markerData) {\n var sidebar_html = '\u5EA7\u6A19\u6E05\u55AE\uFF1A<br>';\n for (var i = 0; i < markerData.length; i++) {\n addMarker(i, markerData[i].lat, markerData[i].lng, markerData[i].label, markerData[i].color, markerData[i].remark, markerData[i].length, markerData[i].width);\n var name = markerData[i][\"label\"];\n sidebar_html += '<b>' + (i + 1) + '.</b> <a href=\"javascript:openWindow(' + i + ')\">' + name + '</a><br />';\n }\n document.getElementById(\"sidebar\").innerHTML = sidebar_html;\n }\n\n function addMarker(i, lat, lng, label, color, remark, length, width) {\n var markerLatLng = new google.maps.LatLng({ lat: lat, lng: lng, });\n var pinImage = 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent('<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" width=\"36\" height=\"36\" fill=\"#' + color + '\"><path d=\"M12 2C7.6 2 4 5.6 4 10c0 4.4 8 13 8 13s8-8.6 8-13c0-4.4-3.6-8-8-8zm0 11c-1.7 0-3-1.3-3-3s1.3-3 3-3 3 1.3 3 3-1.3 3-3 3z\"/></svg>');\n marker[i] = new google.maps.Marker({\n position: markerLatLng,\n map: map,\n icon: {\n url: pinImage,\n scaledSize: new google.maps.Size(width, length)\n }\n });\n const contentString = '<h2>' + label + '</h2><p style=\"font-size:16px;font-weight:bold;\">' + remark + '</p>';\n infoWindow[i] = new google.maps.InfoWindow({ content: contentString });\n markerEvent(i);\n }\n\n function markerEvent(i) {\n marker[i].addListener(\"click\",\n function () {\n if (windowOpened) windowOpened.close();\n infoWindow[i].open(map, marker[i]);\n windowOpened = infoWindow[i];\n }\n );\n }\n \n function openWindow(i) {\n if (windowOpened) windowOpened.close();\n infoWindow[i].open(map, marker[i]);\n windowOpened = infoWindow[i];\n }\n\n </script>\n </body>\n \n </html>\n ");
openGoogleMapWindow.document.close();
}
}, {
Expand Down
2 changes: 1 addition & 1 deletion app/lib.min.js.map

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,7 @@ class googleMap {
function addMarker(i, lat, lng, label, color, remark, length, width) {
var markerLatLng = new google.maps.LatLng({ lat: lat, lng: lng, });
var pinImage = 'https://chart.googleapis.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|' + color;
var pinImage = 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="36" height="36" fill="#' + color + '"><path d="M12 2C7.6 2 4 5.6 4 10c0 4.4 8 13 8 13s8-8.6 8-13c0-4.4-3.6-8-8-8zm0 11c-1.7 0-3-1.3-3-3s1.3-3 3-3 3 1.3 3 3-1.3 3-3 3z"/></svg>');
marker[i] = new google.maps.Marker({
position: markerLatLng,
map: map,
Expand Down

0 comments on commit f719d30

Please sign in to comment.