www.webdeveloper.com
Results 1 to 3 of 3

Thread: Javascript array

  1. #1
    Join Date
    Nov 2010
    Posts
    2

    Javascript array

    Hello. I'm having trouble with javascript arrays.

    I have written a function which gets geographic points into array of strings:

    Code:
    var pointList = new Array();
    
    function init(map) {
    ....
    pointList[pointList.length] = point.lng() + " " + point.lat();
    After this, pointList array has values like this "-21.232145354 54.23124323".
    Next i have another function which must construct a sql query element for geometry data:
    HTML Code:
    function updateGeometry()
    {
    	var geom = "GeomFromText('MULTIPOINT(";
    					
    	for(i=1; i<=pointList.length; i++) {
    		geom += pointList[i];
    		if (i != pointList.length) {
    			geom += ", ";
    		}
    	}
    					
    	geom += "), 4326)";
            Geometry.Update("#{ubikacijaHome.instance.ubikacijaId}", MULTIPOINT" , geom);
    }

    But, this part of code isn't working like it's supposed to. I get errors like:
    HTML Code:
    Error Parsing /UbikacijaEdit.xhtml: Error Traced[line: 146] The content of elements must consist of well-formed character data or markup.
    BTW, line 146 is that for loop with array length property, and I work with jboss server, seam framework, and xhtml pages.

    Any ideas what to do? Thx.

  2. #2
    Join Date
    Nov 2010
    Posts
    2
    OK. I managed to do it like this:

    Code:
    for (var i in pointList) {
        geom += pointList[i];
        if (i != pointList.length) {
    	geom += ", ";
        }
    }
    But now I have a different problem. Instead iterating only through all members of array, it goes through every other function as well, so i get string like this:

    Code:
    "GeomFromText('MULTIPOINT(-87.71408843575045 41.90917597761326, -87.67563628731295 41.90713192595488
    , -87.69142913399264 41.85805505291304, 
    function (C, B) { var A = 0; 
    try { this._each(function (E) {C.call(B, E, A++);}); 
    } catch (D) { if (D != $break) { throw D; } } 
    return this; }, "............
    Any help would be appreciated.

  3. #3
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Code:
    pointList.push(point.lng());
    pointList.push(point.lat());

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles