Why isn't the Angular Google Maps Displaying in my Template View?

After configuring Angular Google Maps and following the provided steps, I am facing an issue where the map is not loading on the directive without any error. Below is the code snippet:

Controller

app.controller('MapCtrl', [
    '$scope',
    'uiGmapGoogleMapApi',
    function($scope, uiGmapGoogleMapApi) {
        //Variables Decleration
        $scope.odorizerID = "";
        $scope.map = {
            center: {
                latitude: 45,
                longitude: -73
            },
            zoom: 8
        };
        //Function Decleration
        $scope.onMapClick = function(odorizerID) {

        }

        uiGmapGoogleMapApi.then(function(maps) {

        });

    }
]);

app.js

app.config([
    '$stateProvider',
    '$urlRouterProvider',
    'uiGmapGoogleMapApiProvider',
    function($stateProvider, $urlRouterProvider, uiGmapGoogleMapApiProvider) {

        /**
         * Configuring the Google Map API.
         */
        uiGmapGoogleMapApiProvider.configure({
            //    key: 'your api key',
            v: '3.17',
            libraries: 'weather,geometry,visualization'
        });



        /*For any unmatched url, redirect to / */
        $urlRouterProvider.otherwise("/");
        /*For all the other states we would configure the $StateProvider*/
        $stateProvider
            .state('login', {
                url: "/",
                templateUrl: "/app/views/auth/login.html",
                controller: 'AuthCtrl'
            })
            .state('maps', {
                url: "/maps",
                templateUrl: "/app/views/maps/maps.html"
            })
            .state('performance', {
                url: "/performance/:ororizerID",
                templateUrl: "/app/views/details/performance.html",
                controller: "PerformanceCtrl"
            })
            .state('usage', {
                url: "/usage/:ororizerID",
                templateUrl: "/app/views/details/usage.html"
            });
    }
]);

maps.html

<ui-gmap-google-map center='map.center' zoom='map.zoom'></ui-gmap-google-map>

index.html

This content should be included in the index.html file

<script src="bower_components/angular-google-maps/dist/angular-google-maps.js"></script>

Please provide assistance with resolving this issue as the map is not loading at all.

The output displayed in the view is as follows:

<ui-gmap-google-map center="map.center" zoom="map.zoom" class="ng-scope ng-isolate-scope"><div class="angular-google-map"><div class="angular-google-map-container"></div><div ng-transclude="" style="display: none"></div></div></ui-gmap-google-map>

style.css

<style type="text/css">
  .angular-google-map-container { height: 400px; width:800px;}
</style>

Answer №1

You forgot to include the controller declaration in your $stateProvider.

.state('maps', {
    url: "/maps",
    templateUrl: "/app/views/maps/maps.html"
})

-->

.state('maps', {
    url: "/maps",
    templateUrl: "/app/views/maps/maps.html",
    controller: "MapCtrl"
})

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is it possible to arrange JSON Objects vertically on a webpage using tables, flexboxes, divs, and Javascript?

Within my JSON data, I have multiple products defined. My goal is to loop through this JSON and display these products side by side on a web page for easy comparison. Initially, I envision structuring them in columns and then rows: https://i.sstatic.net/K ...

Having trouble transforming my JSON file into a JavaScript object

