2012-09-18 10 views
7

複数のデバイスで使用するGoogle Mapsポリゴン選択ツールを実装しようとしています。Google Maps Drawingマネージャのアイコンを変更することはできますか?

デフォルトの描画マネージャアイコン(手、ポリゴン描画ツール)はデスクトップマシンでは問題ありませんが、onやandroidデバイスを使用するのは本当に面倒です。誰でも私にデフォルトのアイコンセット(http://maps.gstatic.com/mapfiles/drawing.png)を上書きすることができるかどうか教えてもらえますか?

私はCSSとhtmlを特に書き換えることができますが、その道を行く前にもっと良い道があります。

ありがとうございます。

答えて

9

これは私がボタンを変更するために使用するもので、それはあなたのID everthingたら、CSSを変更することは簡単です、あなたの出発点を与える必要があります。..

$(".gmnoprint").each(function(){ 
    var newObj = $(this).find("[title='Draw a circle']"); 
    newObj.parent().addClass("remove"); 

    // ID the toolbar 
    newObj.parent().parent().attr("id", "btnBar"); 

    // Now remove the Circle button 
    $(".remove").remove(); 

    // ID the Hand button 
    newObj = $(this).find("[title='Stop drawing']"); 
    newObj.attr('id', 'btnStop'); 

    // ID the Marker button 
    newObj = $(this).find("[title='Add a marker']"); 
    newObj.attr('id', 'btnMarker'); 

    // ID the line button 
    newObj = $(this).find("[title='Draw a line']"); 
    newObj.attr('id', 'btnLine'); 

    // ID the Rectangle Button 
    newObj = $(this).find("[title='Draw a rectangle']"); 
    newObj.attr('id', 'btnRectangle'); 

    // ID the Polygon button 
    newObj = $(this).find("[title='Draw a shape']"); 
    newObj.attr('id', 'btnShape'); 

}); 

さらにそれを修正するには、私は自分自身を追加その後

$("#btnBar").append('<div style="float: left; line-height: 0;"><div id="btnDelete" style="direction: ltr; overflow: hidden; text-align: left; position: relative; color: rgb(51, 51, 51); font-family: Arial,sans-serif; -moz-user-select: none; font-size: 13px; background: none repeat scroll 0% 0% rgb(255, 255, 255); padding: 4px; border-width: 1px 1px 1px 0px; border-style: solid solid solid none; border-color: rgb(113, 123, 135) rgb(113, 123, 135) rgb(113, 123, 135) -moz-use-text-color; -moz-border-top-colors: none; -moz-border-right-colors: none; -moz-border-bottom-colors: none; -moz-border-left-colors: none; border-image: none; box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.4); font-weight: normal;" title="Delete Selected"><span style="display: inline-block;"><div style="width: 16px; height: 16px; overflow: hidden; position: relative;"><img style="position: absolute; left: 0px; top: -195px; -moz-user-select: none; border: 0px none; padding: 0px; margin: 0px; width: 16px; height: 350px;" src="drawing.png" draggable="false"></div></span></div></div>'); 

、新しいボタンをアクティブにし、マウスクリック上のアイコンを変更するには:

google.maps.event.addDomListener(document.getElementById('btnDelete'), 'click', deleteSelectedShape); 
      google.maps.event.addDomListener(document.getElementById('btnDelete'), 'mousedown', function() { 
    $("#btnDelete img").css("top", "-212px"); 
}); 
      google.maps.event.addDomListener(document.getElementById('btnDelete'), 'mouseup', function() { 
    $("#btnDelete img").css("top", "-195px"); 
}); 
このようなツールバーのボタン

これは役に立ちます。 :) デニス

+5

どのようにスタイルの変更を適用しましたか?描画マネージャは読み込みと表示に時間がかかり、完了を示すイベントはありません。私は1秒のタイムアウトを使用しましたが、そのようにして、元のアイコンが短時間表示されます。 – Mike

+0

かなり完璧です。返信が遅れて申し訳ありません! – Miresnare

関連する問題