From 223d4ab2f90fd4d719086b85bd14e7779480fb5d Mon Sep 17 00:00:00 2001 From: fustyles <34397289+fustyles@users.noreply.github.com> Date: Sat, 28 Dec 2024 19:35:15 +0800 Subject: [PATCH] Update javascript.js --- googlemap_20241226/blockly/javascript.js | 82 +++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) diff --git a/googlemap_20241226/blockly/javascript.js b/googlemap_20241226/blockly/javascript.js index b6246ec94a..3ec9cbf557 100644 --- a/googlemap_20241226/blockly/javascript.js +++ b/googlemap_20241226/blockly/javascript.js @@ -22,7 +22,87 @@ Blockly.JavaScript['googlemap_initial'] = function (block) { 'document.getElementsByTagName("head")[0].append(s);\n'+ 'function initMap() {\n'+statement+'\n}\n'+ 'window.initMap = initMap;\n'+ - 'await delay(3);\n'; + 'await delay(3);\n'+ + 'let mapMarkers = [];\n'+ + 'function addMapPoint(pID, pMapId, pLat, pLng, pTitle, pContent) {\n'+ + ' let markerData = {\n'+ + ' position: { lat: pLat, lng: pLng },\n'+ + ' title: pTitle,\n'+ + ' };\n'+ + ' let marker = new google.maps.marker.AdvancedMarkerElement({\n'+ + ' position: markerData.position,\n'+ + ' map: pMapId,\n'+ + ' title: markerData.title,\n'+ + ' });\n'+ + ' let infoWindow = new google.maps.InfoWindow({\n'+ + ' content: pContent,\n'+ + ' });\n'+ + ' marker.addListener("click", () => {\n'+ + ' infoWindow.open(pMapId, marker);\n'+ + ' });\n'+ + ' mapMarkers.push(["point_"+pID, pMapId, marker, infoWindow, markerData.position]);\n'+ + '}\n'+ + 'function clearMarker(pID) {\n'+ + ' for (var i=0;i