amap
1 Examples
2 API
current-amap-key
amap-request
http-response-body/  json
geocode/  geo
ip
8.12

amap🔗ℹ

Yanying Wang <yanyingwang1@gmail.com>

 (require amap) package: amap

Gaode Amap web service API, Check out official api page as well.

    1 Examples

    2 API

1 Examples🔗ℹ

> (current-amap-key "put your amap key here")

> (current-amap-key) ; show your amap key that you've just setted

> (geocode/geo "万国博览建筑群" #:city "shanghai" #:output "xml")
  (http-response
   200
   '#hash(
  
          ("sc" . "0.009"). #<forced-pair> .
          ("Transfer-Encoding" . "chunked")
          ("Vary" . "Accept-Encoding")
  
  
      ("Access-Control-Allow-Headers" . "DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,key,x-biz,x-info,platinfo,encr,enginever,gzipped,poiid")
          ("Content-Type" . "application/xml;charset=UTF-8")
          ("gsid" . "011025230097157224725840000020375504374")
          ("Connection" . "close"). #<forced-pair> .
          ("Access-Control-Allow-Methods" . "*")
          ("X-Powered-By" . "ring/1.0.0"))
   "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<response><status>1</status><info>OK</info><infocode>10000</infocode><count>1</count><geocodes type=\"list\"><geocode><formatted_address>上海市黄浦区万国博览建筑群</formatted_address><country>中国</country><province>上海市</province><citycode>021</citycode><city>上海市</city><district>黄浦区</district><township></township><neighborhood><name></name><type></type></neighborhood><building><name></name><type></type></building><adcode>310101</adcode><street></street><number></number><location>121.489026,31.239125</location><level>兴趣点</level></geocode></geocodes></response>")
> (http-response-body/json
    (geocode/geo "东方明珠" #:city "shanghai"))
  '#hasheq(
  
  
       (geocodes . (#hasheq((adcode . "310115")
                            (building . #hasheq((name)      (type)))
                            (city . "上海市")
                            (citycode . "021")
                            (country . "中国")
                            (district . "浦东新区")
                            (formatted_address . "上海市浦东新区东方明珠")
                            (level . "兴趣点")
                            (location . "121.499740,31.239853")
                            (neighborhood . #hasheq((name)      (type)))
                            (number)
                            (province . "上海市")
                            (street)
                            (township))))
           (info . "OK"). #<forced-pair> .
           (infocode . "10000")
           (status . "1"))

> (http-response-body/json (ip "61.151.166.146"))
  '#hasheq(
           (city . "上海市")
           (info . "OK"). #<forced-pair> .
           (infocode . "10000")
           (province . "上海市")
           (rectangle . "120.8397067,30.77980118;122.1137989,31.66889673")
           (status . "1"))

2 API🔗ℹ

procedure

(current-amap-key key)  string?

  key : string?
Set Amap’s API key, which key you can get it from the Amap webside after you sign in as a developer. And this key will be used for requesting data from it’s website.
If calling the procedure without key, it’ll show the current value.

procedure

(amap-request path parameters)  http-response?

  path : string?
  parameters : (listof hash? alist?)
Execute the requesting to amap API.

procedure

(http-response-body/json struct)  jsexpr?

  struct : http-response?
Parsing the result of http requesting and retrun a racket hash data.

procedure

(geocode/geo address    
  #:city city    
  [#:batch batch    
  #:output output])  http-response?
  address : string?
  city : string?
  batch : string? = "false"
  output : string? = "json"
Returns the geocode of the address, you can also check original amap doc for more details.

procedure

(ip ip-str)  http-response?

  ip-str : string?
Returns information of an IP.