Link maps by lat/lon instead of address
This commit is contained in:
parent
04e1f99872
commit
f07bb9d94b
@ -128,7 +128,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
{{#each records}}
|
{{#each records}}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="https://maps.google.com/?q={{#urlEncode}}{{address}}{{/urlEncode}}" target="_blank" onclick="javascript:accessReview({{id}});">{{name}}</a></td>
|
<td><a href="http://maps.google.com/maps?q={{geo.latitude}},{{geo.longitude}}" target="_blank" onclick="javascript:accessReview({{id}});">{{name}}</a></td>
|
||||||
<td>{{#prettyFloat 2}}{{distanceToUser}}{{/prettyFloat}} km</td>
|
<td>{{#prettyFloat 2}}{{distanceToUser}}{{/prettyFloat}} km</td>
|
||||||
<td>{{closestStn}}</td>
|
<td>{{closestStn}}</td>
|
||||||
<td>{{#prettyFloat 2}}{{distanceToStn}}{{/prettyFloat}} km</td>
|
<td>{{#prettyFloat 2}}{{distanceToStn}}{{/prettyFloat}} km</td>
|
||||||
|
@ -47,10 +47,6 @@
|
|||||||
return parseFloat(options.fn(this)).toFixed(precision);
|
return parseFloat(options.fn(this)).toFixed(precision);
|
||||||
});
|
});
|
||||||
|
|
||||||
Handlebars.registerHelper('urlEncode', function(options) {
|
|
||||||
return encodeURIComponent(options.fn(this));
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#minScore,#resolution,#walkingDist,#maxResults').change(onSearch);
|
$('#minScore,#resolution,#walkingDist,#maxResults').change(onSearch);
|
||||||
$('#profileDlg').on('hidden.bs.modal', onSearch);
|
$('#profileDlg').on('hidden.bs.modal', onSearch);
|
||||||
$('#resetStorage').click(function() {
|
$('#resetStorage').click(function() {
|
||||||
|
2
types.go
2
types.go
@ -63,8 +63,8 @@ type record struct {
|
|||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Score float64 `json:"score"`
|
Score float64 `json:"score"`
|
||||||
Address string `json:"address"`
|
Address string `json:"address"`
|
||||||
|
Geo geoData `json:"geo"`
|
||||||
features map[string]float64
|
features map[string]float64
|
||||||
geo geoData
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type queryContext struct {
|
type queryContext struct {
|
||||||
|
13
util.go
13
util.go
@ -169,7 +169,7 @@ func computeRecordGeo(entries []record, context queryContext) {
|
|||||||
|
|
||||||
if context.geo != nil {
|
if context.geo != nil {
|
||||||
userPoint := geo.NewPoint(context.geo.Latitude, context.geo.Longitude)
|
userPoint := geo.NewPoint(context.geo.Latitude, context.geo.Longitude)
|
||||||
entryPoint := geo.NewPoint(entry.geo.Latitude, context.geo.Longitude)
|
entryPoint := geo.NewPoint(entry.Geo.Latitude, context.geo.Longitude)
|
||||||
entry.DistanceToUser = userPoint.GreatCircleDistance(entryPoint)
|
entry.DistanceToUser = userPoint.GreatCircleDistance(entryPoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,7 +283,8 @@ func fetchRecords(db *sql.DB, context queryContext) ([]record, error) {
|
|||||||
&distanceToStn,
|
&distanceToStn,
|
||||||
&closestStn,
|
&closestStn,
|
||||||
&accessCount,
|
&accessCount,
|
||||||
&id)
|
&id,
|
||||||
|
)
|
||||||
|
|
||||||
entry := record{
|
entry := record{
|
||||||
Name: name,
|
Name: name,
|
||||||
@ -291,14 +292,16 @@ func fetchRecords(db *sql.DB, context queryContext) ([]record, error) {
|
|||||||
DistanceToStn: distanceToStn,
|
DistanceToStn: distanceToStn,
|
||||||
ClosestStn: closestStn,
|
ClosestStn: closestStn,
|
||||||
AccessCount: accessCount,
|
AccessCount: accessCount,
|
||||||
geo: geoData{latitude, longitude},
|
Geo: geoData{latitude, longitude},
|
||||||
Id: id}
|
Id: id,
|
||||||
|
}
|
||||||
|
|
||||||
entry.features = map[string]float64{
|
entry.features = map[string]float64{
|
||||||
"delicious": delicious,
|
"delicious": delicious,
|
||||||
"accommodating": accommodating,
|
"accommodating": accommodating,
|
||||||
"affordable": affordable,
|
"affordable": affordable,
|
||||||
"atmospheric": atmospheric}
|
"atmospheric": atmospheric,
|
||||||
|
}
|
||||||
|
|
||||||
entries = append(entries, entry)
|
entries = append(entries, entry)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user