Graphics Programs Reference
In-Depth Information
In the MarkersClip() constructor, store the variables that will be passed to
the class and compute a few things such as time per year and coordinates
for stores. You can think of this as the setup.
The storesPerYear variable stores how many stores opened during a given
year. For example, one store opened the first year, and no stores opened
the next. When you use this code with your own data, you need to update
storesPerYear appropriately. You could also write a function that com-
putes stores or location openings per year to increase the reusability of
your code. A hard-coded array is specified in this example for the sake of
simplicity.
this.map = map;
this.x = map.getWidth() / 2;
this.y = map.getHeight() / 2;
this.locations = locations;
setPoints();
setMarkers();
this.openingDates = openingDates;
var tempIndex:int = 0;
storesPerYear = [1,0,1,1,0,2,5,5,5,15,17,19,25,19,27,
39,34,43,54,150,63,87,99,110,121,142,125,131,178,
163,138,156,107,129,53,60,66,80,105,106,114,96,
130,118,37];
timePerYear = totalTime / storesPerYear.length;
There are two other functions in the MarkersClip class: setPoints() and
setMarkers() . The first one translates latitude and longitude coordinates
to x- and y-coordinates, and the second function places the markers on
the map without actually showing them. Following is the definition for
setPoints() . It uses a built-in function provided by Modest Maps to calcu-
late x and y and then stores the new coordinates in xpoints and ypoints .
public function setPoints():void {
if (locations == null) {
return;
}
Search WWH ::




Custom Search