#lang planet dyoo/whalesong ;; A simple binding to Google Maps. ;; ;; Some of this comes from: ;; ;; https://developers.google.com/maps/documentation/javascript/tutorial ;; (require (planet dyoo/whalesong/js) (planet dyoo/whalesong/js/world)) (provide initialize-google-maps-api! make-dom-and-map make-on-map-click) ;; initialize-google-maps-api!: string boolean -> void ;; Dynamically loads the Google Maps API. (define raw-initialize-google-maps-api! (js-async-function->procedure #<procedure #<procedure #< (values dom-node gmap-object) ;; Given a latitude and longitude, creates a dom node that presents a ;; Google Map, along with the gmap-object that carries its map state. ;; TODO: We may want to provide a higher-level abstraction that ;; encapsulates the two into a structured value. (define (make-dom-and-map lat lng) (unless (real? lat) (raise-type-error 'make-dom-and-map "real" 0 lat)) (unless (real? lng) (raise-type-error 'make-dom-and-map "real" 1 lng)) (raw-make-map-dom-and-map (number->js-number lat) (number->js-number lng))) ;; make-on-map-click: gmap-object -> world-handler ;; TODO: We may want to provide a higher-level abstraction that ;; encapsulates the two into a structured value. (define make-on-map-click raw-make-on-map-click) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;