I have a JSON file with the following structure: { "branding": { "body": { "header_text_color": "#224466", "body_text_color": "##224466", "background_color": &quo ...

What steps should be taken in VUEjs if the API response is null?

There's a method in my code that retrieves a token from an API: let { Token } = await API.getToken({ postId: postId }) if(){} Whenever the token is null, I receive a warning in the console saying "Cannot read property 'Token' ...

Displaying the information fetched using axios on the screen using node.js

Is there a way to display the information from the input boxes in the image on the screen using node js? ...

Unable to forward to another page using NodeJS (Express)

After spending a considerable amount of time trying to find a solution, I finally managed to create a simple button click redirection using NodeJS and Express. However, when clicking on the "Next page" button in my index.html file, I encountered an error s ...

elevate the div with a floating effect

My goal is to create a chat feature for users that will only be visible for a limited time period. I was thinking of using PHP and timestamp to achieve this functionality, but I also want to make the chat visually disappear by having the message div float ...

Guide on displaying several items from Laravel to Vue through the JavaScript filter method?

I need help transferring multiple objects from laravel to vue and filling my vue objects with information retrieved from the database. This is the data received from laravel: https://i.sstatic.net/2Hnk5.png Vue objects to be populated: storeName: {}, ...

Obtain the value stored in the variable named "data"

I'm trying to calculate the sum of data values using jQuery, similar to this example: { label: "Beginner", data: 2}, { label: "Advanced", data: 12}, { label: "Expert", data: 22}, and then add them together. Like so: var sum = data1+data2+dat ...

Issue encountered while attempting to save hook arrays: Uncaught TypeError - 'choices' is not able to be

I'm in the process of creating a straightforward multiple-choice exam form that includes choices and answers. Whenever a user selects an option, it should be added to the array of choices. At the start, I have an array called exercises, which consist ...

Iframe navigation tracking technology

Let's say I have an iframe element in my HTML document. <html> <body> This is my webpage <button> Button </button> <iframe src="www.example.com"></iframe> </body> </html> If a user clicks on links wi ...

Determine the estimated download duration using the $http protocol

I am experiencing an issue with a function that calculates the time it takes to download a text file (3MB in size) from my server. While it works well for single requests, when I attempt to run multiple requests simultaneously, the time spent waiting for a ...

Delving into the World of ES6 Symbols

Throughout my experience with various programming languages, from C# to Lisp to Scala to Haskell, symbols have consistently behaved as singleton objects. This means that any two symbols with the same name are guaranteed to be identical. In Racket: (equal? ...

Once the submission is made, the website will automatically refresh

As I delved into working on a web page utilizing JavaScript, I implemented a jQuery function to validate user input data. I ensured that if the data was incorrect, the function would return false (return false;) and the form would not refresh the page. How ...

The process of exporting and utilizing models in Sequelize

When working on my node.js project with sequelize, I encountered a challenge of exporting and using table models in another file. I typically save table models in a folder, for instance Profile.js. module.exports = (sequelize, DataTypes) => sequelize.d ...

Explore how to effectively use multiple values in a jQuery filter function when working with data attributes

Exploring the use of jQuery filter for data attributes with tables that contain team, specialization, and level data variables. Seeking advice on the best approach and typical usage methods. Here is my HTML code: <table data-team="<?php print $name[ ...

Using Javascript within an HTML document may not provide the intended functionality

My script: <!DOCTYPE html> <html> <head> <script> $(document).ready(function () { document.getElementById("saveForm").click(); }); </script> </head> <!--<body onload="document.getElementById('saveForm&apos ...

Connect Vue-switch value to a data property

Utilizing the vue-switch component to toggle on and off, I needed to determine its current state. Following guidance from the documentation at https://www.npmjs.com/package/vue-switch, I implemented :value.sync="toggle" in the switch component along with a ...

Tips on updating an object and adding it to an array in ReactJS with Material UI

Seeking guidance on editing an array of objects and displaying the updated value in the view. I'm new to ReactJS and attempted to do it as shown below, but found that after editing, I lose everything except for the specific one I edited. Can anyone co ...

Why does calling $resource (or $http) from inside a callback in Cordova and AngularJS result in a 404 error?

After successfully transitioning my functional angularjs web app to Cordova and compiling it for iOS, I encountered an issue while testing the app on iOS. When trying to access a local file from inside a callback response (after successfully accessing anot ...

Determine the originating page in Next.js that leads to the current page

Imagine a scenario with three pages: A, B, and C. In this setup, it is possible to navigate from page A to C, as well as from page B to C. However, the displayed content on page C will vary depending on the origin page of the navigation. I am curious to ...