amap
1 Procedure Reference
current-amap-key
amap-request
http-response-body/  json
geocode/  geo
ip
2 Example
7.4

amap

Yanying Wang <yanyingwang1@gmail.com>

 (require amap) package: amap

Gaode Amap web service API, you can check official api page as well.

Source code: https://gitlab.com/yanyingwang/amap

1 Procedure Reference

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"
return the geocode of the address, you can also check original amap doc for more details.

procedure

(ip ip-str)  http-response?

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

2 Example

(current-amap-key "your amap key here")
 
(current-amap-key) ;=> show your amap key that you've just set.
 
 
(geocode/geo "万国博览建筑群" #:city "shanghai" #:output "xml")
(http-response
 200
 '#hash(("Access-Control-Allow-Origin" . "*")
        ("Date" . "Mon, 28 Oct 2019 07:20:58 GMT")
        ("sc" . "0.009")
        ("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")
        ("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((count . "1")
         (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")
         (infocode . "10000")
         (status . "1"))
 
 
 
> (http-response-body/json (ip "61.151.166.146"))
'#hasheq((adcode . "310000")
         (city . "上海市")
         (info . "OK")
         (infocode . "10000")
         (province . "上海市")
         (rectangle . "120.8397067,30.77980118;122.1137989,31.66889673")
         (status . "1"))