当我点击地图时,我将所有用户的LatLng
存储在SharedPreference
中。现在我画一个圆圈然后如果任何用户进入这个圆圈,那么标记应该是可见的。我能够做到这一切,但它只显示一个用户。但是我的共享偏好中有多个LatLng。我该怎么办?请跟我说我的代码在这里
private void calculateUserLocation(MapAreaWrapper draggableCircle) {
float[] distance = new float[10];
Location.distanceBetween(map_flag.getPosition().latitude, map_flag.getPosition().longitude,
draggableCircle.getCenter().latitude, draggableCircle.getCenter().longitude, distance);
if (distance[0] > draggableCircle.getRadius()) {
Toast.makeText(getBaseContext(), "Outside", Toast.LENGTH_LONG).show();
} else {
map_flag.setVisible(true);
Toast.makeText(getBaseContext(), "Inside", Toast.LENGTH_LONG).show();
}
}
答案 0 :(得分:1)
private Marker mMarker;
private void calculateUserLocation(MapAreaWrapper draggableCircle) {
float[] distance = new float[10];
Location.distanceBetween(map_flag.getPosition().latitude, map_flag.getPosition().longitude,
draggableCircle.getCenter().latitude, draggableCircle.getCenter().longitude, distance);
if (distance[0] > draggableCircle.getRadius()) {
Toast.makeText(getBaseContext(), "Outside", Toast.LENGTH_LONG).show();
} else {
map_flag.setVisible(true);
if (map!=null){
//Simple Marker
Marker hamburg = map.addMarker(new MarkerOptions().position(LatLng)
.title("Hamburg"));
//marker With icon
Marker kiel = map.addMarker(new MarkerOptions()
.position(LatLng)
.title("Kiel")
.snippet("Kiel is cool")
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.ic_launcher)));
}
Toast.makeText(getBaseContext(), "Inside", Toast.LENGTH_LONG).show();
}
}