답변

3

내가 안드로이드 코드하지 않습니다 아직, 그래서 이것은 대부분 여기에 마지막 코드 블록을 기반으로합니다 http://code.google.com/apis/maps/articles/android_v3.html

그것이 끝은 어디 /하는 내가 조금 늦을 수도

var myIcon=new google.maps.MarkerImage('my_icon.png'); 
var point=new google.maps.LatLng(someLatitude,someLongitude); 
var marker = new google.maps.Marker({position: point,map: map, icon:mc}); 
+0

에서 비트 맵 만들기 대신 JS. – anticafe

+0

다음은 어쩌면 이와 비슷한가요? 'Drawable icon = getResources(). getDrawable (someicon);을 포함하는 http://developmentality.wordpress.com/2009/10/16/android-overlayitemsetmarkerdrawable-icon/; icon.setBounds (0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight()); someItem.setMarker (아이콘); ' –

+0

@anticafe, 네가 맞아. 나는 안드로이드 솔루션 – ihrupin

4

하지만 난에 직면 한 다른 사람을위한 솔루션을 게시합니다 : 그냥 일반 맵 구현되는, 그래서 당신은 기존지도에 마커를 추가하려면 다음을 할 거라고 유사한 문제에 직면 해있다. 따라서 기본적으로 사용자가해야하는 솔루션 (최소한 상자와 유사한 배경에 부과 된 사용자 지정 이미지)은 캔버스를 사용하여 배경 상자에 customImage를 적용합니다. 이 구현을 사용하면 효과적으로 '오버레이'/ 'ItemizedOverlay'에 대한 마커로 지정할 수있는 캔버스에서 BitmapDrawable을 만들 수 있습니다. 또한 수천 개의 이미지 뷰를 동시에 처리해야하는 경우 메모리/앱을 완전히 파괴하므로 각 오버레이에 대해 ImageView를 만들지 마십시오. 대신, 구성 도중 오버레이에 할당 할 수있는 BitmapDrawables를 사용하고 ImageView로 거의 충분한 메모리를 사용하지 마십시오. 레이아웃을 사용하여 Google지도에 대한

public BitmapDrawable imageOnDrawable(int drawableBackground, Bitmap customImage) 
{ 
//The following line is optional but I'd advise you to minimize the size of 
//the size of the bitmap (using a thumbnail) in order to improve draw 
//performance of the overlays (especially if you are creating a lot of overlays). 

Bitmap customImageThumbnail = ThumbnailUtils.extractThumbnail(
               customImage, 100, 100); 

Bitmap bm = BitmapFactory.decodeResource(getResources(), drawableId); 
bm = Bitmap.createScaledBitmap(bm, 112, 120, false); 

Canvas canvas = new Canvas(bm); 
canvas.drawBitmap(bm, 0, 0, null); 
// The 6,6 in the below line refer to the offset of the customImage/Thumbnail 
// from the top-left corner of the background box (or whatever you want to use 
// as your background) 
canvas.drawBitmap(customImageThumbnail, 6, 6, null); 

return new BitmapDrawable(bm); 

} 
3

사용자 정의 마커

View markerView = ((LayoutInflater) getActivity() 
         .getSystemService(
           getActivity().LAYOUT_INFLATER_SERVICE)) 
         .inflate(R.layout.map_marker, null); 

세트 마커

marker = map.addMarker(new MarkerOptions() 
             .position(latLng) 
             .title(strName) 
             .snippet(strStatus) 
             .icon(BitmapDescriptorFactory 
               .fromBitmap(createDrawableFromView(
                 getActivity(), 
                 markerView)))); 

내가 @ihrupin 자바 코드에 대해 이야기하고 생각 드로어 블

public static Bitmap createDrawableFromView(Context context, View view) { 
    DisplayMetrics displayMetrics = new DisplayMetrics(); 
    ((Activity) context).getWindowManager().getDefaultDisplay() 
      .getMetrics(displayMetrics); 
    view.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, 
      LayoutParams.WRAP_CONTENT)); 
    view.measure(displayMetrics.widthPixels, displayMetrics.heightPixels); 
    view.layout(0, 0, displayMetrics.widthPixels, 
      displayMetrics.heightPixels); 
    view.buildDrawingCache(); 
    Bitmap bitmap = Bitmap.createBitmap(view.getMeasuredWidth(), 
      view.getMeasuredHeight(), Bitmap.Config.ARGB_8888); 

    Canvas canvas = new Canvas(bitmap); 
    view.draw(canvas); 

    return bitmap; 
} 
관련 문제