0

i want to show one marker in ng-maps, but im getting error saying Error: [ng:areq] Argument 'myCtrl' is not a function, got undefined code

 <!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <script src="https://maps.google.com/maps/api/js?libraries=placeses,visualization,drawing,geometry,places&key=AIzaSyDQ2TPHVI30yFa6-yVLf8ffNRTlwWvAmf8"></script>
    <script src="https://code.angularjs.org/1.3.15/angular.js"></script>
    <script src="https://rawgit.com/allenhwkim/angularjs-google-maps/master/build/scripts/ng-map.js"></script>


</head>
<body ng-app="ngApp" , ng-controller="myCtrl">
    <ng-map id="map" zoom="11" center="[{{names.lat}},{{names.longitude}}]">
        <marker position="[{{names.lat}},{{names.longitude}}]" title=""></marker>
    </ng-map>
    <script>
        var app = angular.module('ngApp', []);
        app.controller('myCtrl', function ($scope, $http) {
            $http.get('url')
                .then(function (response) {
                    $scope.names = response.data;
                });
        });
        console.log($scope.names);
    </script>
</body>
</html>
krishna mohan
  • 15
  • 1
  • 5

1 Answers1

0

You need to remove the ng-app=ngMap from html tag or use that to define the app and remove the ng-app=ngApp.

<html >//removed ng-app from this one
<head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <script src="https://maps.google.com/maps/api/js?libraries=placeses,visualization,drawing,geometry,places&key=AIzaSyDQ2TPHVI30yFa6-yVLf8ffNRTlwWvAmf8"></script>
    <script src="https://code.angularjs.org/1.3.15/angular.js"></script>
    <script src="https://rawgit.com/allenhwkim/angularjs-google-maps/master/build/scripts/ng-map.js"></script>
    <script src="https://code.angularjs.org/1.3.15/angular.js"></script>

</head>
<body ng-app="ngApp" , ng-controller="myCtrl">
    <ng-map id="map" zoom="11" center="[{{names.lat}},{{names.longitude}}]">
        <marker position="[{{names.lat}},{{names.longitude}}]" title=""></marker>
    </ng-map>
    <script>
        var app = angular.module('ngApp', []);
        app.controller('myCtrl', function ($scope, $http) {
            $http.get('URL')
                .then(function (response) {
                    $scope.names = response.data;
                });
        });
    </script>
</body>
</html>
Sunil Lama
  • 4,531
  • 1
  • 18
  • 46
  • i have updated my code, im not getting any error now but im not able see the map , getting blank page. only – krishna mohan Apr 09 '18 at 07:33
  • @krishnamohan you should log the $scope.names and show. your url is a string which should be the actual url what are you getting $http.get('url'). What is the url in this – Sunil Lama Apr 09 '18 at 07:35
  • var app = angular.module('ngApp', []);//Uncaught ReferenceError: angular is not defined – krishna mohan Apr 09 '18 at 07:41