Commits

camlspotter committed e12c268

function renames

  • Participants
  • Parent commits d0f001e

Comments (0)

Files changed (5)

 open XJs.Std
 open Lwt
 
-let () = GChart.load ()
+let () = GChart.load_via_ajax_api_loader ()
 
 (* eval_string cannot define a function. i.e.
 
 
 include Visualization
 
-let load () = 
-  Google.load_api !$"visualization" !$"1.0" 
+let load_via_ajax_api_loader () = 
+  Google.load_ajax_api !$"visualization" !$"1.0" 
   & Unsafe.variable "{'packages':['corechart']}"
 
 (** [load ()] must be done before [get ()] *)
   in
   Base.load_script (Printf.sprintf "http://maps.googleapis.com/maps/api/js?%s" q)
 
+(* Not yet done. 
+   See: http://stackoverflow.com/questions/5296115/can-you-load-google-maps-api-v3-via-google-ajax-api-loader
+
+let load_via_ajax_api_loader ~sensor ~key ?callback () = 
+  let q = 
+    URL.make_query 
+    & List.filter_map (fun (k,v) -> Option.map ~f:(fun v -> (k, v)) v)
+      [ "key", Some key;
+        "sensor", Some ((function true -> "true" | false -> "false") sensor);
+        "callback", Option.map ~f:id callback]
+  in
+  Base.load_script (Printf.sprintf "http://maps.googleapis.com/maps/api/js?%s" q)
+*)
+
 let get () : t Js.t = Unsafe.variable "google.maps"
 
 let latlng (maps : t Js.t) lat lng = jsnew (maps##_LatLng) (lat, lng)
 let get_google : unit -> t Js.t = fun () -> Unsafe.variable "google"
 (** The variable "google" may not exist when API loading is delayed *)
 
-let load_api : string_t -> string_t -> 'option Js.t -> unit = 
+let load_ajax_api : string_t -> string_t -> 'option Js.t -> unit = 
   fun name version option -> (get_google()) ## load (name, version, option)
 
 let setOnLoadCallback f = (get_google()) ## setOnLoadCallback (f)
 val get_google : unit -> t Js.t
 (** Get the variable "google" *)
 
-val load_api : string_t -> string_t -> 'option Js.t -> unit
+val load_ajax_api : string_t -> string_t -> 'option Js.t -> unit
 (** Load a specific Google API.
     The Loader API must be loaded beforehand by
     <script type="text/javascript" src="https://www.google.com/jsapi"/>