function updateNearbyLocations(event) {
    mapUpdating = true;
    var nw = curBounds.getNorthWest();
    var se = curBounds.getSouthEast();
    var locationsUrl = locationsBaseUrl;
    locationsUrl += '?$where=within_box(location,' + nw.lat + ',' + nw.lng + ',' + se.lat + ',' + se.lng + ')';
    locationsUrl += '&$$app_token=' + locationsApiToken;
    return $http.get(locationsUrl).success(displayLocations).error(updateNearbyLocationsError);

    function displayLocations(data) {
      data.forEach(function (vendor) {
        var lat = parseFloat(vendor.location.latitude);
        var lng = parseFloat(vendor.location.longitude);
        var name = vendor.vendor;
        var city = vendor.city;
        var zip = vendor.zip_code;
        var address = vendor.address;
        // Data has some weird ones where second address is just a space, double quotes and a space.
        if (vendor.second_address && vendor.second_address.indexOf('"') < 0) {
          address += ' ' + vendor.second_address;
        }
        address += ', ' + city + ' ' + zip;
        var message ='<h3>' + name + '</h3><p class="address">' + address + '</p><p class="directions"><a href="https://maps.google.com?saddr=Current+Location&daddr=' + address + '" target="_blank">Directions</a></p>';
        $scope.markers[keyify(name)] = {
          group: vendor.county,
          groupOption: { showCoverageOnHover: false },
          lat: lat,
          lng: lng,
          focus: false,
          message: message,
          icon: markerIcon
        }
      });
    }

    function updateNearbyLocationsError(data, status, headers, config) {
      NotificationService.addNotificiation({
        message: "Unable to load nearby locations.",
        status: NotificationService.STATUSES.ERROR
      })
    }

  }
/**
   * Update the map with nearby locations
   */
Update the map with nearby locations
Update the map with nearby locations
function updateNearbyLocations(event) {
    mapUpdating = true;
    var nw = curBounds.getNorthWest();
    var se = curBounds.getSouthEast();
    var locationsUrl = locationsBaseUrl;
    locationsUrl += '?$where=within_box(location,' + nw.lat + ',' + nw.lng + ',' + se.lat + ',' + se.lng + ')';
    locationsUrl += '&$$app_token=' + locationsApiToken;
    return $http.get(locationsUrl).success(displayLocations).error(updateNearbyLocationsError);
    function displayLocations(data) {
      data.forEach(function (vendor) {
        var lat = parseFloat(vendor.location.latitude);
        var lng = parseFloat(vendor.location.longitude);
        var name = vendor.vendor;
        var city = vendor.city;
        var zip = vendor.zip_code;
        var address = vendor.address;
        if (vendor.second_address && vendor.second_address.indexOf('"') < 0) {
          address += ' ' + vendor.second_address;
        }
        address += ', ' + city + ' ' + zip;
        var message ='<h3>' + name + '</h3><p class="address">' + address + '</p><p class="directions"><a href="https://maps.google.com?saddr=Current+Location&daddr=' + address + '" target="_blank">Directions</a></p>';
        $scope.markers[keyify(name)] = {
          group: vendor.county,
          groupOption: { showCoverageOnHover: false },
          lat: lat,
          lng: lng,
          focus: false,
          message: message,
          icon: markerIcon
        }
      });
    }
    function updateNearbyLocationsError(data, status, headers, config) {
      NotificationService.addNotificiation({
        message: "Unable to load nearby locations.",
        status: NotificationService.STATUSES.ERROR
      })
    }
  }
function updateNearbyLocations ( event ) { mapUpdating = true ; var nw = curBounds . getNorthWest ( ) ; var se = curBounds . getSouthEast ( ) ; var locationsUrl = locationsBaseUrl ; locationsUrl += '?$where=within_box(location,' + nw . lat + ',' + nw . lng + ',' + se . lat + ',' + se . lng + ')' ; locationsUrl += '&$$app_token=' + locationsApiToken ; return $http . get ( locationsUrl ) . success ( displayLocations ) . error ( updateNearbyLocationsError ) ; function displayLocations ( data ) { data . forEach ( function ( vendor ) { var lat = parseFloat ( vendor . location . latitude ) ; var lng = parseFloat ( vendor . location . longitude ) ; var name = vendor . vendor ; var city = vendor . city ; var zip = vendor . zip_code ; var address = vendor . address ; if ( vendor . second_address && vendor . second_address . indexOf ( '"' ) < 0 ) { address += ' ' + vendor . second_address ; } address += ', ' + city + ' ' + zip ; var message = '<h3>' + name + '</h3><p class="address">' + address + '</p><p class="directions"><a href="https://maps.google.com?saddr=Current+Location&daddr=' + address + '" target="_blank">Directions</a></p>' ; $scope . markers [ keyify ( name ) ] = { group : vendor . county , groupOption : { showCoverageOnHover : false } , lat : lat , lng : lng , focus : false , message : message , icon : markerIcon } } ) ; } function updateNearbyLocationsError ( data , status , headers , config ) { NotificationService . addNotificiation ( { message : "Unable to load nearby locations." , status : NotificationService . STATUSES . ERROR } ) } }
Update the map with nearby locations
Update the map with nearby locations
// Data has some weird ones where second address is just a space, double quotes and a space.