Skip to content

Instantly share code, notes, and snippets.

@IndianGuru
Last active October 2, 2015 08:19
Show Gist options
  • Select an option

  • Save IndianGuru/8d8df9e089e36271ebc9 to your computer and use it in GitHub Desktop.

Select an option

Save IndianGuru/8d8df9e089e36271ebc9 to your computer and use it in GitHub Desktop.
blobstrex4.go
func handleServe(w http.ResponseWriter, r *http.Request) {
// Instantiate blobstore reader
reader := blobstore.NewReader(appengine.NewContext(r),
appengine.BlobKey(r.FormValue("blobKey")))
lat, lng, _ := getLatLng(reader)
blobstore.Delete(appengine.NewContext(r),
appengine.BlobKey(r.FormValue("blobKey")))
if lat == "" {
io.WriteString(w, "Sorry but your photo has no GeoTag information...")
return
}
s := "http://maps.googleapis.com/maps/api/staticmap?zoom=5&size=600x300&maptype=roadmap&center="
s = s + lat + "," + lng + "&markers=color:blue%7Clabel:I%7C" + lat + "," + lng
img := "<img src='" + s + "' alt='map' />"
fmt.Fprint(w, img)
}
func getLatLng(f io.Reader) (string, string, error) {
// Decode parses EXIF-encoded data from f
// and returns a queryable Exif object.
x, err := exif.Decode(f)
if err != nil {
return "", "", err
}
lat, lng, _ := x.LatLong()
latstr := strconv.FormatFloat(lat, 'f', 15, 64)
lngstr := strconv.FormatFloat(lng, 'f', 15, 64)
return latstr, lngstr, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment