N
nemrac98
I have a piece of code which I would like to make a new object with a
different variable name everytime I loop through a for loop. Right now
I am using the same variable name and writing over it everytime but
before an iteration happens in the loop I save the object to an array.
The problem is it doesn't seem to be working. I am using OpenMap to
display a region so it could be something with OpenMap.
If I do:
RegionLayer region1 = new RegionLayer(layerArray);
RegionLayer region2 = new RegionLayer(layerArray);
RegionLayer region3 = new RegionLayer(layerArray);
mapHandler.add(region1);
mapHandler.add(region2);
mapHandler.add(region3);
...and then add them to the map one after the other it works fine and it
displays all three of the regions on the map.
However if I do something like the following:
for(int j = 0; j < numOfRegions; j++)
{
for(int i = 0; i < stop; i++)
{
***Make tempArray to send as argument to RegionLayer***
}
RegionLayer region = new RegionLayer(tempArray);
mapHandler.add(region);
}
This causes only the last region added to show up on my map. Any help
or advice is appreciated, I am still getting the hang of things. Thanks
in advance for any help!
different variable name everytime I loop through a for loop. Right now
I am using the same variable name and writing over it everytime but
before an iteration happens in the loop I save the object to an array.
The problem is it doesn't seem to be working. I am using OpenMap to
display a region so it could be something with OpenMap.
If I do:
RegionLayer region1 = new RegionLayer(layerArray);
RegionLayer region2 = new RegionLayer(layerArray);
RegionLayer region3 = new RegionLayer(layerArray);
mapHandler.add(region1);
mapHandler.add(region2);
mapHandler.add(region3);
...and then add them to the map one after the other it works fine and it
displays all three of the regions on the map.
However if I do something like the following:
for(int j = 0; j < numOfRegions; j++)
{
for(int i = 0; i < stop; i++)
{
***Make tempArray to send as argument to RegionLayer***
}
RegionLayer region = new RegionLayer(tempArray);
mapHandler.add(region);
}
This causes only the last region added to show up on my map. Any help
or advice is appreciated, I am still getting the hang of things. Thanks
in advance for any help!