why does images not show up using panoramio javascript api
-
23-06-2021 - |
문제
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:
해결책
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/
다른 팁
Widget does not show in composing mode. It will show after publishing.
<div dir="ltr" style="text-align: center;" trbidi="on">
<script src="https://ssl.panoramio.com/wapi/wapi.js?v=1&hl=en"></script>
<div id="wapiblock" style="float: right; margin: 10px 15px"></div>
<script type="text/javascript">
var myRequest = {
'tag': 'kahna',
'rect': {'sw': {'lat': -30, 'lng': 10.5}, 'ne': {'lat': 50.5, 'lng': 30}}
};
var myOptions = {
'width': 300,
'height': 200
};
var wapiblock = document.getElementById('wapiblock');
var photo_widget = new panoramio.PhotoWidget('wapiblock', myRequest, myOptions);
photo_widget.setPosition(0);
</script>
</div>
제휴하지 않습니다 StackOverflow