一、地理编码

该功能实现地理编码服务,即地址匹配,从已知的地址描述到对应的经纬度坐标的转换,即根据地址信息,查询该地址所对应的点坐标等,地址(address) 为必选项,城市(city)为可选项。

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Grid Opacity="0.8" Margin="0,0,0,608" Background="#FF323232" RenderTransformOrigin="0.497,0.465" Canvas.ZIndex="10" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="地理编码" Margin="3,0,0,0" />
<StackPanel Grid.Row="1" Orientation="Vertical">
<TextBox x:Name="txtAddress" Grid.Row="0" Text="北京市朝阳区望京阜通东大街方恒国际中心" Margin="12,0,0,0" />
<Button Content="地理编码" Click="Button_Click" Margin="274,0,26,0" />
</StackPanel>
</Grid>
</Grid>
        AMap amap;
AMapMarker marker;
public SearchGeoCode()
{
InitializeComponent();
this.ContentPanel.Children.Add(amap = new AMap());
amap.MarkerClickListener += amap_MarkerClickListener; } private async Task AddressToGeoCode(string address)
{
AMapGeoCodeResult cr = await AMapGeoCodeSearch.AddressToGeoCode(address);
this.Dispatcher.BeginInvoke(() =>
{
if (cr.Erro == null && cr.GeoCodeList != null)
{
if (cr.GeoCodeList.Count==)
{
MessageBox.Show("无查询结果");
return;
}
IEnumerable<AMapGeoCode> geocode = cr.GeoCodeList;
foreach (AMapGeoCode gcs in geocode)
{
Debug.WriteLine(gcs.Adcode);
Debug.WriteLine(gcs.Building);
Debug.WriteLine(gcs.City);
Debug.WriteLine(gcs.District);
Debug.WriteLine(gcs.FormattedAddress);
Debug.WriteLine(gcs.Province);
Debug.WriteLine(gcs.Township);
Debug.WriteLine(gcs.Location.Lon);
Debug.WriteLine(gcs.Location.Lat);
Debug.WriteLine(gcs.LevelList[]);
marker= amap.AddMarker(new AMapMarkerOptions()
{
Position = new LatLng(gcs.Location.Lat, gcs.Location.Lon),
Title = gcs.FormattedAddress,
Snippet = gcs.District,
IconUri = new Uri("Images/AZURE.png", UriKind.Relative), });
}
//如果返回的geocode数大于1个,调整视图
if (geocode.Count()>)
{
LatLngBounds.Builder builder = new LatLngBounds.Builder();
List<AMapMarker> markers = amap.GetMapMarkers();
foreach (AMapMarker marker in markers)
{
builder.Include(marker.Position);
}
this.amap.MoveCamera(CameraUpdateFactory.NewLatLngBounds(builder.Build(), markers.Count()));
}
else
{
amap.MoveCamera(CameraUpdateFactory.NewLatLngZoom(new LatLng(geocode.FirstOrDefault().Location.Lat, geocode.FirstOrDefault().Location.Lon), ));
}
}
else
{
MessageBox.Show(cr.Erro.Message);
} });
} void amap_MarkerClickListener(AMapMarker sender, AMapEventArgs args)
{
sender.ShowInfoWindow(new AInfoWindow()
{
Title = sender.Title,
ContentText =sender.Snippet,
});
} private async void Button_Click(object sender, RoutedEventArgs e)
{
amap.Clear();
if (!string.IsNullOrWhiteSpace(txtAddress.Text))
{
await AddressToGeoCode(txtAddress.Text);
} }

二、逆地理编码

该功能实现逆地理编码服务,即地址解析服务,具体是指从已知的经纬度坐标到对应的地址描述(如省市、街区、楼层、房间等)的转换服务,坐标(location) 为必选项,半径(radius)为可选项,详细的参数说明参见参考手册。

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Grid Opacity="0.8" Margin="0,0,0,568" Background="#FF323232" RenderTransformOrigin="0.497,0.465" Canvas.ZIndex="10" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="逆地理编码" Margin="3,0,0,0" /> <Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="经度:" Margin="12,0,0,0" VerticalAlignment="Center" />
<TextBlock Grid.Row="1" Grid.Column="0" Text="纬度:" Margin="12,0,0,0" VerticalAlignment="Center" />
<TextBox x:Name="txtLon" Grid.Row="0" Grid.Column="1" Text="" Width="180" />
<TextBox x:Name="txtLat" Grid.Row="1" Grid.Column="1" Text="" Width="180" />
<TextBlock Grid.Row="2" Text="点击或者输入获得经纬度" Grid.ColumnSpan="2" Margin="3,0,0,0" />
</Grid>
<Button Content="逆地理编码" Click="Button_Click" Margin="257,69,29,3" Grid.Row="1" /> </Grid>
        AMap amap;
