答案 0 :(得分:2)
添加此项并获取地图的中心点...
@Override
public void onMapReady(final GoogleMap map) {
map.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() {
@Override
public void onCameraChange(CameraPosition cameraPosition) {
LatLng centerLatLng = cameraPosition.target;
}
});
}
对于 Framelayout 中的市场设计,使用 ProgrssBar和ImageView 将其添加到地图/屏幕的中心
答案 1 :(得分:0)
嗨你可以这样做,在地图上拖动标记时获取位置lat,lng位置,
function geocodePosition(pos)
{
geocoder = new google.maps.Geocoder();
geocoder.geocode
({
latLng: pos
},
function(results, status)
{
if (status == google.maps.GeocoderStatus.OK)
{
console.log(results[0].geometry.location.lat());
console.log(results[0].geometry.location.lng());
}
else
{
}
}
);
}
function initialize() {
var mapOptions = {
zoom: 14,
center: new google.maps.LatLng(52.5498783, 13.425209099999961),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map'), mapOptions);
marker = new google.maps.Marker(
{
map:map,
draggable:true,
animation: google.maps.Animation.DROP,
position: {lat: 52.5498783, lng: 13.425209099999961}
});
google.maps.event.addListener(map, 'dragend', function() {
var center= map.getCenter();
var latitude=center.lat();
var longitude=center.lng();
marker.setMap(null);
marker = new google.maps.Marker({
map:map,
draggable:true,
animation: google.maps.Animation.DROP,
position: {lat: latitude, lng: longitude}
});
});
google.maps.event.addListener(marker, 'dragend', function(){
geocodePosition(marker.getPosition());
});
}
希望它有所帮助,如果你需要更多澄清。这是javascript实现。