Created
May 27, 2011 16:58
-
-
Save orfeomorello/995682 to your computer and use it in GitHub Desktop.
Call mashape API to get a valid token to invoke our Api Wrapper for static maps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var currentLocation; | |
var currentLatitude; | |
var currentLongitude; | |
/* Default map provider. You can select Bing,Facebook,Foursquare,Google,Ovi,Openstreetmap */ | |
var provider="Google"; | |
var textFromDatabase=""; | |
var goNext=0; | |
function executeRequest() | |
{ | |
$.ajax({ | |
url : tokenUrl, | |
dataType : "jsonp", | |
jsonpCallback: "elaborateToken", | |
timeout : 700 | |
}); | |
} | |
function elaborateToken(data) | |
{ | |
var localstreamerUrl ='http://www.localstreamer.com/mashape/staticimagemap/lat/'+currentLatitude+'/lng/'+currentLongitude+'/provider/'+provider+'?zoom=10&_token='+data.token; | |
$.getJSON(localstreamerUrl,{}, function(data) | |
{ | |
if (data.imageUrl) | |
{ | |
var imageUrl = data.imageUrl | |
var htmlCode = '<a href="#" class="css_tooltip">'+currentLocation+' <span><img src="'+imageUrl+'"></span></a>'; | |
var match = new RegExp(currentLocation, "ig"); | |
textFromDatabase = textFromDatabase.replace(match, htmlCode); | |
document.getElementById("content").innerHTML = textFromDatabase; | |
goNext=goNext+1; | |
if(pointsArray[goNext]) | |
{ | |
currentLocation = pointsArray[goNext][0]; | |
currentLatitude = pointsArray[goNext][1]; | |
currentLongitude = pointsArray[goNext][2]; | |
executeRequest(); | |
} | |
else | |
{ | |
document.getElementById('pleasewait').style.display = 'none'; | |
alert('Completed!'); | |
} | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment