JQuery:集合数组长度上限为100

时间:2015-01-08 13:24:37

标签: javascript jquery google-maps splunk

我使用Splunk Web Framework和Google Maps应用创建自定义地图实现。我看到的问题是,当我将splunk搜索结果信息发送到google maps js时,它会将我的行限制为100.有人可以查看下面的代码并查看是否有任何可能导致数组的地方上限为100?

/** @license
 * RequireJS plugin for async dependency load like JSONP and Google Maps
 * Author: Miller Medeiros
 * Version: 0.1.1 (2011/11/17)
 * Released under the MIT license
 */
define('async',[],function(){

    var DEFAULT_PARAM_NAME = 'callback',
        _uid = 0;

    function injectScript(src){
        var s, t;
        s = document.createElement('script'); s.type = 'text/javascript'; s.async = true; s.src = src;
        t = document.getElementsByTagName('script')[0]; t.parentNode.insertBefore(s,t);
    }

    function formatUrl(name, id){
        var paramRegex = /!(.+)/,
            url = name.replace(paramRegex, ''),
            param = (paramRegex.test(name))? name.replace(/.+!/, '') : DEFAULT_PARAM_NAME;
        url += (url.indexOf('?') < 0)? '?' : '&';
        return url + param +'='+ id;
    }

    function uid() {
        _uid += 1;
        return '__async_req_'+ _uid +'__';
    }

    return{
        load : function(name, req, onLoad, config){
            if(config.isBuild){
                onLoad(null); //avoid errors on the optimizer
            }else{
                var id = uid();
                window[id] = onLoad; //create a global variable that stores onLoad so callback function can define new module after async load
                injectScript(formatUrl(name, id));
            }
        }
    };
});
requirejs.s.contexts._.nextTick = function(f){f()}; require(['css'], function(css) { css.addBuffer('splunkjs/css/googlemap.css'); }); requirejs.s.contexts._.nextTick = requirejs.nextTick;
define('splunkjs/mvc/googlemapview',['require','exports','module','underscore','./mvc','./basesplunkview','./messages','async!http://maps.googleapis.com/maps/api/js?sensor=false','css!../css/googlemap.css'],function(require, exports, module) {
    var _ = require('underscore');
    var mvc = require('./mvc');
    var BaseSplunkView = require("./basesplunkview");
    var Messages = require("./messages");

    require("async!http://maps.googleapis.com/maps/api/js?sensor=false");
    require("css!../css/googlemap.css");

    var GoogleMapView = BaseSplunkView.extend({
        moduleId: module.id,

        className: "splunk-googlemap",

        options: {
            managerid: null,
            data: "preview"
        },

        initialize: function() {
            this.configure();

            this.bindToComponentSetting('managerid', this._onManagerChange, this);

            this.map = null;
            this.markers = [];

            // If we don't have a manager by this point, then we're going to
            // kick the manager change machinery so that it does whatever is
            // necessary when no manager is present.
            if (!this.manager) {
                this._onManagerChange(mvc.Components, null);
            }
        },

        _onManagerChange: function(managers, manager) {
            if (this.manager) {
                this.manager.off(null, null, this);
                this.manager = nul=]=]l;
            }
=]==            if (this.resultsModel) {
 =               this.resultsModel.off(null, null, this);
                this.resultsModel.destroy();
                this.resultsModel = null;
            }

            if (!manager) {
                this.message('no-search');
                return;
            }

            // Clear any messages, since we have a new manager.
            this.message("empty");

            this.manager = manager;            
            this.resultsModel = manager.data(this.settings.get("data"), {
                output_mode: "json_rows"
            });
            manager.on("search:start", this._onSearchStart, this);
            manager.on("search:progress", this._onSearchProgress, this);
            manager.on("search:cancelled", this._onSearchCancelled, this);
            manager.on("search:error", this._onSearchError, this);
            this.resultsModel.on("data", this.render, this);
            this.resultsModel.on("error", this._onSearchError, this);

            manager.replayLastSearchEvent(this);
        },

        _onSearchCancelled: function() { 
            this._isJobDone = false;
            this.message('cancelled');
        },

        _onSearchError: function(message, err) {
            this._isJobDone = false;
            var msg = message;
            if (err && err.data && err.data.messages && err.data.messages.length) {
                msg = _(err.data.messages).pluck('text').join('; ');
            }
            this.message({
                level: "error",
                icon: "warning-sign",
                message: msg
            });
        },

        _onSearchProgress: function(properties) {
            properties = properties || {};
            var content = properties.content || {};
            var previewCount = content.resultPreviewCount || 0;
            var isJobDone = this._isJobDone = content.isDone || false;

            if (previewCount === 0 && isJobDone) {
                this.message('no-results');
                return;
            }

            if (previewCount === 0) {
                this.message('waiting');
                return;
            }
        },

        _onSearchStart: function() { 
            this._isJobDone = false;
            this.message('waiting');
        },

        clearMarkers: function() {
            var count = this.markers.length;
            for (var i = 0; i < count; ++i)
                this.markers[i].setMap(null);
            this.markers.length = 0;
        },

        createMap: function() {
            this.map = new google.maps.Map(this.el, {
                center: new google.maps.LatLng(47.60, -122.32),
                zoom: 2,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            });
            this.map.setOptions(this.options);
        },

        message: function(info) {
            this.map = null;
            Messages.render(info, this.$el);
        },

        render: function() {
            if (!this.manager) {
                return;
            }

            if (!this.resultsModel || !this.resultsModel.hasData()) {
                if (this.resultsModel && !this.resultsModel.hasData() && this._isJobDone) {
                    this.message("no-results");
                }
                return this;
            }

            if (!this.map) {
                this.createMap();
            }

            var that = this;
            this.clearMarkers();
            this.resultsModel.collection().each(function(row) {
                var lat = parseFloat(row.get("lat"));
                var lng = parseFloat(row.get("lng"));
                var latlng = new google.maps.LatLng(lat, lng);
                var marker = new google.maps.Marker({
                    position: latlng,
                    map: that.map
                });
                that.markers.push(marker);
            });

            return this;
        }
    });

    return GoogleMapView;
});

requirejs.s.contexts._.nextTick = function(f){f()}; require(['css'], function(css) { css.setBuffer('/*  */\n\n/* Bootstrap Css Map Fix*/\n.splunk-googlemap img { \n  max-width: none;\n}\n/* Bootstrap Css Map Fix*/\n.splunk-googlemap label { \n  width: auto; \n  display:inline; \n} \n/* Set a small height on the map so that it shows up*/\n.splunk-googlemap {\n    min-height: 100px;\n    height: 100%;\n}\n'); }); requirejs.s.contexts._.nextTick = requirejs.nextTick; 

1 个答案:

答案 0 :(得分:-1)

从快速搜索来看,它似乎可能是100英寸的splunk上限?

请参阅http://answers.splunk.com/answers/52782/100-result-limit-in-js-sdk.html