AMapMarker marker;
LatLng latLng;
public SearchReGeoCode()
{
InitializeComponent();
this.ContentPanel.Children.Add(amap = new AMap());
amap.Tap += amap_Tap;
amap.MarkerClickListener += amap_MarkerClickListener; } void amap_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
latLng = amap.GetProjection().FromScreenLocation(e.GetPosition(amap));
this.txtLat.Text = latLng.latitude.ToString();
this.txtLon.Text = latLng.longitude.ToString();
} private async Task GeoCodeToAddress(double lon, double lat)
{
AMapReGeoCodeResult rcc = await AMapReGeoCodeSearch.GeoCodeToAddress(lon, lat, , "", Extensions.All); this.Dispatcher.BeginInvoke(() =>
{
if (rcc.Erro == null && rcc.ReGeoCode != null)
{
AMapReGeoCode regeocode = rcc.ReGeoCode;
Debug.WriteLine(regeocode.Address_component);
Debug.WriteLine(regeocode.Formatted_address);
Debug.WriteLine(regeocode.Pois); List<AMapPOI> pois = regeocode.Pois.ToList();
//POI信息点
foreach (AMapPOI poi in pois)
{
marker = amap.AddMarker(new AMapMarkerOptions()
{
Position = new LatLng(poi.Location.Lat, poi.Location.Lon),
Title = poi.Name,
Snippet = poi.Address,
IconUri = new Uri("Images/RED.png", UriKind.Relative), });
} Debug.WriteLine(regeocode.Roadinters);
Debug.WriteLine(regeocode.Roadslist);
AMapAddressComponent addressComponent = regeocode.Address_component;
Debug.WriteLine(addressComponent.Building);
Debug.WriteLine(addressComponent.City);
Debug.WriteLine(addressComponent.District);
Debug.WriteLine(addressComponent.Neighborhood);
Debug.WriteLine(addressComponent.Province);
Debug.WriteLine(addressComponent.Stree_number);
Debug.WriteLine(addressComponent.Township);
AMapStreetNumber streetNumber = addressComponent.Stree_number;
Debug.WriteLine(streetNumber.Direction);
Debug.WriteLine(streetNumber.Distance);
Debug.WriteLine(streetNumber.Location.Lat);
Debug.WriteLine(streetNumber.Location.Lon);
Debug.WriteLine(streetNumber.Number);
Debug.WriteLine(streetNumber.Street); marker = amap.AddMarker(new AMapMarkerOptions()
{
Position = new LatLng(streetNumber.Location.Lat, streetNumber.Location.Lon),//amap.Center,//
Title = addressComponent.Province,
Snippet = regeocode.Formatted_address,
IconUri = new Uri("Images/AZURE.png", UriKind.Relative), }); //显示化弹出信息
AInfoWindow info = new AInfoWindow();
info.Title = addressComponent.Province;
info.ContentText = regeocode.Formatted_address;
marker.ShowInfoWindow(info, new Point(, )); amap.MoveCamera(CameraUpdateFactory.NewLatLngZoom(new LatLng(Convert.ToDouble(txtLon.Text), Convert.ToDouble(txtLat.Text)), ));
}
else
{
MessageBox.Show(rcc.Erro.Message);
} }); } void amap_MarkerClickListener(AMapMarker sender, AMapEventArgs args)
{
sender.ShowInfoWindow(new AInfoWindow()
{
Title = sender.Title,
ContentText = sender.Snippet,
});
} private async void Button_Click(object sender, RoutedEventArgs e)
{
amap.Clear();
if (string.IsNullOrWhiteSpace(txtLat.Text) && string.IsNullOrWhiteSpace(txtLon.Text))
{
return;
}
await GeoCodeToAddress(Convert.ToDouble(txtLon.Text), Convert.ToDouble(txtLat.Text));
}

三、同时使用地理编码和逆地理编码

已知一个地址或者模糊地址,然后你想知道该地址详细信息或者周边信息(周边POI点)。先通过地址获取经纬度,然后通过逆地理编码获取详细信息。在此不作出示例。

四、批量逆地理编码

目前高德地图WP SDK中并没有提供直接批量转换的接口,而在REST API中已经提供了,你可以在开发者论坛REST API版块中提出接口使用申请,链接:高德地图rest api接口申请方式

