Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
33 lines (32 sloc) 6.43 KB
{
"HIGHLIGHTSTROKECOLORS": {
"GMAP": "#002659"
},
"ARGPLUGINS": {
"coord": "var block = logo.blocks.blockList[blk];var conns = block.connections;var latitude = logo.parseArg(logo, turtle, conns[1]);var longitude = logo.parseArg(logo, turtle, conns[2]);latitude = eval(latitude);longitude = eval(longitude);if(!latitude || !longitude) { latitude = 42.357279; longitude = -71.065740;}gmapURL = 'http://maps.googleapis.com/maps/api/staticmap?center=' + latitude + ',' + longitude; block.value = gmapURL;",
"cityToLat": "var block = logo.blocks.blockList[blk];var conns = block.connections;var city = logo.parseArg(logo, turtle, conns[1]);if (city == cityName) { block.value = cityLatitude;} else { var apiURL = 'https://devru-latitude-longitude-find-v1.p.mashape.com/latlon.php?location=' + city; var request = new XMLHttpRequest(); request.open('GET', apiURL, false); request.setRequestHeader('X-Mashape-Authorization', gmapMashapeKey); request.send(null); var response = request.responseText; var data = JSON.parse(response); var latitude = 0; if(data['Results'].length > 0) { data = data['Results'][0]['ll']; var parts = data.split(' '); try { cityLatitude = Number(parts[0]); cityLongitude = Number(parts[1]); var latitude = cityLatitude; cityName = city; } catch (e) { logo.errorMsg(_('Coordinate data not available.'), blk); } } else { logo.errorMsg(_('Coordinate data not available.'), blk); } block.value = latitude;}",
"zoom": "var block = logo.blocks.blockList[blk];var conns = block.connections;var zoomFactor = logo.parseArg(logo, turtle, conns[1]);block.value = zoomFactor;",
"cityToLong": "var block = logo.blocks.blockList[blk];var conns = block.connections;var city = logo.parseArg(logo, turtle, conns[1]);if (city == cityName) { block.value = cityLongitude;} else { var apiURL = 'https://devru-latitude-longitude-find-v1.p.mashape.com/latlon.php?location=' + city; var request = new XMLHttpRequest(); request.open('GET', apiURL, false); request.setRequestHeader('X-Mashape-Authorization', gmapMashapeKey); request.send(null); var response = request.responseText; var data = JSON.parse(response); var longitude = 0; if (data['Results'].length > 0) { data = data['Results'][0]['ll']; var parts = data.split(' '); try { cityLatitude = Number(parts[0]); cityLongitude = Number(parts[1]); var longitude = cityLongitude; cityName = city; } catch (e) { logo.errorMsg(_('Coordinate data not available.'), blk); } } else { logo.errorMsg(_('Coordinate data not available.'), blk); } block.value = longitude;}",
"gmap": "var block = logo.blocks.blockList[blk];var conns = block.connections;var url = logo.parseArg(logo, turtle, conns[1]);var zoom_factor = logo.parseArg(logo, turtle, conns[2]);if(!url) { url = 'http://maps.googleapis.com/maps/api/staticmap?center=42.357279,-71.065740';}if(!zoom_factor) { zoom_factor = 10;}if(zoom_factor == 0) { zoom_factor = 0;}gmapURL = url + '&size=800x800&zoom=' + zoom_factor +'&sensor=false';block.value = gmapURL;"
},
"GLOBALS": "gmapMashapeKey = 'JidA8phgY8mshJ8MiEUeHTdwFjjtp1wq209jsncYthfRDMQNW6';cityName = '';cityLatitude = 0;cityLongitude = 0;",
"PALETTEHIGHLIGHTCOLORS": {
"GMAP": "#00c5ff"
},
"PALETTEPLUGINS": {
"GMAP": "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"55\" height=\"55\"> <g transform=\"translate(0,-997.36218)\"> <path d=\"m 26.666222,1048.911 c -0.09596,-0.1879 -0.280246,-1.1767 -0.409529,-2.1972 -0.565075,-4.4605 -1.668106,-8.4319 -3.417528,-12.3047 -1.042617,-2.3081 -1.991286,-4.0116 -4.785815,-8.5938 -2.157572,-3.5377 -3.416439,-6.1924 -3.906374,-8.2377 -1.94515,-8.1203 3.386556,-15.8819 11.66714,-16.9844 6.55392,-0.87256 12.754344,3.0441 14.884012,9.4018 0.303361,0.9057 0.454986,1.948 0.528971,3.6362 0.12683,2.8942 -0.172817,4.4431 -1.375035,7.1077 -0.81051,1.7964 -1.193239,2.47 -3.882801,6.8343 -4.222383,6.8514 -6.42126,12.8338 -7.162043,19.4855 -0.09889,0.8879 -0.288049,1.7449 -0.420357,1.9043 -0.340934,0.4108 -1.502333,0.3757 -1.720641,-0.052 z m 3.610049,-29.2554 c 2.087523,-1.02 3.263533,-2.9613 3.249324,-5.3637 -0.01655,-2.7984 -1.484926,-4.8055 -4.176295,-5.7086 -1.149887,-0.3858 -3.454027,-0.19 -4.573135,0.3887 -0.987414,0.5106 -2.073445,1.6471 -2.65731,2.7808 -0.65002,1.2622 -0.65002,3.816 0,5.0782 1.595933,3.0989 5.107552,4.3148 8.157416,2.8246 z\" style=\"fill:#ffffff\" /> </g></svg>"
},
"BLOCKPLUGINS": {
"coord": "var coordBlk = new ProtoBlock('coord');coordBlk.palette = palettes.dict['GMAP'];blocks.protoBlockDict['coord'] = coordBlk;coordBlk.staticLabels.push(_('coordinates'),_('latitude'),_('longitude'));coordBlk.adjustWidthToLabel();coordBlk.twoArgMathBlock();coordBlk.dockTypes[1] = 'anyin';coordBlk.dockTypes[2] = 'anyin';coordBlk.defaults.push(42.357279,-71.065740);",
"cityToLat": "var cityToLatBlk = new ProtoBlock('cityToLat');cityToLatBlk.palette = palettes.dict['GMAP'];blocks.protoBlockDict['cityToLat'] = cityToLatBlk;cityToLatBlk.staticLabels.push(_('city latitude'));cityToLatBlk.adjustWidthToLabel();cityToLatBlk.oneArgMathBlock();cityToLatBlk.dockTypes[1] = 'anyin';cityToLatBlk.defaults.push(\"Boston\");",
"zoom": "var zoomBlk = new ProtoBlock('zoom');zoomBlk.palette = palettes.dict['GMAP'];blocks.protoBlockDict['zoom'] = zoomBlk;zoomBlk.staticLabels.push(_('zoom'));zoomBlk.adjustWidthToLabel();zoomBlk.oneArgMathBlock();zoomBlk.dockTypes[1] = 'anyin';zoomBlk.defaults.push(10);",
"cityToLong": "var cityToLongBlk = new ProtoBlock('cityToLong');cityToLongBlk.palette = palettes.dict['GMAP'];blocks.protoBlockDict['cityToLong'] = cityToLongBlk;cityToLongBlk.staticLabels.push(_('city longitude'));cityToLongBlk.adjustWidthToLabel();cityToLongBlk.oneArgMathBlock();cityToLongBlk.dockTypes[1] = 'anyin';cityToLongBlk.defaults.push(\"Boston\");",
"gmap": "var gmapBlk = new ProtoBlock('gmap');gmapBlk.palette = palettes.dict['GMAP'];blocks.protoBlockDict['gmap'] = gmapBlk;gmapBlk.staticLabels.push(_('Google map'),_('coordinates'),_('zoom factor'));gmapBlk.adjustWidthToLabel();gmapBlk.twoArgMathBlock();"
},
"PALETTEFILLCOLORS": {
"GMAP": "#00abff"
},
"PALETTESTROKECOLORS": {
"GMAP": "#005aaa"
}
}