maikelm
maikelm

Reputation: 403

ngmap for markers in google map

I am using ngmap and angularjs to generate points on a google map. I works perfectly on my local server, but when you move to a production server does not display the map. Seeing the console see the following error: "Error: google is not defined"

My code:

    var app = angular.module('dataview', ['ngMap'])
    app.controller('DataViewCtrl', function($scope, $http)
    {
      $scope.markers[{lat:30.2817, lng:-81.5273},{lat:30.6824, lng:-81.9680},{lat:31.0004, lng:-82.1580}];

      $scope.mapcenter={lat:$scope.markers[0].lat, lng:$scope.markers[0].lng};
    }
  <script src = 'http://maps.google.com/maps/api/js?v=3&sensor=true'></script>
 <script src = '/assets/vendor/ngmap/build/scripts/ng-map.min.js'></script>
    <map center="{{mapcenter.lat}}, {{mapcenter.lng}}" zoom="5" ng-if="is_map" style="height: 500px;">
        <marker ng-repeat="pos in markers" position="{{pos.lat}}, {{pos.lng}}"></marker>
    </map>

Upvotes: 0

Views: 2305

Answers (2)

maikelm
maikelm

Reputation: 403

The error is: src = 'http://maps.google.com/maps/api/js?v=3&sensor=true. The production server is in https enviroment. The soluction: src = 'https://maps.google.com/maps/api/js?v=3&sensor=true'. HTTPS not HTTP

Upvotes: 1

Adam Pine
Adam Pine

Reputation: 387

<script src = '/assets/vendor/ngmap/build/scripts/ng-map.min.js'></script>

is referencing a local asset. Check that this file is available to the production server.

Upvotes: 1

Related Questions