forked from christianliu/MiCT
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
alexbeam
authored and
alexbeam
committed
Jul 21, 2014
1 parent
74cd21d
commit cc43476
Showing
10 changed files
with
384 additions
and
121 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
function SetupMap() { | ||
|
||
var map = L.mapbox.map('map', 'examples.h186knp8').setView([-33.93, 18.42], 10); | ||
|
||
|
||
myLayer = null; | ||
|
||
// search | ||
$('#company_search').on('submit', function(e) { | ||
e.preventDefault(); | ||
|
||
fetchMarkers({ | ||
onComplete: function(data) { | ||
// once the data has been fetched | ||
|
||
// clear all markers | ||
$('ul#info li').remove() | ||
|
||
// add markers from data (if there are any?) | ||
placeMarkers(myLayer, data); | ||
|
||
if (data.length > 0) { | ||
setTimeout( function() { | ||
map.fitBounds(myLayer.getBounds()); | ||
}, 50); | ||
setTimeout( function() { | ||
$( "li.item" ).first().mouseover(); | ||
}, 600); | ||
} | ||
}, | ||
data: $('#company_search').serialize() | ||
}); | ||
}); | ||
|
||
var fetchMarkers = function(args) { | ||
$.ajax({ | ||
type: "GET", | ||
data: args.data, | ||
url: "/companies", | ||
dataType: "json", | ||
success: args.onComplete | ||
}); | ||
|
||
|
||
}; | ||
|
||
var placeMarkers = function(layer, data) { | ||
|
||
layer.setGeoJSON(data); | ||
|
||
var info = document.getElementById('info'); | ||
var info = $('ul#info') | ||
|
||
// Iterate through each feature layer item, build a | ||
// marker menu item and enable a click event that pans to + opens | ||
// a marker that's associated to the marker item. | ||
layer.eachLayer(function(marker) { | ||
|
||
itemName = marker.feature.properties.title + | ||
'' + marker.feature.properties.additional + ''; | ||
|
||
itemMarker = marker.feature.properties.title + | ||
'' + marker.feature.properties.description + ''; | ||
|
||
info.append( | ||
|
||
$("<li class='item'>" + itemName + "</li>").on('mouseover', function(e) { | ||
|
||
$('ul#info li').removeClass('active'); | ||
$(e.target).addClass('active'); | ||
|
||
// When a menu item is clicked, animate the map to center | ||
// its associated marker and open its popup. | ||
|
||
marker.openPopup(); | ||
|
||
}) | ||
); | ||
|
||
marker.bindPopup(itemMarker,{ | ||
width: 320, | ||
height: 320 | ||
}); | ||
}); | ||
}; | ||
myLayer = L.mapbox.featureLayer().addTo(map); | ||
|
||
fetchMarkers({ | ||
onComplete: function(data) { | ||
placeMarkers(myLayer, data); | ||
setTimeout( function() { | ||
map.fitBounds(myLayer.getBounds()); | ||
}, 50); | ||
|
||
} | ||
}); | ||
}; | ||
|
||
function filterButton(form) { | ||
fetchMarkers({ | ||
onComplete: function(data) { | ||
// once the data has been fetched | ||
|
||
// clear all markers | ||
$('ul#info li').remove() | ||
|
||
// add markers from data (if there are any?) | ||
placeMarkers(myLayer, data); | ||
|
||
if (data.length > 0) { | ||
setTimeout( function() { | ||
map.fitBounds(myLayer.getBounds()); | ||
}, 50); | ||
setTimeout( function() { | ||
$( "li.item" ).first().mouseover(); | ||
}, 600); | ||
} | ||
}, | ||
data: {q: {has_tags: $('#has_tags').val()}} | ||
}); | ||
}; | ||
|
||
|
||
|
||
var fetchMarkers = function(args) { | ||
$.ajax({ | ||
type: "GET", | ||
data: args.data, | ||
url: "/companies", | ||
dataType: "json", | ||
success: args.onComplete | ||
}); | ||
|
||
|
||
}; | ||
|
||
var placeMarkers = function(layer, data) { | ||
|
||
layer.setGeoJSON(data); | ||
|
||
var info = document.getElementById('info'); | ||
var info = $('ul#info') | ||
|
||
// Iterate through each feature layer item, build a | ||
// marker menu item and enable a click event that pans to + opens | ||
// a marker that's associated to the marker item. | ||
layer.eachLayer(function(marker) { | ||
|
||
itemName = marker.feature.properties.title + | ||
'' + marker.feature.properties.additional + ''; | ||
|
||
itemMarker = marker.feature.properties.title + | ||
'' + marker.feature.properties.description + ''; | ||
|
||
info.append( | ||
|
||
$("<li class='item'>" + itemName + "</li>").on('mouseover', function(e) { | ||
|
||
$('ul#info li').removeClass('active'); | ||
$(e.target).addClass('active'); | ||
|
||
// When a menu item is clicked, animate the map to center | ||
// its associated marker and open its popup. | ||
|
||
marker.openPopup(); | ||
|
||
}) | ||
); | ||
|
||
marker.bindPopup(itemMarker,{ | ||
width: 320, | ||
height: 320 | ||
}); | ||
}); | ||
}; | ||
myLayer = L.mapbox.featureLayer().addTo(map); | ||
|
||
fetchMarkers({ | ||
onComplete: function(data) { | ||
placeMarkers(myLayer, data); | ||
setTimeout( function() { | ||
map.fitBounds(myLayer.getBounds()); | ||
}, 50); | ||
|
||
} | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
# SetupMap = -> | ||
# map = L.mapbox.map("map", "examples.h186knp8").setView([ | ||
# -33.93 | ||
# 18.42 | ||
# ], 10) | ||
# window.myLayer = null | ||
|
||
# # search | ||
# $("#company_search").on "submit", (e) -> | ||
# e.preventDefault() | ||
# fetchMarkers | ||
# onComplete: (data) -> | ||
|
||
# # once the data has been fetched | ||
|
||
# # clear all markers | ||
# $("ul#info li").remove() | ||
|
||
# # add markers from data (if there are any?) | ||
# placeMarkers myLayer, data | ||
# if data.length > 0 | ||
# setTimeout (-> | ||
# map.fitBounds myLayer.getBounds() | ||
# return | ||
# ), 50 | ||
# setTimeout (-> | ||
# $("li.item").first().mouseover() | ||
# return | ||
# ), 600 | ||
# return | ||
|
||
# data: $("#company_search").serialize() | ||
|
||
# return | ||
|
||
# fetchMarkers = (args) -> | ||
# $.ajax | ||
# type: "GET" | ||
# data: args.data | ||
# url: "/companies" | ||
# dataType: "json" | ||
# success: args.onComplete | ||
|
||
# return | ||
|
||
# placeMarkers = (layer, data) -> | ||
# layer.setGeoJSON data | ||
# info = document.getElementById("info") | ||
# info = $("ul#info") | ||
|
||
# # Iterate through each feature layer item, build a | ||
# # marker menu item and enable a click event that pans to + opens | ||
# # a marker that's associated to the marker item. | ||
# layer.eachLayer (marker) -> | ||
# itemName = marker.feature.properties.title + "" + marker.feature.properties.additional + "" | ||
# itemMarker = marker.feature.properties.title + "" + marker.feature.properties.description + "" | ||
# info.append $("<li class='item'>" + itemName + "</li>").on("mouseover", (e) -> | ||
# $("ul#info li").removeClass "active" | ||
# $(e.target).addClass "active" | ||
|
||
# # When a menu item is clicked, animate the map to center | ||
# # its associated marker and open its popup. | ||
# marker.openPopup() | ||
# return | ||
# ) | ||
# marker.bindPopup itemMarker, | ||
# width: 320 | ||
# height: 320 | ||
|
||
# return | ||
|
||
# return | ||
|
||
# myLayer = L.mapbox.featureLayer().addTo(map) | ||
# fetchMarkers onComplete: (data) -> | ||
# placeMarkers myLayer, data | ||
# setTimeout (-> | ||
# map.fitBounds myLayer.getBounds() | ||
# return | ||
# ), 50 | ||
# return | ||
|
||
# return | ||
# filterButton = (form) -> | ||
# fetchMarkers | ||
# onComplete: (data) -> | ||
|
||
# # once the data has been fetched | ||
|
||
# # clear all markers | ||
# $("ul#info li").remove() | ||
|
||
# # add markers from data (if there are any?) | ||
# placeMarkers myLayer, data | ||
# if data.length > 0 | ||
# setTimeout (-> | ||
# map.fitBounds myLayer.getBounds() | ||
# return | ||
# ), 50 | ||
# setTimeout (-> | ||
# $("li.item").first().mouseover() | ||
# return | ||
# ), 600 | ||
# return | ||
|
||
# data: | ||
# q: | ||
# has_tags: $("#has_tags").val() | ||
|
||
# return | ||
# fetchMarkers = (args) -> | ||
# $.ajax | ||
# type: "GET" | ||
# data: args.data | ||
# url: "/companies" | ||
# dataType: "json" | ||
# success: args.onComplete | ||
|
||
# return | ||
|
||
# placeMarkers = (layer, data) -> | ||
# layer.setGeoJSON data | ||
# info = document.getElementById("info") | ||
# info = $("ul#info") | ||
|
||
# # Iterate through each feature layer item, build a | ||
# # marker menu item and enable a click event that pans to + opens | ||
# # a marker that's associated to the marker item. | ||
# layer.eachLayer (marker) -> | ||
# itemName = marker.feature.properties.title + "" + marker.feature.properties.additional + "" | ||
# itemMarker = marker.feature.properties.title + "" + marker.feature.properties.description + "" | ||
# info.append $("<li class='item'>" + itemName + "</li>").on("mouseover", (e) -> | ||
# $("ul#info li").removeClass "active" | ||
# $(e.target).addClass "active" | ||
|
||
# # When a menu item is clicked, animate the map to center | ||
# # its associated marker and open its popup. | ||
# marker.openPopup() | ||
# return | ||
# ) | ||
# marker.bindPopup itemMarker, | ||
# width: 320 | ||
# height: 320 | ||
|
||
# return | ||
|
||
# return | ||
|
||
# window.myLayer = L.mapbox.featureLayer().addTo(map) | ||
# fetchMarkers onComplete: (data) -> | ||
# placeMarkers myLayer, data | ||
# setTimeout (-> | ||
# map.fitBounds myLayer.getBounds() | ||
# return | ||
# ), 50 | ||
# return |
Oops, something went wrong.