【高德地图API】地理编码与逆地理编码的更多相关文章

  1. 【高德地图API】从零开始学高德JS API(八)——地址解析与逆地址解析

    原文:[高德地图API]从零开始学高德JS API(八)——地址解析与逆地址解析 摘要:无论是百度LBS开放平台,还是高德LBS开放平台,其调用量最高的接口,必然是定位,其次就是地址解析了,又称为地理 ...

  2. 【百度地图API】如何制作班级地理通讯录?LBS通讯录

    原文:[百度地图API]如何制作班级地理通讯录?LBS通讯录 摘要:班级通讯录必备的功能,比如人员列表,人员地理位置标注,展示复杂信息窗口,公交和驾车等.一般班级人员都不会超过300个,因为可以高效地 ...

  3. 高德地图api实现地址和经纬度的转换(python)

    利用高德地图web服务api实现地理/逆地址编码 api使用具体方法请查看官方文档 文档网址:http://lbs.amap.com/api/webservice/guide/api/georegeo ...

  4. 【高德地图API】如何解决坐标转换,坐标偏移?

    http://bbs.amap.com/thread-18617-1-1.html#rd?sukey=cbbc36a2500a2e6c2b0b19115118ace519002ff3a52731f13 ...

  5. 【高德地图API】汇润做爱地图技术大揭秘

    原文:[高德地图API]汇润做爱地图技术大揭秘 昨日收到了高德地图微信公众号的消息推送,说有[一大波免费情趣用品正在袭来],点进去看了一眼,说一个电商公司(估计是卖情趣用品的)用高德云图制作了一张可以 ...

  6. 【高德地图API】从零开始学高德JS API(七)——定位方式大揭秘

    原文:[高德地图API]从零开始学高德JS API(七)——定位方式大揭秘 摘要:关于定位,分为GPS定位和网络定位2种.GPS定位,精度较高,可达到10米,但室内不可用,且超级费电.网络定位,分为w ...

  7. 【高德地图API】从零开始学高德JS API(六)——坐标转换

    原文:[高德地图API]从零开始学高德JS API(六)——坐标转换 摘要:如何从GPS转到谷歌?如何从百度转到高德?这些都是小case.我们还提供,如何将基站cell_id转换为GPS坐标? --- ...

  8. 【高德地图API】从零开始学高德JS API(五)路线规划——驾车|公交|步行

    原文:[高德地图API]从零开始学高德JS API(五)路线规划——驾车|公交|步行 先来看两个问题:路线规划与导航有什么区别?步行导航与驾车导航有什么区别? 回答: 1.路线规划,指的是为用户提供3 ...

  9. 【高德地图API】如何打造十月妈咪品牌地图?

    原文:[高德地图API]如何打造十月妈咪品牌地图? 摘要:品牌地图除了地图,商铺标点外,还有微博关注,路线查询等功能. ---------------------------------------- ...

随机推荐

  1. python 通过句柄获取窗口内容

    -- enoding:utf-8 -- 生成 buffer 对象 import win32con from win32gui import PyMakeBuffer, SendMessage, PyG ...

  2. C语言学习2

    C语言能够进行嵌套备注的方法: #if(0) do { scanf("%d", &n); getchar(); }]||n>a[M-]); #endif

  3. Linux 搭建 squid 代理服务器 三种模式

    CentOS 6.7 squid 代理服务器 一般有两张或以上网卡,一张链接公网,访问外网资源,一张位于局域网. 代理服务器可以提供文件缓存.复制和地址过滤等服务,充分利用有限的出口带宽,加快内部主机 ...

  4. PAT 1059. C语言竞赛

    PAT 1059. C语言竞赛 C语言竞赛是浙江大学计算机学院主持的一个欢乐的竞赛.既然竞赛主旨是为了好玩,颁奖规则也就制定得很滑稽: 冠军将赢得一份"神秘大奖"(比如很巨大的一本 ...

  5. Uva - 12230 Crossing Rivers (数学期望)

    你住在村庄A,每天需要过很多条河到另一个村庄B上班,B在A的右边,所有的河都在A,B之间,幸运的是每条船上都有自由移动的自动船, 因此只要到达河左岸然后等船过来,在右岸下船,上船之后船的速度不变.现在 ...

  6. 组队训练1 回放(转载至cxhscst2's blog)

      第一场组队训练……意料之中的爆炸. 开场先看题,H是斐波那契水题,qw把H切了. 同时czy看I题(排列),cst继续读其他题. czy尝试交I,PE. cst发现K是水题. cst上来敲K,WA ...

  7. PostgreSQL及PostGIS使用

    基础知识 参考文档:http://www.postgis.net/docs/ PostGIS支持的GIS对象是OpenGIS Consortium(OGC)定义的“简单特征”的超集.OpenGIS规范 ...

  8. [bzoj4826][Hnoi2017]影魔_单调栈_主席树

    影魔 bzoj-4826 Hnoi-2017 题目大意:给定一个$n$个数的序列$a$,求满足一下情况的点对个数: 注释:$1\le n,m\le 2\cdot 10^5$,$1\le p1,p2\l ...

  9. Codeforces 803F(容斥原理)

    题意: 给n个正整数,求有多少个GCD为1的子序列.答案对1e9+7取模. 1<=n<=1e5,数字ai满足1<=ai<=1e5 分析: 设f(x)表示以x为公约数的子序列个数 ...

  10. u启动为苹果笔记本重装win7系统教程

    准备更换系统的苹果笔记本一台!   上述需要准备的东西均准备好以后我们就开始今天的教程了!!   首先,将已经制作好启动盘的u启动u盘插入到苹果笔记本上的usb插口,然后开机!   由于苹果笔记本电脑 ...