Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 2nd, 2012  |  syntax: ActionScript 3  |  size: 4.24 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.         // This here just assigns an image to each marker based on type, then it prints the marker and when I click the marker it sets off a function to display the information in the tab below the map.
  2. protected function getBusiness_resultHandler(event:ResultEvent):void
  3.                         {
  4.                                 var xml:XML = new XML(event.result as String);
  5.                                 //businessListCol = new XMLListCollection (xml.business);
  6.                                 businessList = xml.business;
  7.                                
  8.                                
  9.                                 for (var i:int=0; i<businessList.length(); i++)
  10.                                 {
  11.                                        
  12.                                         if (businessList[i].type=="Hotel")
  13.                                         {
  14.                                                 var bm:Bitmap = new Hotel as Bitmap;
  15.                                         }
  16.                                         else if (businessList[i].type=="Hostel")
  17.                                         {
  18.                                                 var bm:Bitmap = new Hostel as Bitmap;
  19.                                         }
  20.                                         else if (businessList[i].type=="Pharmacy")
  21.                                         {
  22.                                                 var bm:Bitmap = new Pharmacy as Bitmap;
  23.                                         }
  24.                                         else if (businessList[i].type=="Restaurant")
  25.                                         {
  26.                                                 var bm:Bitmap = new Restaurant as Bitmap;
  27.                                         }
  28.                                         else if (businessList[i].type=="Supplies")
  29.                                         {
  30.                                                 var bm:Bitmap = new Supplies as Bitmap;
  31.                                         }
  32.                                         else if (businessList[i].type=="Work")
  33.                                         {
  34.                                                 var bm:Bitmap = new Work as Bitmap;
  35.                                         }
  36.                                         else
  37.                                         {
  38.                                                 var bm:Bitmap = new Bike as Bitmap;
  39.                                         }
  40.                                        
  41.                                         var html:String = "<b>" + businessList[i].name + "</b><br/>" + businessList[i].street + "<br/>" + businessList[i].city + "<br/>" + businessList[i].country + ", " + businessList[i].postcode;
  42.                                         var imageURL:String;
  43.                                         var imageURL2:String;
  44.                                        
  45.                                         var businessMarker:Marker = new Marker(new LatLng(businessList[i].latitude,businessList[i].longitude),
  46.                                                 new MarkerOptions({icon:bm, iconOffset: new Point (-23, -44)}));
  47.                                         businessMarker.addEventListener(MapMouseEvent.CLICK, function(e:MapMouseEvent):void {
  48.                                                 Marker(e.currentTarget).openInfoWindow(new InfoWindowOptions({contentHTML:htmlDict[e.currentTarget]}));
  49.                                                 detailName.text = nameDict[e.currentTarget];
  50.                                                 detailStreet.text = streetDict[e.currentTarget];
  51.                                                 detailCity.text = cityDict[e.currentTarget];
  52.                                                 detailCountryPost.text = countryDict[e.currentTarget];
  53.                                                 detailPhonenumber.text = phonenumberDict[e.currentTarget];
  54.                                                 detailEmail.text = emailDict[e.currentTarget];
  55.                                                 detailWebsite.text = websiteDict[e.currentTarget];
  56.                                                 detailDescription.text = descriptionDict[e.currentTarget];
  57.                                                 detailDescription.visible=true;
  58.                                                 descTitle.visible=true;
  59.                                                 facebookURL = facebookidDict[e.currentTarget];
  60.                                                 twitterURL = twitteridDict[e.currentTarget];
  61.                                                 youtubeURL = youtubeidDict[e.currentTarget];
  62.                                                 flickrURL = flickridDict[e.currentTarget];
  63.                                                 imageURL = idDict[e.currentTarget];
  64.                                                 detailLogo.source = "/logos/" + imageURL + ".jpg";
  65.                                                 detailLogo.visible=true;
  66.                                                 emailDisplay();
  67.                                                 websiteDisplay();
  68.                                                 facebookIcon();
  69.                                                 twitterIcon();
  70.                                                 youtubeIcon();
  71.                                                 flickrIcon();
  72.                                                
  73.                                         });
  74.                                         htmlDict[businessMarker] = html;
  75.                                         idDict[businessMarker] = businessList[i].businessid;
  76.                                         typeDict[businessMarker] = businessList[i].type;
  77.                                         nameDict[businessMarker] = businessList[i].name;
  78.                                         streetDict[businessMarker] = businessList[i].street;
  79.                                         cityDict[businessMarker] = businessList[i].city;
  80.                                         countryDict[businessMarker] = businessList[i].country + ", " + businessList[i].postcode;
  81.                                         phonenumberDict[businessMarker] = businessList[i].phonenumber;
  82.                                         emailDict[businessMarker] = businessList[i].email;
  83.                                         websiteDict[businessMarker] = businessList[i].website;
  84.                                         descriptionDict[businessMarker] = businessList[i].description;
  85.                                         facebookidDict[businessMarker] = businessList[i].facebookid;
  86.                                         twitteridDict[businessMarker] = businessList[i].twitterid;
  87.                                         youtubeidDict[businessMarker] = businessList[i].youtubeid;
  88.                                         flickridDict[businessMarker] = businessList[i].flickrid;
  89.  
  90.                                         Map.addOverlay(businessMarker);
  91.                                 }
  92.                                
  93.                         }
  94.  
  95. //Here is the function that I will call when a box changes. For the moment I'm doing a function just for Hotel check box, but later I may get all check boxes to call the function and just pass the value 'Hotel' etc
  96.  
  97. private function toggleHotel():void {
  98.                                 for (var i:Number = 0; i < *******; i++) {
  99.                                        
  100.                                         if (!marker.visible) {
  101.                                                 marker.visible = true;
  102.                                         } else {
  103.                                                 marker.visible = false;
  104.                                         }
  105.                                 }