Google지도에 Google Api 버전 2를 사용하고 있습니다. Google지도를 새로 고치고 싶습니다. API 버전 2를 사용하여 새로 고칠 수 있습니까? api-v2에서 VisualRefresh 옵션을 사용할 수 있습니까? 난 단지 자바 코드 또는 가능한에서 자바 스크립트 경우를 사용하여 몇 가지 아이디어를 제안하십시오 (무효화)하지만보기에 적용하여 시도 Api-V2를 사용하여 Google지도를 새로 고침 하시겠습니까?
public class ClustringActivity extends Activity{
View view;
MapView mapView;
GoogleMap map;
List<PointOfInterest> pointsOfInterest;
Clusterer<PointOfInterest> clusterer;
HashMap<Marker, PointOfInterest> markers = new HashMap<Marker, PointOfInterest>();
HashMap<Marker, Cluster> clusters = new HashMap<Marker, Cluster>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
}
private void createDummyLocations() {
pointsOfInterest = new ArrayList<PointOfInterest>();
pointsOfInterest.add(new PointOfInterest(new LatLng(12.9065534, 77.57748019999997), "Perry's house", "Very beautiful"));
pointsOfInterest.add(new PointOfInterest(new LatLng(12.9169534, 77.67748019999997), "Cottolengo",
"Greatest munye-munye I've ever tasted"));
pointsOfInterest.add(new PointOfInterest(new LatLng(12.915295, 77.573647), "Banashankari",
" Metro Station"));
pointsOfInterest.add(new PointOfInterest(new LatLng(12.905974, 77.580664), "17th Cross Road",
"Bus Station"));
pointsOfInterest.add(new PointOfInterest(new LatLng(12.91091, 77.581694), "Mirambika School for New Age",
"Sri Aurobindo Marg, 1st phase, Phase I, Bangalore, KA, India"));
pointsOfInterest.add(new PointOfInterest(new LatLng(12.904426, 77.573755), "Pizza HUt",
"BKN Plaza, Opposite Family Mart, 363/70, Kanakapura Road, Jarganahalli, JP Nagar VI Phase, Bangalore, Karnataka, India"));
}
private void initMap() {
if (mapView==null) return;
CameraPosition cameraPosition = new CameraPosition.Builder().target(new LatLng(12.910491, 77.580117)).zoom(15).build();
map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
map.setOnMarkerClickListener(new OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker) {
if (markers.containsKey(marker)) {
Toast.makeText(ClustringActivity.this, "Poi clicked!", Toast.LENGTH_LONG).show();
} else if (clusters.containsKey(marker)){
Toast.makeText(ClustringActivity.this, "Cluster clicked!", Toast.LENGTH_LONG).show();
}
return false;
}
});
}
private void initClusterer() {
clusterer = new Clusterer<PointOfInterest>(this, map);
clusterer.addAll(pointsOfInterest);
Toast.makeText(getApplicationContext(), "refresh....", Toast.LENGTH_SHORT).show();
clusterer.setOnPaintingMarkerListener(new OnPaintingMarkerListener<PointOfInterest>() {
@Override
public void onMarkerCreated(Marker marker, PointOfInterest clusterable) {
markers.put(marker, clusterable);
}
@Override
public MarkerOptions onCreateMarkerOptions(PointOfInterest clusterable) {
PointOfInterest poi = (PointOfInterest) clusterable;
return new MarkerOptions().position(clusterable.getPosition()).title(poi.getName()).snippet(poi.getDescription());
}
});
clusterer.setOnPaintingClusterListener(new OnPaintingClusterListener() {
@Override
public void onMarkerCreated(Marker marker, Cluster cluster) {
clusters.put(marker, cluster);
}
@Override
public MarkerOptions onCreateClusterMarkerOptions(Cluster cluster) {
/*View marker = ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.custom_marker_layout, null);
TextView numTxt = (TextView) marker.findViewById(R.id.num_txt);
numTxt.setText(cluster.getWeight());*/
return new MarkerOptions()
.title("Clustering " + cluster.getWeight() + " items")
.position(cluster.getCenter())
.icon(BitmapDescriptorFactory.fromBitmap(getClusteredLabel(Integer.valueOf(cluster.getWeight()).toString(),
ClustringActivity.this)));
/*.icon(BitmapDescriptorFactory.fromBitmap(createDrawableFromView(ClustringActivity.this, marker)));*/
}
});
}
private Bitmap getClusteredLabel(String cnt, Context ctx) {
Resources r = ctx.getResources();
Bitmap res = BitmapFactory.decodeResource(r, R.drawable.custom_marker);
res = res.copy(Bitmap.Config.ARGB_8888, true);
Canvas c = new Canvas(res);
Paint textPaint = new Paint();
textPaint.setAntiAlias(true);
textPaint.setTextAlign(Paint.Align.CENTER);
textPaint.setTypeface(Typeface.DEFAULT_BOLD);
textPaint.setColor(Color.BLUE);
textPaint.setTextSize(40);
c.drawText(cnt, res.getWidth()/3 +textPaint.getTextSize()/4, res.getHeight()/2 , textPaint);
return res;
}
below-로
내 코드는?
어떤 특정 문제가 있습니까? 관련없는 코드를 많이 붙여 넣는 것은 해결되지 않습니다. –
지도를 새로 고침하고 싶습니까? 대답 해 줄 수 있니? –
할 수 없습니다. 당신이 무엇을 요구하고 있는지 명확하지 않습니다. [단문, 자기 포함, 수정 (Compilable), 예] (http://sscce.org/), 스크린 샷, 실제 및 예상 결과를 제공 할 수 있습니다. –