I have written the javascript code for client side using Google Map API that is running well when i am reading excel sheet having 170 rows but when i tried to run it on excel having 237 rows so it gives error in the array "farah[...]5 is null or not an object",then i ok to debugg but debugger doesn't show anything and map opens but as i want to plot polygon doesn't appears.The same code is showing polygons well for excel of 170 rows.
In the excel sheet,i used latitude value in col 3 and longitude value in col 2,ID is in col 5 for which i want to store values and plot polygon is after col 6 and onwards.
Below is my code.Please can anyone solve this problem.
<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() {
farah=new Array()
samrah=new Array()
var Excel;
Excel = new ActiveXObject("Excel.Application");
Excel.Visible = false;
var a=Excel.Workbooks.Open("C:/desktop/Book5.xlsx").sheets(1);
for(var r=1;r<=a.usedrange.rows.count;r++)
{
farah[r-1]=new Array()
for(var c=1;c<=a.usedrange.columns.count;c++)
farah[r-1][c-1]=a.Cells(r,c).Value;
}
n=prompt("ENTER THE ID","");
var x,y,a;
for(a=1;a<farah.length;a++)
{if(n==farah[a][5])
{x=farah[a][1];
y=farah[a][2];}}
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(y,x), 15);
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.addControl(new GMapTypeControl());
for(m=1;m<farah.length;m++)
{
bsc=farah[m][5];
if(n==bsc)
{
samrah=new Array()
u=0;y=6;
if(farah[m][6]!=null)
{
do
{samrah[u]=farah[m][y];
u++;
y++;
}
while(farah[m][y]!=null);
u--;
}
}
m++;
bsc1=farah[m][5];
if(n==bsc1)
{
samrah=new Array()
u=0;y=6;
if(farah[m][6]!=null)
{
do
{samrah[u]=farah[m][y];
u++;
y++;
}
while(farah[m][y]!=null);
u--;
}}
m++
bsc2=farah[m][5];
if(n==bsc2)
{
samrah=new Array()
u=0;y=6;
if(farah[m][6]!=null)
{
do
{samrah[u]=farah[m][y];
u++;
y++;
}
while(farah[m][y]!=null);
u--;
}}
}
for(t=1;t<farah.length;t++)
{cell=farah[t][5]
for(j=0;j<samrah.length;j++)
{
if(samrah[j]==cell)
{
c3=farah[t][0];
lat =farah[t][2];
lon = farah[t][1];
var latOffset = 0.05;
var lonOffset = 1;
var latOffset2 = 0.05;
var lonOffset2 = 1;
switch(c3)
{
case "1":
{polygon = new GPolygon([
new GLatLng(lat , lon ),
new GLatLng(lat - (latOffset2-0.049), lon + (lonOffset-0.9995)),
new GLatLng(lat - (latOffset2-0.049), lon - (lonOffset-0.9995)),
new GLatLng(lat , lon ),
], "0x987654", 0.1 , 0.9, "0x987654", 0.9);
map.addOverlay(polygon);
break;}
case "2":
{polygon2 = new GPolygon([
new GLatLng ( lat, lon),
new GLatLng(lat ,lon + (lonOffset2-0.999)),
new GLatLng(lat + (latOffset-0.049),lon + (lonOffset2-0.999)),
new GLatLng(lat,lon),
], "0x987654", 0.1 , 0.9, "0x987654", 0.9);
map.addOverlay(polygon2);
break;}
default:
{polygon3 = new GPolygon([
new GLatLng( lat, lon),
new GLatLng( lat, lon - (lonOffset2-0.999)),
new GLatLng( lat + (latOffset-0.049), lon - (lonOffset2-0.999)),
new GLatLng( lat ,lon),
], "0x987654", 0.1 , 0.9, "0x987654", 0.9);
map.addOverlay(polygon3);
break;}}
}
}
}
}
}
</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>