กำหนด Transition Effect
ในการแสดงผลภาพแผนที่ผ่าน Openlayers นั้น เมื่อเราเปลี่ยนมาตราฐานหรือการย่อ ขยายแผนที่ ภาพแผนที่ที่แสดงมันจะหายไปแล้วทำการดึงภาพแผนที่ใหม่มาแทนที่ อาจจะทำไม่ค่อยสวยในการแสดงผล ในส่วนของ Openlayers จะมีตัวเลือกในการทำให้การเปลี่ยนภาพแผนที่จากที่กำหนดเป็นมาตรฐานที่กล่าวมาแล้ว เป็นแบบการดึงภาพแผนที่ก่อนการกระทำมาแสดงก่อน เมื่อได้ภาพใหม่มาจึงนำภาพดังกล่าวมาแสดงแทน โดยเราสามารถจะกำหนดได้ 2 แนวทาง ดังนี้
var tiled_resize_effect = new OpenLayers.Layer.WMS(
"WMS tiled resize",
"http://vmap0.tiles.osgeo.org/wms/vmap0?",
{layers: 'basic'},
{transitionEffect: 'resize'}
);
1. กำหนดใน layer โดยกำหนดแบบตายตัวใน library ของ Openlayer เลย โดยกำหนดในแฟ้มข้อมูล Openlayers/Layer.js
/**
* APIProperty: transitionEffect
* {String} The transition effect to use when the map is panned or
* zoomed.
*
* There are currently two supported values:
* - *null* No transition effect (the default).
* - *resize* Existing tiles are resized on zoom to provide a visual
* effect of the zoom having taken place immediately. As the
* new tiles become available, they are drawn over top of the
* resized tiles.
*/
transitionEffect: null,
/**
* Property: SUPPORTED_TRANSITIONS
* {Array} An immutable (that means don't change it!) list of supported
* transitionEffect values.
*/
SUPPORTED_TRANSITIONS: ['resize'],
/**
* APIProperty: transitionEffect
* {String} The transition effect to use when the map is panned or
* zoomed.
*
* There are currently two supported values:
* - *null* No transition effect (the default).
* - *resize* Existing tiles are resized on zoom to provide a visual
* effect of the zoom having taken place immediately. As the
* new tiles become available, they are drawn over top of the
* resized tiles.
*/
transitionEffect: null,
/**
* Property: SUPPORTED_TRANSITIONS
* {Array} An immutable (that means don't change it!) list of supported
* transitionEffect values.
*/
SUPPORTED_TRANSITIONS: ['resize'],
2. กำหนดใน parameter ในการตอนเรียกเพิ่มชั้นข้อมูลในโปรแกรม
var tiled_resize_effect = new OpenLayers.Layer.WMS(
"WMS tiled resize",
"http://vmap0.tiles.osgeo.org/wms/vmap0?",
{layers: 'basic'},
{transitionEffect: 'resize'}
);
ลองไปใช้งานดูนะครับ หรือจะดูตัวอย่างใน Openlayers ใน Folder Examples/transition.html ก็ได้มีตัวอย่างในการเรียกแบบที่ 2
ความคิดเห็น
แสดงความคิดเห็น