javascriptconflictpanoramio

Panoramio JavaScript API and PHP - Conflict?


I have a problem with compatibility, I think... Following the Panoramio API Reference Guide I have set up a Panoramio box, and it works fine as long as I try to make it work in an html test page on my computer. But then when I include that page in a php page - include(page.php) - it does not work at all... I fear it might be a compatibility issue, but I have no idea how to solve it unfortunately, I've already tried to enclose the code as a function but it didn't work.

Here's the code (as I'm working on localhost)

<script type="text/javascript" src="http://www.panoramio.com/wapi/wapi.js?v=1&amp;hl=en"></script>

<div id="div_photo_ex" style="float: left; margin: 10px 15px"></div>
<script type="text/javascript">
(function() {
  var rect = {'rect': {'sw': {'lat': 50, 'lng': -1}, 'ne': {'lat': 51, 'lng': 1}}};
  var photo_ex_options = {'width': 250, 'height': 400};
  var photo_ex_widget = new panoramio.PhotoWidget('div_photo_ex', rect, photo_ex_options);
  photo_ex_widget.setPosition(0);
})();
</script>

Here's the link to on of the pages in which the code should be put: http://www.beachpartyfever.com/parties-in/asia/152-malaysia/54-long-beach

I hope that someone knows what I could do, as I'm completely lost!


Solution

  • I do not know how/why, but I solved the problem... I added the following code

    <script type="text/javascript" src="http://www.panoramio.com/wapi/wapi.js?v=1&amp;hl=en"></script>
    

    at the beginning of the head portion of the page, instead of at the line right before the head closure tag. I don't know why, but now everything works fine. Anyone can explain the reason? I'd really like to understand the reason why it works, so in the future I will know how to handle this problem! Thank's!