Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6702753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:05:26+00:00 2026-05-26T07:05:26+00:00

I’m creating a project using Polymaps JS lybrary. I have to plot about 200,000

  • 0

I’m creating a project using Polymaps JS lybrary. I have to plot about 200,000 points. It takes a while to load the points into the browser and then navigazion is very sluggish.

I’ve read the documentation and there’s no option for filtering a GeoJson before adding its data to the page.

Can someone suggest a better way then this:

var po = org.polymaps;
var map = po.map()
.container(document.body.appendChild(po.svg("svg")))
.center({lat: 45.468318, lon: 9.1709})
.zoom(13)
.add(po.interact());

//Skinning the map
map.add(po.image()
.url(po.url("http://{S}tile.cloudmade.com"
+ "/1a1b06b230af4efdbb989ea99e9841af" // http://cloudmade.com/register
+ "/998/256/{Z}/{X}/{Y}.png")
.hosts(["a.", "b.", "c.", ""])));

//Importing the geoJSON
map.add(po.geoJson()
.url("test_4sq.json")
.id("streets")
.on("load", loadAreas)
.tile(false));

map.add(po.compass()
.pan("none"));

// This function loads all the data and then do the filtering (very sluggish method) 
function loadAreas(obj) {
for (var i = 0; i < obj.features.length; i++) {
    var f = obj.features[i];
    var e = obj.features[i].element;
    var p = obj.features[i].data.properties;
    e.setAttribute('r', 4);
    e.setAttribute('id', f.data.id);
    e.setAttribute('title', p.venueName);
    //console.log(e);

    // Displaying the data in August (month propriety = '8')
    if (p.month != "08")
         console.log(e); 
    else 
        e.setAttribute('display', 'none');
} 
} 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:05:26+00:00Added an answer on May 26, 2026 at 7:05 am

    I figured out how to make the script faster.
    First of all launching the app via localhost or server makes all work faster.
    I always open the app via file (file:///pathTo_file/index.html)! That’s WRONG. It’s better use a server instead (www.pathTo_file.com/ or localhost://pathTo_file/index.html)
    Second, I tried to minify the imported json. I leaved a lot of spaces and line breaks for better readability, but It’ was quite heavy to load so I removed all this useless characters.
    Third, I load a file only if a user use the daypicker. In this way the app loads all the tiles first and in a second time the user chosen data.

    Here is a sample of the code if somone is interested.

    $(document).ready(function() {
    
    
    
    // DAY AND MONTH CORRECTION RELATED TO FILENAME
    function addZero(num){
        console.log("Function launched: addZero")
        parseInt(num);
        if(num>=1 && num<=9){
                num="0"+num;
        }   
        return num;
    } 
    
    $("#datepicker").datepicker({
        dateFormat: 'yy/mm/dd',
        inline: true,
        minDate: new Date(2011, 8 - 1, 20),
        maxDate:new Date(2011, 12 - 1, 31),
        altField: '#datepicker_value',
          onSelect: function(){
            var selDay = $("#datepicker").datepicker('getDate').getDate();                 
            var selMonth = $("#datepicker").datepicker('getDate').getMonth() + 1;             
            var selYear = $("#datepicker").datepicker('getDate').getFullYear();
    
    
    //PLOTTING THE MAP WITH THE USER'S SELECTION - DATEPICKER PARAMETERS -
    plotMap(addZero(selDay), addZero(selMonth));
        }
    });
    //INITIALISATING THE DATEPICKER 
    $("#datepicker").datepicker('setDate', new Date());
    
    
        // JSON DATA IMPORT
        var po = org.polymaps;
        var map = po.map()
                .container(document.body.appendChild(po.svg("svg")))
                .center({lat: 45.468318, lon: 9.1709})
                .zoom(13)
                .add(po.interact());
    
        map.add(po.image()
                .url(po.url("http://{S}tile.cloudmade.com"
                + "/1a1b06b230af4efdbb989ea99e9841af" // http://cloudmade.com/register
                + "/998/256/{Z}/{X}/{Y}.png")
                .hosts(["a.", "b.", "c.", ""])));
    
        function plotMap(day, month){
            var jsonUrl = "json/4sq_"+day+"_"+month+"_min.json";
            map.add(po.geoJson()
                .url(jsonUrl)
                .on("load", loadSingleEvents));
    
                console.log("Ho caricato il file:" + jsonUrl);
        };
    
    
        map.add(po.compass()
                .pan("none"));
    
    
    //LOADING THE DATA
        function loadSingleEvents(obj) {
            console.log("Function launched: loadSingleEvents")
            singleEvents=true;
    
            $.each (obj.features, function (i, feat){
                var point = feat.element;
                var propriety = feat.data.properties;
                point.setAttribute('r', 3.5);
                point.setAttribute('id', feat.data.id);
                point.setAttribute('data-venueName', propriety.venueName);
                point.setAttribute('data-hour', propriety.hour);        
            }); 
            console.log("Numero di Elementi visualizzati: (dovrebbe essere sui 3500) "+ obj.features.length);           
    
        }
    
    
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have thousands of HTML files to process using Groovy/Java and I need to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
this is what i have right now Drawing an RSS feed into the php,
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.