SHOW:
|
|
- or go back to the newest paste.
| 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. |
| 1 | + | protected var markersInfo:Dictionary = new Dictionary(); |
| 2 | ||
| 3 | - | {
|
| 3 | + | |
| 4 | - | var xml:XML = new XML(event.result as String); |
| 4 | + | {
|
| 5 | - | //businessListCol = new XMLListCollection (xml.business); |
| 5 | + | var xml:XML = new XML(event.result as String); |
| 6 | - | businessList = xml.business; |
| 6 | + | businessList = xml.business; |
| 7 | - | |
| 7 | + | for (var i:int=0; i<businessList.length(); i++) |
| 8 | - | |
| 8 | + | {
|
| 9 | - | for (var i:int=0; i<businessList.length(); i++) |
| 9 | + | var bm:Bitmap; |
| 10 | - | {
|
| 10 | + | switch(businessList[i].type) |
| 11 | - | |
| 11 | + | {
|
| 12 | - | if (businessList[i].type=="Hotel") |
| 12 | + | case "Hotel": bm = new Hotel as Bitmap; break; |
| 13 | - | {
|
| 13 | + | case "Hostel": bm = new Hostel as Bitmap; break; |
| 14 | - | var bm:Bitmap = new Hotel as Bitmap; |
| 14 | + | case "Pharmacy": bm = new Pharmacy as Bitmap; break; |
| 15 | - | } |
| 15 | + | case "Restaurant": bm = new Restaurant as Bitmap; break; |
| 16 | - | else if (businessList[i].type=="Hostel") |
| 16 | + | case "Supplies": bm = new Supplies as Bitmap; break; |
| 17 | - | {
|
| 17 | + | case "Work": bm = new Work as Bitmap; break; |
| 18 | - | var bm:Bitmap = new Hostel as Bitmap; |
| 18 | + | case "Bike": bm = new Bike as Bitmap; break; |
| 19 | - | } |
| 19 | + | } |
| 20 | - | else if (businessList[i].type=="Pharmacy") |
| 20 | + | var latLng = new LatLng(businessList[i].latitude, businessList[i].longitude); |
| 21 | - | {
|
| 21 | + | var options = new MarkerOptions({icon:bm, iconOffset: new Point (-23, -44)}));
|
| 22 | - | var bm:Bitmap = new Pharmacy as Bitmap; |
| 22 | + | var businessMarker:Marker = new Marker(latLng, options); |
| 23 | - | } |
| 23 | + | businessMarker.addEventListener(MapMouseEvent.CLICK, onMarkerClick):void |
| 24 | - | else if (businessList[i].type=="Restaurant") |
| 24 | + | markersInfo[businessMarker] = businessList[i]; |
| 25 | - | {
|
| 25 | + | Map.addOverlay(businessMarker); |
| 26 | - | var bm:Bitmap = new Restaurant as Bitmap; |
| 26 | + | } |
| 27 | - | } |
| 27 | + | } |
| 28 | - | else if (businessList[i].type=="Supplies") |
| 28 | + | |
| 29 | - | {
|
| 29 | + | function onMarkerClick(e:MapMouseEvent):void |
| 30 | - | var bm:Bitmap = new Supplies as Bitmap; |
| 30 | + | {
|
| 31 | - | } |
| 31 | + | var businessMarker:Marker = Marker(e.currentTarget); |
| 32 | - | else if (businessList[i].type=="Work") |
| 32 | + | var xml:XML = markersInfo[businessMarker]; |
| 33 | - | {
|
| 33 | + | detailName.text = xml.name; |
| 34 | - | var bm:Bitmap = new Work as Bitmap; |
| 34 | + | detailStreet.text = xml.street; |
| 35 | - | } |
| 35 | + | detailCity.text = xml.city; |
| 36 | - | else |
| 36 | + | detailCountryPost.text = xml.country + ", " + xml.postcode; |
| 37 | - | {
|
| 37 | + | detailPhonenumber.text = xml.phonenumber; |
| 38 | - | var bm:Bitmap = new Bike as Bitmap; |
| 38 | + | detailEmail.text = xml.email; |
| 39 | - | } |
| 39 | + | detailWebsite.text = xml.website; |
| 40 | - | |
| 40 | + | detailDescription.text = xml.description; |
| 41 | - | var html:String = "<b>" + businessList[i].name + "</b><br/>" + businessList[i].street + "<br/>" + businessList[i].city + "<br/>" + businessList[i].country + ", " + businessList[i].postcode; |
| 41 | + | detailDescription.visible=true; |
| 42 | - | var imageURL:String; |
| 42 | + | descTitle.visible=true; |
| 43 | - | var imageURL2:String; |
| 43 | + | facebookURL = xml.facebookid; |
| 44 | - | |
| 44 | + | twitterURL = xml.twitterid; |
| 45 | - | var businessMarker:Marker = new Marker(new LatLng(businessList[i].latitude,businessList[i].longitude), |
| 45 | + | youtubeURL = xml.youtubeid; |
| 46 | - | new MarkerOptions({icon:bm, iconOffset: new Point (-23, -44)}));
|
| 46 | + | flickrURL = xml.flickrid; |
| 47 | - | businessMarker.addEventListener(MapMouseEvent.CLICK, function(e:MapMouseEvent):void {
|
| 47 | + | detailLogo.source = "/logos/" + xml.businessid + ".jpg"; |
| 48 | - | Marker(e.currentTarget).openInfoWindow(new InfoWindowOptions({contentHTML:htmlDict[e.currentTarget]}));
|
| 48 | + | detailLogo.visible=true; |
| 49 | - | detailName.text = nameDict[e.currentTarget]; |
| 49 | + | var html:String = "<b>" + xml.name + "</b><br/>" + xml.street + |
| 50 | - | detailStreet.text = streetDict[e.currentTarget]; |
| 50 | + | "<br/>" + xml.city + "<br/>" + xml.country + ", " + xml.postcode; |
| 51 | - | detailCity.text = cityDict[e.currentTarget]; |
| 51 | + | businessMarker.openInfoWindow(new InfoWindowOptions({contentHTML:html}));
|
| 52 | - | detailCountryPost.text = countryDict[e.currentTarget]; |
| 52 | + | emailDisplay(); |
| 53 | - | detailPhonenumber.text = phonenumberDict[e.currentTarget]; |
| 53 | + | websiteDisplay(); |
| 54 | - | detailEmail.text = emailDict[e.currentTarget]; |
| 54 | + | facebookIcon(); |
| 55 | - | detailWebsite.text = websiteDict[e.currentTarget]; |
| 55 | + | twitterIcon(); |
| 56 | - | detailDescription.text = descriptionDict[e.currentTarget]; |
| 56 | + | youtubeIcon(); |
| 57 | - | detailDescription.visible=true; |
| 57 | + | flickrIcon(); |
| 58 | - | descTitle.visible=true; |
| 58 | + | } |
| 59 | - | facebookURL = facebookidDict[e.currentTarget]; |
| 59 | + | |
| 60 | - | twitterURL = twitteridDict[e.currentTarget]; |
| 60 | + | private function toggleHotel():void |
| 61 | - | youtubeURL = youtubeidDict[e.currentTarget]; |
| 61 | + | {
|
| 62 | - | flickrURL = flickridDict[e.currentTarget]; |
| 62 | + | for(businessMarker in markersInfo) |
| 63 | - | imageURL = idDict[e.currentTarget]; |
| 63 | + | {
|
| 64 | - | detailLogo.source = "/logos/" + imageURL + ".jpg"; |
| 64 | + | if(businessMarker.type=="Hotel") |
| 65 | - | detailLogo.visible=true; |
| 65 | + | {
|
| 66 | - | emailDisplay(); |
| 66 | + | businessMarker.visible = !marker.visible; |
| 67 | - | websiteDisplay(); |
| 67 | + | } |
| 68 | - | facebookIcon(); |
| 68 | + | } |
| 69 | - | twitterIcon(); |
| 69 | + | } |