1 /* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
2 * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
3 * text of the license. */
4 // @require: OpenLayers/Layer.js
\r
6 // load Yahoo map control script
\r
7 document.write("<script src='http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=euzuro-openlayers'></script>");
\r
12 OpenLayers.Layer.Yahoo = Class.create();
\r
13 OpenLayers.Layer.Yahoo.prototype = Object.extend( new OpenLayers.Layer(), {
\r
15 /** @type Boolean */
\r
16 viewPortLayer: true,
\r
18 /** @type GMap2 gmap stores the Google Map element */
\r
21 /** @type Boolean */
\r
27 * @param {String} name
\r
29 initialize: function(name) {
\r
30 OpenLayers.Layer.prototype.initialize.apply(this, [name]);
\r
34 * @param {OpenLayers.Map} map
\r
36 setMap:function(map) {
\r
37 OpenLayers.Layer.prototype.setMap.apply(this, arguments);
\r
39 // once our layer has been added to the map, we can create the vemap
\r
40 this.map.events.register("addlayer", this, this.loadYMap);
\r
43 /** Yahoo layer is always a base class.
\r
46 isBaseLayer: function() {
\r
51 * @param {OpenLayers.Bounds} bounds
\r
52 * @param {int} zoomChanged
\r
54 moveTo:function(bounds,zoomChanged) {
\r
56 if ((this.ymap != null) && (!this.dragging)) {
\r
58 var olCenter = this.map.getCenter();
\r
59 var yCenter = this.getYMapCenter();
\r
61 var olZoom = this.map.getZoom();
\r
62 var yZoom = this.ymap.getZoomLevel();
\r
64 if ((!olCenter.equals(yCenter)) || (( 16 - olZoom) != yZoom)) {
\r
65 this.ymap.drawZoomAndCenter(new YGeoPoint(olCenter.lat, olCenter.lon),
\r
74 loadYMap:function() {
\r
75 // create div and set to same size as map
\r
76 var yDiv = OpenLayers.Util.createDiv(this.name);
\r
77 var sz = this.map.getSize();
\r
78 yDiv.style.width = sz.w;
\r
79 yDiv.style.height = sz.h;
\r
80 this.div.appendChild(yDiv);
\r
82 // create GMap, hide nav controls
\r
83 this.ymap = new YMap(this.div);
\r
85 // catch pans and zooms from GMap
\r
86 YEvent.Capture(this.ymap,
\r
91 // catch pans and zooms from GMap
\r
92 YEvent.Capture(this.ymap,
\r
93 EventsList.endAutoPan,
\r
98 // attach to the drag start and end and we´ll set a flag so that
\r
99 // we dont get recursivity. this is because the events fall through
\r
100 // the gmaps div and into the main layer div
\r
101 YEvent.Capture(this.ymap,
\r
102 EventsList.startPan,
\r
111 dragStart: function() {
\r
112 this.dragging = true;
\r
120 catchPanZoom: function(e) {
\r
121 this.dragging = false;
\r
123 var olCenter = this.getYMapCenter();
\r
124 var yZoom = this.ymap.getZoomLevel();
\r
126 this.map.setCenter(olCenter, 16 - yZoom);
\r
133 * @returns An OpenLayers.LonLat with the center of the ymap, or null if
\r
134 * the YMap has not been centered yet
\r
135 * @type OpenLayers.LonLat
\r
137 getYMapCenter:function() {
\r
138 var olCenter = null;
\r
139 var yCenter = this.ymap.getCenterLatLon();
\r
140 if (yCenter != null) {
\r
141 olCenter = new OpenLayers.LonLat(yCenter.Lon, yCenter.Lat);
\r
147 /** @final @type String */
\r
148 CLASS_NAME: "OpenLayers.Layer.Yahoo"
\r