Link to home
Start Free TrialLog in
Avatar of Tom Powers
Tom Powers

asked on

load Ballpark Jquery

I need to load a image of a BallPark into a current image The reason is I'm going to have little Players loaded on top of Baseball field. I have code to load the image when nothing is on webpage but I need to know How to load Ballpark image into a present image.
here is the code It should load washington Nationals Ballpark and not default.
stadiums = {
	"wrigley field":"wrigley.gif",
	"comerica park":"comerica.gif" ,
	"yankee stadium":"yankee.jpg" ,
	"shea stadium":"shea.jpg" ,
	"angel stadium of anaheim":"angel.jpg" ,
	"rangers ballpark in arlington":"angel.jpg" ,
	"at&t park":"attpark.jpg" ,
	"citizens bank park":"citizenballpark.jpg" ,
	"coors field":"coors.jpg" ,
	"busch stadium":"busch.jpg" ,
	"oriole park at camden yards":"camden_baltimore.jpg",
	"dodger stadium":"dodgers.jpg" ,
	"chase field":"chasefield.jpg" ,
	"tropicana field":"tropicana.jpg" ,
	"great american ball park":"greatamerican.jpg" ,
	"kauffman stadium":"kauffmanstadium.jpg" ,
	"mcafee coliseum":"mcafeecoliseum.jpg" ,
	"hubert h. humphrey metrodome":"metrodome.jpg" ,
	"metrodome":"metrodome.jpg" ,
	"miller park":"millerpark.jpg" ,
	"minute maid park":"minutemaid.jpg" ,
	"nationals park":"nationalspark.jpg" ,
	"petco park":"petcopark.jpg" ,
	"pnc park":"pncpark.jpg" ,
	"progressive field":"progressive.jpg" ,
	"rogers centre":"rogerscentre.jpg" ,
	"safeco field":"safecofield.jpg" ,
	"turner field":"turnerfield.jpg" ,
	"dolphin stadium":"dolphinstadium.jpg" ,
	"fenway park":"fenwaypark.jpg" ,
	"u.s. cellular field":"uscellularfield.jpg" ,
	"oakland-alameda county coliseum":"mcafeecoliseum.jpg",
	"marlins park":"marlins.jpg",
	"citi field":"citifield.jpg",
	"citi field":"citifield.jpg",
	 "minnesota":"target field"
} // no comma on the last

var homeTurf = {
  "philadelphia":"citizens bank park",
  "milwaukee":"miller park",
  "san francisco":"u.s. cellular field",
  "la angels":"angel stadium of anaheim",
  "tampa bay":"tropicana field",
  "chicago wsox":"u.s. cellular field",
  "oakland":"oakland-alameda county coliseum",
  "kansas city":"kauffman stadium",
  "los angeles":"dodger stadium",
  "san diego":"petco park",
  "boston":"fenway park",
  "seattle":"safeco field",
  "detroit":"comerica park",
  "atlanta":"turner field",
  "baltimore":"oriole park at camden yards",
  "miami":"marlins park",
  "pittsburgh":"pnc park",
  "ny mets":"citi field",
  "st. louis":"busch stadium",
  "houston":"minute maid park",
  "cleveland":"progressive field",
  "cincinnati":"great american ball park",
  "texas":"rangers ballpark in arlington",
  "toronto":"rogers centre",
  "chicago cubs":"wrigley field",
  "arizona":"chase field",
  "colorado":"coors field",
  "ny yankees":"yankee stadium",
  "washington":"nationals park"
}

$(document).ready(function(){
  $.ajax({
    type: "GET",
    url: xmlPath+"/"+xmlGameID+".xml",
	
    dataType: "xml",
    success: function(data){
		 var d = $(data);
      var Play = d.find('Play');
      var Teams = $(data).find("Team");
	  
      $.each(Teams,function(i,Team) {
        team=$(Team);
        var id = team.attr("ID").toLowerCase();
        var teamLogo = $("<img/>").attr("src","http://images.sportsnetwork.com/MLB/attheballpark/pbp_logos/" + id + ".png");
        var homeOrAway = team.attr("vh");
	var name = team.attr("name").toLowerCase();
        $("#team"+homeOrAway).append(teamLogo);
        if (homeOrAway=="H") {
          var stadium_location = stadiums[homeTurf[name]]; // or have
          var url = "http://images.sportsnetwork.com/mlb/attheballpark/stadiums/";
          url = (stadium_location) ?url + stadium_location:"default.gif";
          
		 var loc = Play.attr('Location') ;
      var locate = "Location" + $('#txtBallparkname').html(loc).toUpperCase; 
        }  


      });
     }
  });
});

Open in new window

Field.html
37260.xml
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

1)  var loc = Play.attr('Location') ; does not return a location
2) var locate = "Location" + $('#txtBallparkname').html(loc).toUpperCase;
does not do anything.

I get this for the home team

http://images.sportsnetwork.com/mlb/attheballpark/stadiums/nationalspark.jpg

and this:

User generated image
Avatar of Tom Powers
Tom Powers

ASKER

I need washington field to load butnot like that I location to match location in xml file then staduim graphic file name to be appended to i "http://images.sportsnetwork.com/mlb/attheballpark/stadiums/";
Sorry that did nt make any sense...
In the xml file there is a attrib called Location the value of Location is nationalspark.jpg I am simply trying to call the value of location which is  nationalspark.jpg and put that value at the end of http://images.sportsnetwork.com/mlb/attheballpark/stadiums/ 

That is it my syntax is off though.
But as I said, I do get national park on my computer with the files you posted
This is the washington Nationals field the one I need
http://images.sportsnetwork.com/mlb/attheballpark/stadiums/nationalspark.jpg


The one your getting is Default.gif I guess if your not into Baseball they all look the same.

Your link
http://images.sportsnetwork.com/mlb/attheballpark/stadiums/default.gif
Hmm. Ok I also looked in the debugger.

I'll look again tomorrow. Bedtime here
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
mplungjan: Thank You for your assistance Your Help is much appreciated