creativetimofficial / vue-black-dashboard

Vue Black Dashboard
https://demos.creative-tim.com/vue-black-dashboard
MIT License
558 stars 848 forks source link

Google Maps Problem #68

Closed MZain-ul-Abideen closed 4 hours ago

MZain-ul-Abideen commented 4 hours ago

Describe the Bug The Google Maps integration on the http://localhost:8080/#/maps page does not work as expected. The map fails to render, and the browser console logs multiple errors related to the Google Maps API key and improper API loading patterns. The issue prevents users from interacting with the embedded map, resulting in a broken feature.

Steps to Reproduce

  1. Clone the repository and follow the setup instructions to run the project locally.
  2. Start the application using the provided instructions (e.g., npm run serve or equivalent command).
  3. Navigate to the Maps section at http://localhost:8080/#/maps.
  4. Open the browser's developer console (press F12 or right-click and choose Inspect, then go to the Console tab).
  5. Observe the following:

Expected Behavior

Actual Behavior The Maps page fails to load the Google Map, and the console displays errors indicating a missing or invalid Google Maps API key. {{ Google Maps JavaScript API has been loaded directly without loading=async. This can result in suboptimal performance. For best-practice loading patterns please see https://goo.gle/js-api-loading

[Vue warn]: Error in mounted hook: "TypeError: window.google.maps.marker is undefined"

found in

---> at src/pages/Maps.vue

at src/layout/dashboard/Content.vue at src/layout/dashboard/DashboardLayout.vue at src/App.vue }} **Screenshots** ![Screenshot from 2024-11-15 18-06-57](https://github.com/user-attachments/assets/898eb510-1ff2-44ea-95cc-a0a80d1aafe3) **Environment** Browser: Firefox (latest version) Operating System: Manjaro Linux Node.js Version: 10.9.0 **Possible Causes** 1. Invalid or Missing API Key: The key provided for Google Maps might be incorrect, expired, or improperly configured in the project. 2. Improper API Loading Pattern: The Google Maps JavaScript API has been loaded directly without using the recommended async attribute, leading to potential initialization issues. 3. Integration Issue: The codebase might reference window.google.maps.marker incorrectly, or the relevant Google Maps library component (e.g., Marker) may not be loaded. **Proposed Solutions** 1. API Key Configuration: - Verify the Google Maps API key in the project configuration file or .env file. 2. Ensure the API key is authorized for the domain localhost in the Google Cloud Console. - Best Practice Loading: 3. Update the script tag for the Google Maps API to include the async and defer attributes: - Follow the official documentation for optimal API loading: Google Maps JavaScript API Loading. **Debug Integration Code** - Check the mounted hook in src/pages/Maps.vue for issues referencing window.google.maps.marker. - Ensure all necessary Google Maps components are explicitly loaded in the API script URL (e.g., libraries=places,geometry). **Additional Context** - The problem may stem from incorrect integration of the Google Maps API with Vue's lifecycle methods, especially in the mounted hook. - Consult relevant documentation for the Google Maps API and Vue.js best practices when working with third-party libraries.
github-actions[bot] commented 4 hours ago

@MZain-ul-Abideen this issue was automatically closed because it did not follow the bellow rules:


IMPORTANT: Please use the following link to create a new issue:

https://www.creative-tim.com/new-issue/vue-black-dashboard

**If your issue was not created using the app above, it will be closed immediately.**

Love Creative Tim? Do you need Angular, React, Vuejs or HTML? You can visit:
πŸ‘‰  https://www.creative-tim.com/bundles
πŸ‘‰  https://www.creative-tim.com