linguisticexplorer/Linguistic-Explorer

View on GitHub
public/javascripts/gmaps4rails/gmaps4rails.mapquest.js

Summary

Maintainability
F
4 days
Test Coverage
(function() {
  var __hasProp = Object.prototype.hasOwnProperty,
    __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };

  this.Gmaps4RailsMapquest = (function(_super) {

    __extends(Gmaps4RailsMapquest, _super);

    function Gmaps4RailsMapquest() {
      Gmaps4RailsMapquest.__super__.constructor.apply(this, arguments);
      this.map_options = {
        type: "map"
      };
      this.markers_conf = {};
      this.mergeWithDefault("markers_conf");
      this.mergeWithDefault("map_options");
    }

    Gmaps4RailsMapquest.prototype.createPoint = function(lat, lng) {
      return new MQA.Poi({
        lat: lat,
        lng: lng
      });
    };

    Gmaps4RailsMapquest.prototype.createLatLng = function(lat, lng) {
      return {
        lat: lat,
        lng: lng
      };
    };

    Gmaps4RailsMapquest.prototype.createLatLngBounds = function() {};

    Gmaps4RailsMapquest.prototype.createMap = function() {
      var map;
      map = new MQA.TileMap(document.getElementById(this.map_options.id), this.map_options.zoom, {
        lat: this.map_options.center_latitude,
        lng: this.map_options.center_longitude
      }, this.map_options.type);
      MQA.withModule('zoomcontrol3', (function() {
        return map.addControl(new MQA.LargeZoomControl3(), new MQA.MapCornerPlacement(MQA.MapCorner.TOP_LEFT));
      }));
      return map;
    };

    Gmaps4RailsMapquest.prototype.createMarkerImage = function(markerPicture, markerSize, origin, anchor, scaledSize) {};

    Gmaps4RailsMapquest.prototype.createMarker = function(args) {
      var icon, marker;
      marker = new MQA.Poi({
        lat: args.Lat,
        lng: args.Lng
      });
      if (args.marker_picture !== "") {
        icon = new MQA.Icon(args.marker_picture, args.marker_height, args.marker_width);
        marker.setIcon(icon);
        if (args.marker_anchor !== null) {
          marker.setBias({
            x: args.marker_anchor[0],
            y: args.marker_anchor[1]
          });
        }
      }
      if (args.shadow_picture !== "") {
        icon = new MQA.Icon(args.shadow_picture, args.shadow_height, args.shadow_width);
        marker.setShadow(icon);
        if (args.shadow_anchor !== null) {
          marker.setShadowOffset({
            x: args.shadow_anchor[0],
            y: args.shadow_anchor[1]
          });
        }
      }
      this.addToMap(marker);
      return marker;
    };

    Gmaps4RailsMapquest.prototype.clearMarkers = function() {
      var marker, _i, _len, _results;
      _results = [];
      for (_i = 0, _len = markers.length; _i < _len; _i++) {
        marker = markers[_i];
        _results.push(this.clearMarker(marker));
      }
      return _results;
    };

    Gmaps4RailsMapquest.prototype.showMarkers = function() {
      var marker, _i, _len, _results;
      _results = [];
      for (_i = 0, _len = markers.length; _i < _len; _i++) {
        marker = markers[_i];
        _results.push(this.showMarker(marker));
      }
      return _results;
    };

    Gmaps4RailsMapquest.prototype.hideMarkers = function() {
      var marker, _i, _len, _results;
      _results = [];
      for (_i = 0, _len = markers.length; _i < _len; _i++) {
        marker = markers[_i];
        _results.push(this.hideMarker(marker));
      }
      return _results;
    };

    Gmaps4RailsMapquest.prototype.clearMarker = function(marker) {
      return this.removeFromMap(marker.serviceObject);
    };

    Gmaps4RailsMapquest.prototype.showMarker = function(marker) {};

    Gmaps4RailsMapquest.prototype.hideMarker = function(marker) {};

    Gmaps4RailsMapquest.prototype.extendBoundsWithMarkers = function() {
      var marker, _i, _len, _ref, _results;
      if (this.markers.length >= 2) {
        this.boundsObject = new MQA.RectLL(this.markers[0].serviceObject.latLng, this.markers[1].serviceObject.latLng);
        _ref = this.markers;
        _results = [];
        for (_i = 0, _len = _ref.length; _i < _len; _i++) {
          marker = _ref[_i];
          _results.push(this.boundsObject.extend(marker.serviceObject.latLng));
        }
        return _results;
      }
    };

    Gmaps4RailsMapquest.prototype.createClusterer = function(markers_array) {};

    Gmaps4RailsMapquest.prototype.clearClusterer = function() {};

    Gmaps4RailsMapquest.prototype.clusterize = function() {};

    Gmaps4RailsMapquest.prototype.createInfoWindow = function(marker_container) {
      return marker_container.serviceObject.setInfoTitleHTML(marker_container.description);
    };

    Gmaps4RailsMapquest.prototype.fitBounds = function() {
      if (this.markers.length >= 2) {
        this.serviceObject.zoomToRect(this.boundsObject);
      }
      if (this.markers.length === 1) {
        return this.serviceObject.setCenter(this.markers[0].serviceObject.latLng);
      }
    };

    Gmaps4RailsMapquest.prototype.centerMapOnUser = function() {
      return this.serviceObject.setCenter(this.userLocation);
    };

    Gmaps4RailsMapquest.prototype.addToMap = function(object) {
      return this.serviceObject.addShape(object);
    };

    Gmaps4RailsMapquest.prototype.removeFromMap = function(object) {
      return this.serviceObject.removeShape(object);
    };

    return Gmaps4RailsMapquest;

  })(Gmaps4Rails);

}).call(this);