jan_flanders

Untitled

Jun 2nd, 2012
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. protected var markersInfo:Dictionary = new Dictionary();
  2.  
  3. protected function getBusiness_resultHandler(event:ResultEvent):void
  4. {
  5.     var xml:XML = new XML(event.result as String);
  6.     businessList = xml.business;
  7.     for (var i:int=0; i<businessList.length(); i++)
  8.     {
  9.         var bm:Bitmap;
  10.         switch(businessList[i].type)
  11.         {
  12.             case "Hotel": bm = new Hotel as Bitmap; break;
  13.             case "Hostel": bm = new Hostel as Bitmap; break;
  14.             case "Pharmacy": bm = new Pharmacy as Bitmap; break;
  15.             case "Restaurant": bm = new Restaurant as Bitmap; break;
  16.             case "Supplies": bm = new Supplies as Bitmap; break;
  17.             case "Work": bm = new Work as Bitmap; break;
  18.             case "Bike": bm = new Bike as Bitmap; break;
  19.         }      
  20.         var latLng = new LatLng(businessList[i].latitude, businessList[i].longitude);
  21.         var options = new MarkerOptions({icon:bm, iconOffset: new Point (-23, -44)}));
  22.         var businessMarker:Marker = new Marker(latLng, options);
  23.         businessMarker.addEventListener(MapMouseEvent.CLICK, onMarkerClick):void
  24.         markersInfo[businessMarker] = businessList[i];
  25.         Map.addOverlay(businessMarker);
  26.     }
  27. }  
  28.  
  29. function onMarkerClick(e:MapMouseEvent):void
  30. {
  31.     var businessMarker:Marker = Marker(e.currentTarget);
  32.     var xml:XML = markersInfo[businessMarker];
  33.     detailName.text = xml.name;
  34.     detailStreet.text = xml.street;
  35.     detailCity.text = xml.city;
  36.     detailCountryPost.text = xml.country + ", " + xml.postcode;
  37.     detailPhonenumber.text = xml.phonenumber;
  38.     detailEmail.text = xml.email;
  39.     detailWebsite.text = xml.website;
  40.     detailDescription.text = xml.description;
  41.     detailDescription.visible=true;
  42.     descTitle.visible=true;
  43.     facebookURL = xml.facebookid;
  44.     twitterURL = xml.twitterid;
  45.     youtubeURL = xml.youtubeid;
  46.     flickrURL = xml.flickrid;
  47.     detailLogo.source = "/logos/" + xml.businessid + ".jpg";
  48.     detailLogo.visible=true;
  49.     var html:String = "<b>" + xml.name + "</b><br/>" + xml.street +
  50.     "<br/>" + xml.city + "<br/>" + xml.country + ", " + xml.postcode;
  51.     businessMarker.openInfoWindow(new InfoWindowOptions({contentHTML:html}));
  52.     emailDisplay();
  53.     websiteDisplay();
  54.     facebookIcon();
  55.     twitterIcon();
  56.     youtubeIcon();
  57.     flickrIcon();
  58. }
  59.  
  60. private function toggleHotel():void
  61. {
  62.     for(businessMarker in markersInfo)
  63.     {
  64.         if(businessMarker.type=="Hotel")
  65.         {
  66.             businessMarker.visible = !marker.visible;
  67.         }
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment