mirror of https://github.com/jlelse/GoBlog
Fix
This commit is contained in:
parent
0ea54f87a6
commit
55ef904286
28
geoMap.go
28
geoMap.go
|
@ -61,16 +61,24 @@ func (a *goBlog) serveGeoMap(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
locationsJsonBytes, err := json.Marshal(locations)
|
locationsJson := ""
|
||||||
if err != nil {
|
if len(locations) > 0 {
|
||||||
a.serveError(w, r, err.Error(), http.StatusInternalServerError)
|
locationsJsonBytes, err := json.Marshal(locations)
|
||||||
return
|
if err != nil {
|
||||||
|
a.serveError(w, r, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
locationsJson = string(locationsJsonBytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
tracksJsonBytes, err := json.Marshal(tracks)
|
tracksJson := ""
|
||||||
if err != nil {
|
if len(tracks) > 0 {
|
||||||
a.serveError(w, r, err.Error(), http.StatusInternalServerError)
|
tracksJsonBytes, err := json.Marshal(tracks)
|
||||||
return
|
if err != nil {
|
||||||
|
a.serveError(w, r, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
tracksJson = string(tracksJsonBytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
mapPath := bc.getRelativePath(defaultIfEmpty(bc.Map.Path, defaultGeoMapPath))
|
mapPath := bc.getRelativePath(defaultIfEmpty(bc.Map.Path, defaultGeoMapPath))
|
||||||
|
@ -78,8 +86,8 @@ func (a *goBlog) serveGeoMap(w http.ResponseWriter, r *http.Request) {
|
||||||
BlogString: blog,
|
BlogString: blog,
|
||||||
Canonical: a.getFullAddress(mapPath),
|
Canonical: a.getFullAddress(mapPath),
|
||||||
Data: map[string]interface{}{
|
Data: map[string]interface{}{
|
||||||
"locations": string(locationsJsonBytes),
|
"locations": locationsJson,
|
||||||
"tracks": string(tracksJsonBytes),
|
"tracks": tracksJson,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
(function () {
|
(function () {
|
||||||
let mapEl = document.getElementById('map')
|
let mapEl = document.getElementById('map')
|
||||||
let locations = JSON.parse(mapEl.dataset.locations)
|
let locations = (mapEl.dataset.locations == "") ? [] : JSON.parse(mapEl.dataset.locations)
|
||||||
let tracks = JSON.parse(mapEl.dataset.tracks)
|
let tracks = (mapEl.dataset.tracks == "") ? [] : JSON.parse(mapEl.dataset.tracks)
|
||||||
|
|
||||||
let map = L.map('map')
|
let map = L.map('map')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue