lat/lngをピクセルに変換する方法はありませんが、アノテーションに画像やテキストを表示する方法はあります。それは、それを行うための「ハック」の方法のようなものですが、それは動作します。基本的には、カスタムビューを作成するだけです。ビューの設定が完了したら、注釈の画像プロパティーのためにyourCustomView.toImage()に設定します。ここで
は一例です:
//Setup device size variables
var deviceWidth = Ti.Platform.displayCaps.platformWidth;
var deviceHeight = Ti.Platform.displayCaps.platformHeight;
//Create a new window
var w = Ti.UI.createWindow({
width:deviceWidth,
height:deviceHeight
})
//Create view for annotation
var annotationView = Ti.UI.createView({
width:50,
height:50,
backgroundImage:'http://www.insanedonkey.com/images/bubble.png',
})
//Add text to the annotation view
var annotationText = Ti.UI.createLabel({
width:'auto',
height:'auto',
text:'785k',
font:{fontSize:12,fontWeight:'bold'},
color:'#fff',
})
annotationView.add(annotationText);
//Create a new annotation
var newAnnotation = Titanium.Map.createAnnotation({
latitude:36.134513,
longitude:-80.659690,
animate:true,
image:annotationView.toImage() //Convert the annotationView to an image blob
});
var mapview = Titanium.Map.createView({
region:{latitude:36.134513, longitude:-80.659690, latitudeDelta:0.0009, longitudeDelta:0.0009},
animate:true,
regionFit:true,
userLocation:true,
annotations:[newAnnotation],
mapType:Titanium.Map.STANDARD_TYPE,
width:2000,
height:2000
});
//Add the mapview to the window
w.add(mapview);
//Open the window
w.open();
私はこれがアウトに役立ちます願っています。
ご返信ありがとうございます。私はそれを知っています。しかし、これは私が探しているものではありません。テキストを画像の上に表示し、ユーザーのクリックには表示しません。また、マップに適用したい他のさまざまなカスタム機能もありますが、これはデフォルトの注釈では実行できません。 私は先に述べた方法(Projection.toPixels())でアンドロイド用のアプリをすでに実装しています。事は、私はチタンのために何か類似したものを見つけることができません。 – George
は小さなハックのようですが、これはどうですか? http://developer.appcelerator.com/question/135862/convert-longitutelatidute-to-pixels –
hehe、これはappceleratorフォーラムの自分の投稿です。私がそこで答えたので、私はその男の提案をできるだけ早く試してみるでしょう。その後、私はそこにコメントを投稿します(またはうまくいけば解決策)。再度、感謝します! – George