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