--- a/src/egonomy/__init__.py Wed Jul 17 13:23:35 2013 +0200
+++ b/src/egonomy/__init__.py Thu Jul 18 11:25:19 2013 +0200
@@ -1,4 +1,4 @@
-VERSION = (0, 6, 12, "final", 1)
+VERSION = (0, 7, 0, "final", 1)
VERSION_STR = unicode(".".join(map(lambda i:"%02d" % (i,), VERSION[:2])))
--- a/src/egonomy/templates/egonomy_view_collection.html Wed Jul 17 13:23:35 2013 +0200
+++ b/src/egonomy/templates/egonomy_view_collection.html Thu Jul 18 11:25:19 2013 +0200
@@ -254,13 +254,13 @@
// Locations have now lat and lng, we can init the map
initmap();
}
-function initmap() {
+function initmap(){
// set up the map
map = new L.Map('map');
// create the tile layer with correct attribution
var osmUrl='http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
- var osm = new L.TileLayer(osmUrl, {minZoom: 3, maxZoom: 20});
+ var osm = new L.TileLayer(osmUrl);
// start the map in South-East England
map.setView(new L.LatLng(48.833, 2.333),4);
@@ -269,14 +269,57 @@
// markers
for (var loc in places) {
if(places[loc]["location"]["lat"] && places[loc]["location"]["lng"]){
+ // Set marker
var marker = L.marker([places[loc]["location"]["lat"], places[loc]["location"]["lng"]]).addTo(map);
marker.bindPopup(loc);
- marker.on('click', function (d) {
+ places[loc]["marker"] = marker;
+ // Marker click behaviour : highlight items
+ marker.on('click', function(d){
// Get the marker's title thanks to leaflet object organisation
marker_title = d.target._popup._content;
// Get the items
highlight_items(places[marker_title]["items"]);
});
+ // Item hover bevahiour : open/close popup
+ for(var i=0;i<places[loc]["items"].length;i++){
+ $("#item" + places[loc]["items"][i]).hover(
+ function(){
+ // id is like "itemNUM"
+ var id = $(this).attr('id');
+ var num_item = parseInt(id.substr(4));
+ var stop = false;
+ for(var loc in places){
+ for(var i=0;i<places[loc]["items"].length;i++){
+ if(places[loc]["items"][i]==num_item){
+ places[loc]["marker"].openPopup();
+ stop = true;
+ break;
+ }
+ }
+ if(stop){
+ break;
+ }
+ }
+ },
+ function(){
+ // id is like "itemNUM"
+ var id = $(this).attr('id');
+ var num_item = parseInt(id.substr(4));
+ var stop = false;
+ for(var loc in places){
+ for(var i=0;i<places[loc]["items"].length;i++){
+ if(places[loc]["items"][i]==num_item){
+ places[loc]["marker"].closePopup();
+ stop = true;
+ break;
+ }
+ }
+ if(stop){
+ break;
+ }
+ }
+ });
+ }
}
}
map.on('popupclose', function(e) {