-
Notifications
You must be signed in to change notification settings - Fork 1
/
load_api.js
56 lines (45 loc) · 1.39 KB
/
load_api.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
function parseDeals (json) {
console.log("Number of deals : " + json.deals.length);
//console.log(json.deals);
deals = json.deals;
for(var i= 0; i < deals.length; i++)
{
//console.log("Deal# " + i + deals[i]);
var title, expiery;
var deal = deals[i];
var lat, lng;
var image_url = deal.smallImageUrl;
console.log("Image url : " + image_url);
optionsloop:
for (var j=0; j < deal.options.length; j++)
{
title = deal.options[j].title;
expiery = deal.options[j].expiresAt;
if(deal.options[j].redemptionLocations.length > 0)
{
lat = deal.options[j].redemptionLocations[0].lat;
lng = deal.options[j].redemptionLocations[0].lng;
break optionsloop;
}
}
console.log("deal " + i + " lat: " + lat + " lng: " + lng);
if((typeof lat == 'undefined') || (typeof lng == 'undefined'))
{
continue; //continue to next deal
}
var point = new google.maps.LatLng(parseFloat(lat),parseFloat(lng));
var html='<img src='+image_url+'><br/>'+title+'<br />'+"ExpiresAt : "+expiery;
addMarker(point, html);
}
}
// function to make cross domain call
function loadScript(url)
{
// adding the script tag to the head
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
// fire the loading
head.appendChild(script);
}