inocan-group / vue3-google-map

A set of composable components for easy use of Google Maps in your Vue 3 projects.
https://vue3-google-map.com
MIT License
280 stars 57 forks source link

Added marker in streetview is now shown. #42

Closed jbbulls closed 2 years ago

jbbulls commented 3 years ago

The code below is taken from the Google Maps sample. https://jsfiddle.net/api/post/library/pure/ Maybe someone can help me spot the issue. Thanks

onMounted(() => { setTimeout(() => { if (mapRef.value.ready) {
// const panorama = mapRef.value.api.StreetViewPanorama; const panorama = mapRef.value.map.getStreetView();

      const cafeMarker = new mapRef.value.api.Marker({
        position: { lat: 53.48161, lng: -2.24212 },
        panorama,
        icon: "https://chart.apis.google.com/chart?chst=d_map_pin_icon&chld=cafe|FFFF00",
        title: "Cafe",
      });

      console.log('cafeMarker', cafeMarker); 

      panorama.setPosition(centerPosition.value);
      panorama.setPov(
        /** @type {google.maps.StreetViewPov} */ {
          heading: 265,
          pitch: 0,
        });
    }      
  }, 2000);
});
VitAndrGuid commented 3 years ago

You manually created the marker but never assigned it to the map, try passing the map instance to the marker like in the first code of https://developers.google.com/maps/documentation/javascript/adding-a-google-map.