答えて

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

からビットマップを作成します。私は@ihrupinは、Javaコードについて話していると思います代わりに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、あなたは正しいです。私はいくつかのJavaのAndroidソリューションのヒント – ihrupin

4

私は少し遅れかもしれないが、私は/です直面している他の人のための解決策を投稿します同様の問題に直面している。だから、基本的に何をしなければならないのか(少なくともあなたが探している解決策、すなわちボックスのような背景に課されたカスタムイメージ)は、キャンバスの助けを借りて背景のボックスにcustomImageを押し付けます。この実装を使用すると、効果的にキャンバスからBitmapDrawableを作成できます。このBitmapDrawableは、 'Overlay'/'ItemizedOverlay'のマーカーとして割り当てることができます。また、オーバーレイごとにImageViewを作成することは控えてください。これは、このようなImageViewを同時に処理する必要がある場合、メモリ/アプリケーションを完全に破棄するためです。代わりに、構築中にオーバーレイに割り当てることができるBitmapDrawablesを使用し、ImageViewとしてほぼ十分なメモリを消費しないでください。

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

Googleマップのカスタムマーカー

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)))); 

Drawableの

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; 
} 
関連する問題