2010/07/11

teepeedee2 と Google Map と Parenscript

html も css も js も全て S 式はいいな。

(eval-when (:compile-toplevel :load-toplevel :execute)
(require :teepeedee2))

(defpackage :gmap
(:use :cl :tpd2 :tpd2.ml :tpd2.ml.html))

(in-package :gmap)

(defpage "/" ()
(with-ml-output
(output-raw-ml "<!DOCTYPE html>")
(<html
(<head
(<meta :name "viewport" :content "initial-scale=1.0, user-scalable=no")
(css-html-style
(<html :height "100%")
(<body :height "100%" :margin "0px" :padding "0px")
("#map_canvas" :height "100%"))
(<script :type "text/javascript" :src "http://maps.google.com/maps/api/js?sensor=true")
(js-html-script-as-bv
(defun initialize ()
(let* ((latlng (ps:new (ps:chain google maps (-lat-lng 35.374499568225296 133.5380996728516))))
(my-options (ps:create zoom 8
center latlng
map-type-id (ps:@ google maps -map-type-id -r-o-a-d-m-a-p)))
(map (ps:new (ps:chain google maps
(-map (ps:chain document (get-element-by-id "map_canvas"))
my-options)))))
;; click した場所の latlng を表示
(ps:chain google maps event
(add-listener map "click" (lambda (e)
(alert (ps:@ e lat-lng))))))))
(<title "地図で遊ぶ"))
(<body :onload "initialize()"
(<div :id "map_canvas" :style "width:100%; height:100%")))))


(defun start ()
"Visit http://localhost:8080/"
(http-start-server 8080)
(sb-thread:make-thread #'event-loop :name "tpd2"))
;;(gmap::start)

0 件のコメント: