Click here to Skip to main content
15,851,387 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I want to plot polygon(triangle)from excel sheet having 3 consecutive rows with its column 1 and 2 have same coordinates values and next 3 rows have different values with column 1 and 2 but this code is not reading this sheet and showing error "Line:929 Error:Number expected".

But when i am reading sheet having all rows have different values with column 1 and 2 so its running well.

Plz can anyone solve this error.

Thanks in advance


HTML
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> 
  <head> 
    <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
    <title>Google Maps API Sample</title> 
    <<script src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=ABQIAAAA1XbMiDxx_BTCY2_FkPh06RRaGTYH6UMl8mADNa0YKuWNNa8VNxQEerTAUcfkyrr6OwBovxn7TDAH5Q" type="text/javascript"></script> 
    <script type="text/javascript"> 

document.write("<pre>");
function initialize() {
array=new Array() 
var Excel; 
Excel = new ActiveXObject("Excel.Application"); 
Excel.Visible = false; 
var a=Excel.Workbooks.Open("C:/desktop/Book1.xlsx").sheets(1);
for(var r=1;r<=a.usedrange.rows.count;r++) 
{
array[r-1]=new Array() 
for(var c=1;c<=a.usedrange.columns.count;c++) 
array[r-1][c-1]=a.Cells(r,c).Value;
} 
var x=0,y=0,p1=0,p2=0; 
for(len in array) 
{
x+=array[len][1]; 
y+=array[len][2];
} 
p1=(x/array.length); 
p2=(y/array.length); 
  if (GBrowserIsCompatible()) {
    var map = new GMap2(document.getElementById("map_canvas"));
    map.setCenter(new GLatLng(p1,p2), 3);
    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());
map.addControl(new GMapTypeControl());  

for(m=0;m<array.length;m++)>
{

      var lat =array[m][1];
      var lon = array[m][2];
      var latOffset = 0.5;
      var lonOffset = 2;
      var latOffset2 = 0.5;
      var lonOffset2 = 2;
   	  var polygon = new GPolygon([
        new GLatLng(lat , lon ),
        new GLatLng(lat - latOffset2, lon + (lonOffset-1)),
        new GLatLng(lat - latOffset2, lon - (lonOffset-1)),
        new GLatLng(lat , lon ),
 ], "#ff0000", 0.1 , 0.9, "#ff0000", 0.9);

map.addOverlay(polygon);
       
       m++;
       lat=array[m][1];
       lon=array[m][2];   
    
        var polygon2 = new GPolygon([
        new GLatLng ( lat, lon),
        new GLatLng(lat ,lon + lonOffset2),
        new GLatLng(lat + latOffset,lon + lonOffset2),
        new GLatLng(lat,lon),
 ], "#f33f00", 0.1 , 0.9, "#f33f00", 0.9);
  map.addOverlay(polygon2);
    
        m++;
       lat=array[m][1];
       lon=array[m][2];        
       var polygon3 = new GPolygon([
        new GLatLng( lat, lon),
        new GLatLng( lat, lon - lonOffset2),
        new GLatLng( lat + latOffset, lon - lonOffset2),
        new GLatLng( lat ,lon),


     
  ], "#0000ff", 0.1 , 0.9, "#0000ff", 0.9);
  map.addOverlay(polygon3);

}
  }

}

document.write("</pre>");
</script> 
  </head> 
  <body onload="initialize()" onunload="GUnload()" style="font-family: Arial;border: 0 none;"> 
    <div id="map_canvas" style="width: 1000px; height: 900px">
    </div> 
  </body> 
</html>
Posted
Updated 14-Jul-10 2:58am
v2
Comments
Sandeep Mewara 14-Jul-10 8:31am    
Did you used DEBUGGER and checked the line where this error is thrown?
If you are unable to get then, higlight the line that throws this error here.

1 solution

use debugger keyword to debug your javascript to know the exact error.

Eg : Write the code below, from the point where ever u want to debug the script.

debugger; 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900