Search code examples
javascriptimagepanoramio

why does images not show up using panoramio javascript api


I am trying to display a bunch of images of a city given its lat/long.

I'm using panoramio's javascript api, however, I don't see any output. There are no errors on the chrome console.

Here is the source:

<head>
  <title>My page</title>
  <meta name="description" content="This is my page." />
  <script type="text/javascript" src="http://www.panoramio.com/wapi/wapi.js?v=1" />
  <script type="text/javascript">
  var myRequest = new panoramio.PhotoRequest({
      'rect': {'sw': {'lat': -30, 'lng': 10.5}, 'ne': {'lat': 50.5, 'lng': 30}}
    });
  var myOptions = {
          'width': 300,
          'height': 200
        };
  var widget = new panoramio.PhotoWidget('wapiblock', myRequest, myOptions);
  widget.setPosition(0);
  </script>
</head>
<body>

<div id="wapiblock"></div>

</body>

The jsfiddle that shows the same problem:


Solution

  • The problem is, quite funny, with the closing </script> tag. You can't shorten it. Always close all tags in full form, except <img />, <br /> and <meta />.

    Wrong:

    <script src="http://www.panoramio.com/wapi/wapi.js?v=1" />
    

    Right:

    <script src="http://www.panoramio.com/wapi/wapi.js?v=1"></script>
    

    Working example: http://jsfiddle.net/AMy9j/1/