我想知道是否有人在同一版本中实现了谷歌地图V2和百度地图;因为通用汽车在中国没有按预期工作?
或者我应该将项目分成两个分支?但是跳过维护两个分支会很好。
您可以同时使用谷歌地图和百度地图,但请确保将WGS-84坐标(世界大多数国家使用)转换为百度坐标(BD-09,不同于中国的GCJ-02)。基于百度地图API中的一个示例,这里有一些代码可以做到这一点:
// Google coordinates
var gPoint = new BMap.Point(121.4914, 31.2423); // lon, lat of the Bund Museum in Shanghai - https://www.google.com/maps/@31.2423,121.4914,19z
// gPoint = new BMap.Point(-122.0851053, 37.4219593); // lon, lat of the Googleplex (no Baidu map data but zooms out in Mountain View)
var labelOffset = { offset: new BMap.Size(20, -10) };
// Initialize map
var map = new BMap.Map('allmap');
map.centerAndZoom(gPoint, 15);
map.addControl(new BMap.ScaleControl({anchor: BMAP_ANCHOR_TOP_LEFT})); // add scale
map.addControl(new BMap.NavigationControl());
map.addControl(new BMap.MapTypeControl()); // map type control: street/satellite/2.5D
map.enableScrollWheelZoom(); // mouse wheel scroll is disabled by default
// Add Google marker and label
var markerG = new BMap.Marker(gPoint);
map.addOverlay(markerG);
markerG.setLabel(new BMap.Label('Google coordinates marker appears<br/>at incorrect location on Baidu Map', labelOffset));
// Coordinate conversion ... GCJ-02 coordinates ... Baidu coordinates
BMap.Convertor.translate(gPoint, 2, function (point) {
var marker = new BMap.Marker(point);
map.addOverlay(marker);
marker.setLabel(new BMap.Label('Converted to Baidu coordinates:<br/>' +
point.lng + ', ' +
point.lat +
'<br/>(note the offset of ' + (map.getDistance(gPoint, point)).toFixed(2) + ' meters)',
labelOffset));
map.addOverlay(new BMap.Polyline([gPoint, point])); // draw a line between points
});
<style type="text/css">
body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
</style>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=gd0GyxGUxSCoAbmdyQBhyhrZ"></script>
<script type="text/javascript" src="http://developer.baidu.com/map/jsdemo/demo/convertor.js"></script>
<div id="allmap"></div>
此外,我发现如果你在中国使用http://ditu.google.cn,它确实有效。
当你的应用程序使用中国的在线地图时,无论是谷歌地图还是百度,出于法律原因,都有经纬度的转换。
谷歌地图中的卫星视图使用“地球”(WGS-84)坐标。中国GMAP的地图视图使用“火星”坐标(GCJ-02),并且有代码在两者之间进行转换。百度地图使用“Bearpaw”坐标,偏移量不同。百度地图API有一个在谷歌坐标和自己系统之间转换的演示。
在中国,GPS就像所有东西一样,还有一层额外的复杂性:)
如果您已构建此应用程序,请发布详细信息。有一个英文界面的百度地图将是伟大的。
我的解决方案是像往常一样实现GM,但是如果用户在中国设置(通过设置)将使用静态地图,但是静态地图是从百度而不是谷歌获取的。
staticUrl = "http://api.map.baidu.com/staticimage?center="
+ location.getLongitude() + "," + location.getLatitude()
+ "&width=" + width + "&height=" + width + "&zoom=15"
+ "&markers=" + location.getLongitude() + "," + location.getLatitude();
https://api.map.baidu.com/staticimage?center=121结果,31
如果尝试实现真实地图解决方案,不建议使用此方法。由于我有不同的位置仅供不同国家使用,因此可以使用此解决方案。
这就是我解决它的方法。希望有人觉得这有帮助。
正如标题所说,我已经在我的应用程序中使用谷歌地图,我也希望在Kindle设备中使用亚马逊地图。AM和GM v1在技术上使用相同的接口。我如何才能很好地解决这个问题,根据我使用的设备,我可以为每个类获得适当的类类型(例如com.google.android.maps.MapView或com.amazon.geo.maps.MapView)? 所以假设我需要适当版本的MapView类,具体取决于我的设
错误:
我正在开发一个应用程序,其中我必须显示最短路线。我正在使用Google Direction API,但结果与相同目的地和旅行模式的Google Maps应用程序不同。 https://maps.googleapis.com/maps/api/directions/json?origin=19.107163,72.862375 既然备选方案是正确的,我已经在使用可用路线中的最短路线(响应)。 注意:
我正在使用latitude在百度地图(中国的主要地图服务)中实现一个地图视图 进行线性调整后,百度位置大致出现在正确的位置(几米): 虽然这可以满足我的特殊需要,但我不喜欢这些神奇的数字。有人知道这种抵消是从哪里产生的吗?
我正在做一个导航应用程序,已经做了所有需要互联网的工作。我的意思是(我已经绘制了标记,在它们之间做了一条路线,以及其他设施,比如参照用户的位置搜索名胜)等等,使用Google map Android API V2。 但现在我也想让这个应用离线。我的意思是让用户可以在没有互联网连接的情况下做这些事情。如果在离线模式下搜索设施是可能的(我的意思是,如果标记不能绘制,路线不能在起点和目的地之间),那么请
软件包com.map.testing; 导入Android.os.bundle; 导入com.google.android.maps.geopoint;导入com.google.android.maps.MapActivity;导入com.google.android.maps.MapController;导入com.google.android.maps.MapView; 我的清单: