×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Nokia Developer Expert
    Join Date
    Jul 2013
    Posts
    4

    How to avoid script errors with many locations

    Hi,
    I am working on a tool using the JavaScript API, but I am experiencing that the browser gives me errors/warnings that the script is running to long when there are many locations to display.
    Sometimes, there are 1000+ locations to display and the more locations, the higher the risk in getting these errors.

    Are there maybe other ways in how to get this speeded up?

    Thanks
    Micha

  2. #2
    Regular Contributor
    Join Date
    Aug 2011
    Location
    Berlin
    Posts
    288

    Re: How to avoid script errors with many locations

    The error message you are getting is what is known as a runaway script dialog, which is a function of the browser rather than the API. In a nutshell it means that the JavaScript code you are using is taking too long to complete so the next update of the visuals on the screen is blocked. Usually the timeout for these errors can be configured on the browser, but this isn't much use if you are writing a public facing site.

    You will need to split up the processor intensive code into a series of smaller chunks so that you can schedule these updates asynchronously - a simple example using setTimeout() can be found here: http://jsfiddle.net/Detect/HnpCr/3/. The code for a simple map marker based example using setTimeout() can be found here, however this solution isn't optimal since the API itself offers a more elegant way of doing this using coroutines as explained in the article here

    It is highly improbable that any user would be able to distinguish the location of more than 50 markers on the map, let alone more than 1000, so the usual workaround in these cases is to use marker clustering - this only displays a fraction of the set of markers at any one time. Even marker clustering can breakdown with extremely large data sets (since the JavaScript API is a client-side library) and in these cases you would need to investigate the use of a server-side clustering algorithm (as explained in this Java ME article here - the principles are still valid for web development though). The final strategy if all else fails, is to replace your data set with an overlay .
    Last edited by jasfox; 2013-07-08 at 11:51.

Similar Threads

  1. Replies: 4
    Last Post: 2010-06-15, 13:52
  2. Files storage locations
    By jim416 in forum Mobile Java General
    Replies: 2
    Last Post: 2010-04-23, 08:14
  3. Replies: 24
    Last Post: 2010-02-17, 14:29
  4. Can a Python script call a Perl script?
    By xhsoldier in forum Symbian
    Replies: 1
    Last Post: 2009-02-11, 10:04
  5. About bitmaps Locations
    By pistha in forum Symbian
    Replies: 3
    Last Post: 2008-03-11, 10:47

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×