resetView
This commit is contained in:
parent
14d86c06af
commit
8a2300578a
@ -109,6 +109,8 @@ require(["map"], function (Map) {
|
|||||||
historyDict.links[linkId(d)] = d
|
historyDict.links[linkId(d)] = d
|
||||||
})
|
})
|
||||||
|
|
||||||
|
gotoAnything.reset()
|
||||||
|
|
||||||
gotoHistory(gotoAnything, historyDict, window.location.hash)
|
gotoHistory(gotoAnything, historyDict, window.location.hash)
|
||||||
|
|
||||||
window.onpopstate = function (d) {
|
window.onpopstate = function (d) {
|
||||||
@ -280,10 +282,12 @@ require(["map"], function (Map) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Infobox(sidebar) {
|
function Infobox(sidebar) {
|
||||||
|
var gotoAnything
|
||||||
var self = this
|
var self = this
|
||||||
el = undefined
|
el = undefined
|
||||||
|
|
||||||
function close() {
|
function close() {
|
||||||
|
gotoAnything.reset()
|
||||||
destroy()
|
destroy()
|
||||||
pushHistory()
|
pushHistory()
|
||||||
}
|
}
|
||||||
@ -314,6 +318,10 @@ require(["map"], function (Map) {
|
|||||||
return el
|
return el
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.setGoto = function (d) {
|
||||||
|
gotoAnything = d
|
||||||
|
}
|
||||||
|
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -605,6 +613,14 @@ require(["map"], function (Map) {
|
|||||||
var targets = []
|
var targets = []
|
||||||
var self = this
|
var self = this
|
||||||
|
|
||||||
|
infobox.setGoto(self)
|
||||||
|
|
||||||
|
function resetView() {
|
||||||
|
targets.forEach( function (t) {
|
||||||
|
t.resetView()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function gotoNode(d, showMap, push) {
|
function gotoNode(d, showMap, push) {
|
||||||
showMap = trueDefault(showMap)
|
showMap = trueDefault(showMap)
|
||||||
push = trueDefault(push)
|
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.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.link = function (d, m, p) { return function () { return gotoLink(d, m, p) }}
|
||||||
|
this.reset = resetView
|
||||||
this.addMarkers = function (d) {
|
this.addMarkers = function (d) {
|
||||||
markers = d
|
markers = d
|
||||||
}
|
}
|
||||||
|
17
lib/map.js
17
lib/map.js
@ -52,6 +52,8 @@ define(function () {
|
|||||||
var iconOffline = { color: "#D43E2A", radius: 6, fillOpacity: 0.5, weight: 2, className: "stroke-first" }
|
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 iconNew = { color: "#558020", radius: 6, fillOpacity: 0.5, weight: 2, className: "stroke-first" }
|
||||||
|
|
||||||
|
var groupOnline, group
|
||||||
|
|
||||||
return function (sidebar) {
|
return function (sidebar) {
|
||||||
var self = this
|
var self = this
|
||||||
|
|
||||||
@ -92,8 +94,13 @@ define(function () {
|
|||||||
.map(mkMarker(nodeDict, function (d) { return iconOnline }, gotoAnything))
|
.map(mkMarker(nodeDict, function (d) { return iconOnline }, gotoAnything))
|
||||||
|
|
||||||
var groupLines = L.featureGroup(lines).addTo(map)
|
var groupLines = L.featureGroup(lines).addTo(map)
|
||||||
var groupOnline = L.featureGroup(onlinemarkers).addTo(map)
|
groupOnline = L.featureGroup(onlinemarkers).addTo(map)
|
||||||
var group = L.featureGroup(markers).addTo(map)
|
group = L.featureGroup(markers).addTo(map)
|
||||||
|
resetView()
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetView() {
|
||||||
|
resetMarkerStyles(nodeDict, linkDict)
|
||||||
|
|
||||||
var bounds = group.getBounds()
|
var bounds = group.getBounds()
|
||||||
|
|
||||||
@ -135,6 +142,8 @@ define(function () {
|
|||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.resetView = resetView
|
||||||
|
|
||||||
self.gotoNode = function (d) {
|
self.gotoNode = function (d) {
|
||||||
resetMarkerStyles(nodeDict, linkDict)
|
resetMarkerStyles(nodeDict, linkDict)
|
||||||
|
|
||||||
@ -142,6 +151,8 @@ define(function () {
|
|||||||
|
|
||||||
if (m)
|
if (m)
|
||||||
m.setStyle({ fillColor: m.options.color, color: "orange", weight: 20, fillOpacity: 1, opacity: 0.7 })
|
m.setStyle({ fillColor: m.options.color, color: "orange", weight: 20, fillOpacity: 1, opacity: 0.7 })
|
||||||
|
else
|
||||||
|
resetView()
|
||||||
}
|
}
|
||||||
|
|
||||||
self.gotoLink = function (d) {
|
self.gotoLink = function (d) {
|
||||||
@ -151,6 +162,8 @@ define(function () {
|
|||||||
|
|
||||||
if (m)
|
if (m)
|
||||||
m.setStyle({ weight: 7, opacity: 1, dashArray: "10, 10" })
|
m.setStyle({ weight: 7, opacity: 1, dashArray: "10, 10" })
|
||||||
|
else
|
||||||
|
resetView()
|
||||||
}
|
}
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
Loading…
Reference in New Issue
Block a user