i am javascript jedi

This commit is contained in:
jllord 2013-05-27 19:29:51 -07:00
parent c3e0a4e6fa
commit 3fd2362c6a
3 changed files with 30 additions and 6 deletions

View File

@ -1 +1 @@
[{"name":"Sweet Bar Bakery","address":"2355 Broadway","city":"Oakland","state":"Ca","long":"-122.266011839473","lat":"37.8129222733119","country":"USA","wifipassword":"cupcakes","outlets":"yes","couch":"no","largetable":"yes","brewing":"","outdoorseating":"yes","hexcolor":"#FF4646","rowNumber":1},{"name":"Awaken Cafe","address":"1429 Broadway","city":"Oakland","state":"Ca","long":"-122.271131495076","lat":"37.8046753170488","country":"USA","wifipassword":"iced coffee","outlets":"yes","couch":"yes","largetable":"yes","brewing":"Four Barrel","outdoorseating":"","hexcolor":"#FF4646","rowNumber":2},{"name":"Panther Coffee","address":"2390 NW 2nd Ave","city":"Miami","state":"Fl","long":"-80.1991536666667","lat":"25.8000021666667","country":"USA","wifipassword":"espresso","outlets":"yes","couch":"no","largetable":"yes","brewing":"In-house","outdoorseating":"yes","hexcolor":"#FF4646","rowNumber":3},{"name":"Haddon Hill Cafe","address":"504 Wesley Ave","city":"Oakland","state":"Ca","long":"-122.2488474","lat":"37.8049159","country":"USA","wifipassword":"haddon10","outlets":"yes","couch":"no","largetable":"yes","brewing":"Sight Glass","outdoorseating":"yes","hexcolor":"#FF4646","rowNumber":4},{"name":"SubRosa Coffee","address":"419 40th Street","city":"Oakland","state":"Ca","long":"-122.2604838","lat":"37.8283586","country":"USA","wifipassword":"-","outlets":"yes","couch":"no","largetable":"no","brewing":"Four Barrel","outdoorseating":"yes","hexcolor":"#FF4646","rowNumber":5}] [{"contributerstwitter":"jllord","name":"Sweet Bar Bakery","address":"2355 Broadway","city":"Oakland","state":"Ca","long":"-122.266011839473","lat":"37.8129222733119","country":"USA","wifipassword":"cupcakes","outlets":"yes","couch":"no","largetable":"yes","brewing":"","outdoorseating":"yes","hexcolor":"#B9FCFC","rowNumber":1},{"contributerstwitter":"jllord","name":"Awaken Cafe","address":"1429 Broadway","city":"Oakland","state":"Ca","long":"-122.271131495076","lat":"37.8046753170488","country":"USA","wifipassword":"iced coffee","outlets":"yes","couch":"yes","largetable":"yes","brewing":"Four Barrel","outdoorseating":"","hexcolor":"#B9FCFC","rowNumber":2},{"contributerstwitter":"jllord","name":"Panther Coffee","address":"2390 NW 2nd Ave","city":"Miami","state":"Fl","long":"-80.1991536666667","lat":"25.8000021666667","country":"USA","wifipassword":"espresso","outlets":"yes","couch":"no","largetable":"yes","brewing":"In-house","outdoorseating":"yes","hexcolor":"#B9FCFC","rowNumber":3},{"contributerstwitter":"jllord","name":"Haddon Hill Cafe","address":"504 Wesley Ave","city":"Oakland","state":"Ca","long":"-122.2488474","lat":"37.8049159","country":"USA","wifipassword":"haddon10","outlets":"yes","couch":"no","largetable":"yes","brewing":"Sight Glass","outdoorseating":"yes","hexcolor":"#B9FCFC","rowNumber":4},{"contributerstwitter":"jllord","name":"SubRosa Coffee","address":"419 40th Street","city":"Oakland","state":"Ca","long":"-122.2604838","lat":"37.8283586","country":"USA","wifipassword":"-","outlets":"yes","couch":"no","largetable":"no","brewing":"Four Barrel","outdoorseating":"yes","hexcolor":"#B9FCFC","rowNumber":5}]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@ -6,7 +6,7 @@
<script src='js/jquery.js '></script> <script src='js/jquery.js '></script>
<script type="text/javascript" src='js/d3.js'></script> <script type="text/javascript" src='js/d3.js'></script>
<script type="text/javascript" src='js/sheetsee.js'></script> <script type="text/javascript" src='js/sheetsee.js'></script>
<link rel="shortcut icon" href="https://raw.github.com/jllord/sheetsee-cache/master/favicon-p.png"/> <link rel="shortcut icon" href="https://raw.github.com/jlord/hack-spots/master/favico.png"/>
<link href='http://api.tiles.mapbox.com/mapbox.js/v1.0.0/mapbox.css' rel='stylesheet' /> <link href='http://api.tiles.mapbox.com/mapbox.js/v1.0.0/mapbox.css' rel='stylesheet' />
<link href='http://fonts.googleapis.com/css?family=Lato:300,400,700,300italic' rel='stylesheet' type='text/css'> <link href='http://fonts.googleapis.com/css?family=Lato:300,400,700,300italic' rel='stylesheet' type='text/css'>
@ -71,6 +71,7 @@
<li><span class="category">Large Table:</span> {{largetable}}</li> <li><span class="category">Large Table:</span> {{largetable}}</li>
<li><span class="category">Outdoor Seating:</span> {{outdoorseating}}</li> <li><span class="category">Outdoor Seating:</span> {{outdoorseating}}</li>
<li><span class="category">Brewing:</span> {{brewing}}</li> <li><span class="category">Brewing:</span> {{brewing}}</li>
<li><span class="category">Contributed By:</span> <a href="http://www.twitter/{{contributerstwitter}}" target="_blank">@{{contributerstwitter}}</a></li>
</ul> </ul>
<ul> <ul>
<li><a href="https://maps.google.com/maps?q={{address}},{{city}},{{state}}" target="_blank">View in Google Maps</a></li> <li><a href="https://maps.google.com/maps?q={{address}},{{city}},{{state}}" target="_blank">View in Google Maps</a></li>
@ -117,9 +118,25 @@
$('#selectedSpot').html(selectedSpot).css("display", "inline") $('#selectedSpot').html(selectedSpot).css("display", "inline")
var selectedCoords = [dataElement[0].lat, dataElement[0].long] var selectedCoords = [dataElement[0].lat, dataElement[0].long]
console.log(selectedCoords) console.log(selectedCoords)
map.setView(selectedCoords, 17) matchGeoJSONbyRowNumber(rowNumber, geoJSON, "#FF4646")
console.log(geoJSON)
Sheetsee.addMarkerLayer(geoJSON, map, 11)
map.setView(selectedCoords, 13)
}) })
function matchGeoJSONbyRowNumber(rowNumber, geoJSON, highlightColor) {
geoJSON.forEach(function (d) {
for (var key in d.opts) {
var value = d.opts[key].toString().toLowerCase()
if (key === 'rowNumber' && value.match(rowNumber.toString().toLowerCase())) {
d.properties["marker-color"] = highlightColor
return geoJSON
}
// else { console.log("no match") }
}
})
}
var theLatestSpot = gData.reverse()[0] var theLatestSpot = gData.reverse()[0]
var latestSpot = ich.latestSpot({ var latestSpot = ich.latestSpot({
@ -133,11 +150,18 @@
var searchCoords = "" var searchCoords = ""
// map.setView(viewCoords, zoomLevel) // map.setView(viewCoords, zoomLevel)
} }
}) })
var optionsJSON = ["name", "address", "city", "rownumber"] function highlightLastMarker(geoJSON, highlightColor) {
var geoJSON = Sheetsee.createGeoJSON(gData, optionsJSON) geoJSON.reverse()[0].properties["marker-color"] = highlightColor
return geoJSON
}
var optionsJSON = ["name", "address", "city", "rowNumber"]
var geoJSONnoHL = Sheetsee.createGeoJSON(gData, optionsJSON)
var geoJSON = highlightLastMarker(geoJSONnoHL, "#FF4646")
console.log(geoJSON[0].properties)
// geoJSON[0].properties["maker-color"] = "#E5FF1D"
var map = Sheetsee.loadMap("map") var map = Sheetsee.loadMap("map")
Sheetsee.addTileLayer(map, 'examples.map-20v6611k') Sheetsee.addTileLayer(map, 'examples.map-20v6611k')
var markerLayer = Sheetsee.addMarkerLayer(geoJSON, map, 11) var markerLayer = Sheetsee.addMarkerLayer(geoJSON, map, 11)