使用 时Geo::Coder:Google
,从地址到纬度/经度的映射反之亦然。
但是输出不适合直接访问具体字段,尤其是在将纬度/经度转换为地址时。
根据我的调试日志:
loc by lat 48.308472 / lon 14.284578 ---\ {#012 address_components [#012 [0] {#012 long_name "Nibelungenbrücke",#012 short_name "B129",#012 types [#012 [0] "route"#012 ]#012 },#012 [1] {#012 long_name "Landstraße",#012 short_name "Landstraße",#012 types [#012 [0] "neighborhood",#012 [1] "political"#012 ]#012 },#012 [2] {#012 long_name "Innenstadt",#012 short_name "Innenstadt",#012 types [#012 [0] "sublocality",#012 [1] "political"#012 ]#012 },#012 [3] {#012 long_name "Linz",#012 short_name "Linz",#012 types [#012 [0] "locality",#012 [1] "political"#012 ]#012 },#012 [4] {#012 long_name "Linz",#012 short_name "Linz",#012 types [#012 [0] "administrative_area_level_2",#012 [1] "political"#012 ]#012 },#012 [5] {#012 long_name "Upper Austria",#012 short_name "OÖ",#012 types [#012 [0] "administrative_area_level_1",#012 [1] "political"#012 ]#012 },#012 [6] {#012 long_name "Austria",#012 short_name "AT",#012 types [#012 [0] "country",#012 [1] "political"#012 ]#012 },#012 [7] {#012 long_name 4020,#012 short_name 4020,#012 types [#012 [0] "postal_code"#012 ]#012 }#012 ],#012 formatted_address "Nibelungenbrücke, 4020 Linz, Austria",#012 geometry {#012 bounds {#012 n
使用子字符串 subs 会让我发疯。目前,代码:
sub map_latlon_to_loc($$){ my $lat = shift; my $lon = shift;
$location = $geocoder_google->reverse_geocode(latlng => $lat.','.$lon);
dbg("loc by lat ".$lat." / lon ".$lon." --- " . p $location);
}
哪种具体方式/方法/子适合访问其中的属性$location
?
btwp
指的是打印机模块