一、地理编码

该功能实现地理编码服务,即地址匹配,从已知的地址描述到对应的经纬度坐标的转换,即根据地址信息,查询该地址所对应的点坐标等,地址(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. Spring AOP配置简单记录(注解及xml配置方式)

    在了解spring aop中的关键字(如:连接点(JoinPoint).切入点(PointCut).切面(Aspact).织入(Weaving).通知(Advice).目标(Target)等)后进行了 ...

  2. C51 中断 个人笔记

    总架构图 IE寄存器 控制各个中断源的屏蔽与允许 TCON寄存器 各个中断源的请求标志位&有效信号的规定 中断源及其优先级 中断号写程序的时候要用 CPU处理中断三原则 1.CPU同时接收到几 ...

  3. 接口测试工具-fiddler的运用

    本篇主要介绍一下fiddler的基本运用,包括查看接口请求方式,状态响应码,如何进行接口测试等 一.Fiddler的优点 独立的可以直接抓http请求 小巧.功能完善 快捷.启动就行 代理方便 二.什 ...

  4. HDU 4968 (水dp 其他?)

    +;],dp1[][],dp2[][]; map<      memset(GPA,,     ;i<=;i++) hash[i]=;     ;i<=;i++) hash[i]=; ...

  5. [ C语言 ] 迷宫 迷宫生成器 [ 递归与搜索 ]

    [原创]转载请注明出处 [浙江大学 程序设计专题] [地图求解器] 本题目要求输入一个迷宫地图,输出从起点到终点的路线. 基本思路是从起点(Sx,Sy)每次枚举该格子上下左右四个方向,直到走到终点(T ...

  6. Sumdiv(poj1845)

    题意:求A^B的因子的和. /* 首先将A分解 A=p1^a1*p2^a2*...*pn*an A^B=p1^a1B*p2^a2B*...*pn*anB 因子之和sum=(1+p1+p1^2+...+ ...

  7. 从零开始写STL—栈和队列

    从零开始写STL-栈和队列 适配器模式 意图:将一个类的接口转换成客户希望的另外一个接口.适配器模式使得原本由于接口不兼容而不能一起工作的那些类可以一起工作. 主要解决:主要解决在软件系统中,常常要将 ...

  8. 技术杂记之:在阿里云centos7上部署JDK MYSQL TOMCAT

    今日小编闲来无事,乘着公司新项目即将上线之际,在阿里云上整了一台centos作为测试机.原本以为一个小时搞定,结果还是花了一点小小时间.不管怎么说,记录下来,给各位小白当成课后甜点吧. 价格 先上价格 ...

  9. 07-js数组

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  10. Android--Activity在跳转时携带数据

    首先看看两种传递方法演示样例:(一个简单姻缘计算器) 主Activity import android.os.Bundle; import android.app.Activity; import a ...