Read and display Panoramio pictures with JSON and ASP

You want to use the Panoramio API to display pictures related to a place? (www.panoramio.com/api)
Here is the stuff you need:

  • Long/Lat of your place
  • Be able to calculate a min/max value for your Long/Lat
  • Read the Panoramio legal stuff :)

ASP:

<%

‘ Set the Min and Max long/Lat

x_geolatMin = Cint(x_geolatMin )’ this is your min LAT
x_geolongMin = Cint(x_
geolongMin )’ this is your min LONG
x_geolatMax = Cint(x_geolatMax ) this is your max LAT
x_geolongMax = Cint(x_geolongMax ) this is your max LONG

‘ Set the URL to Panoramio with your LONG/LAT values

PanoURL = “http://www.panoramio.com/map/get_panoramas.php?order=popularity&set=public&from=0&to=10&minx=”&x_geolongMin&”&miny=”&x_geolatMin&”&maxx=”&x_geolongMax&”&maxy=”&x_geolatMax

‘ Create the xml object
Set GetConnection = CreateObject(”Microsoft.XMLHTTP”)

‘ Conect to Panoramio…
GetConnection.Open “get”, PanoURL , False
GetConnection.Send

‘ PanoResponse is the response we will get when visiting PanoURL
PanoResponse = GetConnection.responseText

Set GetConnection = Nothing
PanoResponse = replace(PanoResponse ,”"”",”‘”) ‘not mandatory…

%>

Now we have the JSON string, let’s show it with basic Java Script

<SCRIPT type=”text/javascript”>
var myFirstJSON = <%=PanoResponse %>;
for (i=0; i<10; i++)//10 is the limit we want… change it here AND in the PanoUrl if needed

{
document.writeln(”<img src=’”+myFirstJSON.photos[i].photo_file_url+”‘><br />”);
document.writeln(myFirstJSON.photos[i].photo_title+”<br /><br />”);
}
</SCRIPT>

Now read more on www.panoramio.com/api about the JSON values like Autho, file adress etc..

Have fun ;)
You want more? Links:

1 Comment

  1. Jean Said,

    July 4, 2007 @ 12:45 pm

    A class to read JSON in ASP VBscript
    http://blog.crayoncowboy.com/?p=7

    A class to write JSON in ASP VBscript
    http://www.webdevbros.net/2007/04/26/generate-json-from-asp-datatypes/

    A function to clean a JSON string in ASP VBscript
    http://www.webdevbros.net/2007/04/26/json-character-escaping-function-in-classic-asp/

RSS feed for comments on this post