ズームレベルによって、TLbelで設定された文字列の位置の書き換えを行ないたいと考えています。
ソースは下記の様に行っています。
var map;
function load(){
var lat=35.68079483220707;
var lng=139.76662874221802;
var c_lat=35.68574469022577;
var c_lng=139.75218772888184
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.setCenter(new GLatLng(c_lat, c_lng), 14);
var set_contents = '<div style= "white-space: nowrap;font-size:
70%;font-weight: bolder;color: black; background-olor:white;width:
auto;">'+ '東京駅' +' </div>';
var latlng= new GLatLng(lat,lng);
var label = new TLabel();
label.id= 'tokyo_station' ;
l label.anchorLatLng = latlng;
label.anchorPoint = 'topCenter';
label.markerOffset = new GSize(0,0);
label.content = set_contents;
label.percentOpacity = 80;
map.addTLabel(label);
GEvent.addListener(map, "zoomend", checkZoom);
}
}
function checkZoom(oldZoom, newZoom) {
var zoom = map.getZoom();
var latlng;
var content ;
if (zoom == 15) {
latlng=new GLatLng(35.67079483220707,139.76662874221802);
var set_contents = '<div style= "white-space: nowrap;font-size:
70%;font-weight: bolder;color: black; background-olor:white;width:
auto;">'+ '東京駅' +' </div>';
var latlng= new GLatLng(lat,lng);
var label = new TLabel();
label.id= 'tokyo_station' ;
label.anchorLatLng = latlng;
label.anchorPoint = 'topCenter';
label.markerOffset = new GSize(0,0);
label.content = set_contents;
label.percentOpacity = 80;
map.addTLabel(label);
}
}
以上のようなイメージで実行したところ、
ズームアップ後の表示で、指定している場所と異なる部分に
ラベルが表示されてしまいます。
TLabelの使い方が間違っているかも知れませんが、
どなたかアドバイスをお願いいたします。