ラベル 座標表示 の投稿を表示しています。 すべての投稿を表示
ラベル 座標表示 の投稿を表示しています。 すべての投稿を表示

2009年3月19日木曜日

OpenLayers 18c マウス位置の座標表示をカスタマイズ

Custom Style Example マウス位置の座標表示をカスタマイズ
を参考にマウスポジションの座標表示をカスタマイズします。

次のコードを追加します。

---
/* ここから追加 */
div.olControlMousePosition {
font-family: Verdana; /* ブラウザのフォントの関係で指定通りにならないときもあります */
font-size: 0.5em;
color: red;
}
/* ここまで */
</style>
---
// ここから追加
map.addControl(new OpenLayers.Control.MousePosition());
// ここまで

} // End of function init()
---

OpenLayers 18b Shift+Drag で四角座標表示

Custom Control Example(custom-control.html) Shift+Drag で四角座標表示
を参考に座標表示させます。

OpenLayers 18a で追加したコードは削除してください。
次のコードを追加します。

---
// ここから追加
var control = new OpenLayers.Control();
OpenLayers.Util.extend(control, {
draw: function () {
// this Handler.Box will intercept the shift-mousedown
// before Control.MouseDefault gets to see it
this.box = new OpenLayers.Handler.Box(
control,
{"done": this.notice},
{keyMask: OpenLayers.Handler.MOD_SHIFT});
this.box.activate();
},

notice: function (bounds) {
var ll = map.getLonLatFromPixel(new OpenLayers.Pixel(bounds.left, bounds.bottom));
var ur = map.getLonLatFromPixel(new OpenLayers.Pixel(bounds.right, bounds.top));
alert(ll.lon.toFixed(4) + ", " +
ll.lat.toFixed(4) + ", " +
ur.lon.toFixed(4) + ", " +
ur.lat.toFixed(4));
}
});

map.addControl(control);
// ここまで

} // End of function init()

地図上を Shift + ドラッグ で座標がポップアップ表示されます。

2009年3月18日水曜日

OpenLayers 18a Shift+Click で座標表示

Custom Control Point Example(custom-control-point.html) Shift+Click で座標表示
を参考に座標表示させます。

次のコードを追加します。

---
// ここから追加
var control = new OpenLayers.Control();
OpenLayers.Util.extend(control, {
draw: function () {
// this Handler.Point will intercept the shift-mousedown
// before Control.MouseDefault gets to see it
this.point = new OpenLayers.Handler.Point(
control,
{"done": this.notice},
{keyMask: OpenLayers.Handler.MOD_SHIFT}
);
this.point.activate();
},

notice: function (bounds) {
document.getElementById('bounds').innerHTML = bounds;
}
});

map.addControl(control);
// ここまで

} // End of function init()
---
</script>
</head>
<body onload="init()">
<h1 id="title">Display Data1</h1>
<div id="layerswitcher" style="position:absolute; z-index:1;"></div>
<div id="map"></div>
<div id="paneldiv" class="olControlNavToolbar"></div>
<!-- ここを追加 -->
<div id="bounds" style="margin-left:50px;"></div><br />
<!-- ここまで -->
---

地図上を Shift + クリック で地図のしたに座標が表示されます。