|
| 1 | +/* |
| 2 | + * Copyright 2025 Google LLC |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * * https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | + * * Unless required by applicable law or agreed to in writing, software |
| 9 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | + * See the License for the specific language governing permissions and |
| 12 | + * limitations under the License. |
| 13 | +*/ |
| 14 | + |
| 15 | +// @ts-nocheck |
| 16 | +// [START maps_3d_marker_customization] |
| 17 | +async function init() { |
| 18 | + const { Map3DElement, Marker3DElement } = await google.maps.importLibrary("maps3d"); |
| 19 | + const { PinElement } = await google.maps.importLibrary("marker"); |
| 20 | + |
| 21 | + const map = new Map3DElement({ |
| 22 | + center: { lat: 37.4176, lng: -122.02, altitude: 0 }, |
| 23 | + tilt: 67.5, |
| 24 | + range: 7000, |
| 25 | + mode: 'HYBRID' |
| 26 | + }); |
| 27 | + |
| 28 | + map.mode = "SATELLITE"; |
| 29 | + |
| 30 | + // Change the border color. |
| 31 | + const pinBorder = new PinElement({ |
| 32 | + borderColor: '#FFFFFF', |
| 33 | + }); |
| 34 | + const markerWithBorder = new Marker3DElement({ |
| 35 | + position: { lat: 37.415, lng: -122.035 }, |
| 36 | + }); |
| 37 | + markerWithBorder.append(pinBorder); |
| 38 | + |
| 39 | + // Add a label. |
| 40 | + const markerWithLabel = new Marker3DElement({ |
| 41 | + position: { lat: 37.419, lng: -122.03 }, |
| 42 | + label: 'Simple label' |
| 43 | + }); |
| 44 | + |
| 45 | + // Adjust the scale. |
| 46 | + const pinScaled = new PinElement({ |
| 47 | + scale: 1.5, |
| 48 | + }); |
| 49 | + const markerWithScale = new Marker3DElement({ |
| 50 | + position: { lat: 37.419, lng: -122.02 }, |
| 51 | + }); |
| 52 | + markerWithScale.append(pinScaled); |
| 53 | + |
| 54 | + // Change the glyph color. |
| 55 | + const pinGlyph = new PinElement({ |
| 56 | + glyphColor: 'white', |
| 57 | + }); |
| 58 | + const markerWithGlyphColor = new Marker3DElement({ |
| 59 | + position: { lat: 37.415, lng: -122.025 }, |
| 60 | + }); |
| 61 | + markerWithGlyphColor.append(pinGlyph); |
| 62 | + |
| 63 | + // Change many elements together and extrude marker. |
| 64 | + const pinTextGlyph = new PinElement({ |
| 65 | + background: '#F0F6FC', |
| 66 | + glyph: 'E', |
| 67 | + glyphColor: 'red', |
| 68 | + borderColor: '#0000FF', |
| 69 | + }); |
| 70 | + const markerWithGlyphText = new Marker3DElement({ |
| 71 | + position: { lat: 37.415, lng: -122.015, altitude: 50 }, |
| 72 | + extruded: true, |
| 73 | + altitudeMode: "RELATIVE_TO_GROUND", |
| 74 | + }); |
| 75 | + markerWithGlyphText.append(pinTextGlyph); |
| 76 | + |
| 77 | + // Hide the glyph. |
| 78 | + const pinNoGlyph = new PinElement({ |
| 79 | + glyph: '', |
| 80 | + }); |
| 81 | + const markerWithNoGlyph = new Marker3DElement({ |
| 82 | + position: { lat: 37.415, lng: -122.005 }, |
| 83 | + }); |
| 84 | + markerWithNoGlyph.append(pinNoGlyph); |
| 85 | + |
| 86 | + // Change the background color. |
| 87 | + const pinBackground = new PinElement({ |
| 88 | + background: '#FBBC04', |
| 89 | + }); |
| 90 | + |
| 91 | + const markerWithBackground = new Marker3DElement({ |
| 92 | + position: { lat: 37.419, lng: -122.01 }, |
| 93 | + }); |
| 94 | + markerWithBackground.append(pinBackground); |
| 95 | + |
| 96 | + map.append(markerWithLabel); |
| 97 | + map.append(markerWithScale); |
| 98 | + map.append(markerWithBackground); |
| 99 | + map.append(markerWithBorder); |
| 100 | + map.append(markerWithGlyphColor); |
| 101 | + map.append(markerWithGlyphText); |
| 102 | + map.append(markerWithNoGlyph); |
| 103 | + |
| 104 | + document.body.append(map); |
| 105 | +} |
| 106 | + |
| 107 | +init(); |
| 108 | +// [END maps_3d_marker_customization] |
0 commit comments