Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you're adamant about your geocoordinates service returning <code>Marker</code>s instead of geocoordinates, then you have two options that I can think of:</p> <p>a) Pass the map to the geocoordinates service</p> <pre><code>angular.module('mapGuy', function($scope, geoService) { geoService.addMarkers($scope.map); }). factory('geoService', function($http) { var addMarkers = function(map) { $http.get('/path/to/geo/server').success(function(points) { angular.forEach(points, function(points) { new google.maps.Marker({ map: map, position: new google.maps.LatLng(points.lat, points.long) }) }) }); }; return { addMarkers: addMarkers }; }); </code></pre> <p>b) Stick the map on the module's <code>$rootScope</code> and inject <code>$rootScope</code> into the service</p> <pre><code>angular.module('mapGuy', function($scope, $rootScope, geoService) { $rootScope.map = $scope.map; geoService.addMarkers(); }). factory('geoService', function($http, $rootScope) { var addMarkers = function() { $http.get('/path/to/geo/server').success(function(points) { angular.forEach(points, function(points) { new google.maps.Marker({ map: $rootScope.map, position: new google.maps.LatLng(points.lat, points.long) }) }) }); }; return { addMarkers: addMarkers }; }); </code></pre> <p>That's a rough sketch of what the code could look like. I'm pulling Google Maps API from memory, but hopefully this helps you get the idea.</p> <p>I think the first option is preferable, but it's hard to say since you didn't provide a lot of context to work with.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload