resetView

This commit is contained in:
Nils Schneider 2015-03-25 02:50:28 +01:00
parent 14d86c06af
commit 8a2300578a
2 changed files with 32 additions and 2 deletions

View File

@ -109,6 +109,8 @@ require(["map"], function (Map) {
historyDict.links[linkId(d)] = d
})
gotoAnything.reset()
gotoHistory(gotoAnything, historyDict, window.location.hash)
window.onpopstate = function (d) {
@ -280,10 +282,12 @@ require(["map"], function (Map) {
}
function Infobox(sidebar) {
var gotoAnything
var self = this
el = undefined
function close() {
gotoAnything.reset()
destroy()
pushHistory()
}
@ -314,6 +318,10 @@ require(["map"], function (Map) {
return el
}
self.setGoto = function (d) {
gotoAnything = d
}
return self
}
@ -605,6 +613,14 @@ require(["map"], function (Map) {
var targets = []
var self = this
infobox.setGoto(self)
function resetView() {
targets.forEach( function (t) {
t.resetView()
})
}
function gotoNode(d, showMap, push) {
showMap = trueDefault(showMap)
push = trueDefault(push)
@ -639,6 +655,7 @@ require(["map"], function (Map) {
this.node = function (d, m, p) { return function () { return gotoNode(d, m, p) }}
this.link = function (d, m, p) { return function () { return gotoLink(d, m, p) }}
this.reset = resetView
this.addMarkers = function (d) {
markers = d
}

View File

@ -52,6 +52,8 @@ define(function () {
var iconOffline = { color: "#D43E2A", radius: 6, fillOpacity: 0.5, weight: 2, className: "stroke-first" }
var iconNew = { color: "#558020", radius: 6, fillOpacity: 0.5, weight: 2, className: "stroke-first" }
var groupOnline, group
return function (sidebar) {
var self = this
@ -92,8 +94,13 @@ define(function () {
.map(mkMarker(nodeDict, function (d) { return iconOnline }, gotoAnything))
var groupLines = L.featureGroup(lines).addTo(map)
var groupOnline = L.featureGroup(onlinemarkers).addTo(map)
var group = L.featureGroup(markers).addTo(map)
groupOnline = L.featureGroup(onlinemarkers).addTo(map)
group = L.featureGroup(markers).addTo(map)
resetView()
}
function resetView() {
resetMarkerStyles(nodeDict, linkDict)
var bounds = group.getBounds()
@ -135,6 +142,8 @@ define(function () {
return m
}
self.resetView = resetView
self.gotoNode = function (d) {
resetMarkerStyles(nodeDict, linkDict)
@ -142,6 +151,8 @@ define(function () {
if (m)
m.setStyle({ fillColor: m.options.color, color: "orange", weight: 20, fillOpacity: 1, opacity: 0.7 })
else
resetView()
}
self.gotoLink = function (d) {
@ -151,6 +162,8 @@ define(function () {
if (m)
m.setStyle({ weight: 7, opacity: 1, dashArray: "10, 10" })
else
resetView()
}
return self