1 mxn.register('yahoo', {
\r
5 init: function(element,api) {
\r
8 this.maps[api] = new YMap(element);
\r
10 YEvent.Capture(this.maps[api], EventsList.MouseClick, function(event,location) {
\r
11 me.clickHandler(location.Lat, location.Lon, location, me);
\r
12 me.click.fire({'location': new mxn.LatLonPoint(location.Lat, location.Lon)});
\r
14 YEvent.Capture(this.maps[api], EventsList.changeZoom, function() {
\r
15 me.moveendHandler(me);
\r
16 me.changeZoom.fire();
\r
18 YEvent.Capture(this.maps[api], EventsList.endPan, function() {
\r
19 me.moveendHandler(me);
\r
22 YEvent.Capture(this.maps[api], EventsList.endAutoPan, function() {
\r
26 this.loaded[api] = true;
\r
30 alert(api + ' map script not imported');
\r
34 applyOptions: function(){
\r
37 if (this.options.enableDragging) {
\r
38 map.enableDragMap();
\r
40 map.disableDragMap();
\r
45 resizeTo: function(width, height){
\r
46 this.maps[this.api].resizeTo(new YSize(width,height));
\r
49 addControls: function( args ) {
\r
50 var map = this.maps[this.api];
\r
53 map.addPanControl();
\r
56 // Yahoo doesn't check the pan control is there before trying to remove it
\r
57 // so throws an exception :(
\r
58 map.addPanControl();
\r
59 map.removePanControl();
\r
62 if (args.zoom == 'large') {
\r
65 else if ( args.zoom == 'small' ) {
\r
69 map.removeZoomScale();
\r
73 addSmallControls: function() {
\r
74 var map = this.maps[this.api];
\r
75 map.addPanControl();
\r
77 this.addControlsArgs.pan = true;
\r
78 this.addControlsArgs.zoom = 'small';
\r
81 addLargeControls: function() {
\r
82 var map = this.maps[this.api];
\r
83 map.addPanControl();
\r
85 this.addControlsArgs.pan = true; // keep the controls in case of swap
\r
86 this.addControlsArgs.zoom = 'large';
\r
89 addMapTypeControls: function() {
\r
90 var map = this.maps[this.api];
\r
91 map.addTypeControl();
\r
94 dragging: function(on) {
\r
95 var map = this.maps[this.api];
\r
97 map.enableDragMap();
\r
99 map.disableDragMap();
\r
103 setCenterAndZoom: function(point, zoom) {
\r
104 var map = this.maps[this.api];
\r
105 var pt = point.toProprietary(this.api);
\r
107 var yzoom = 18 - zoom; // maybe?
\r
108 map.drawZoomAndCenter(pt,yzoom);
\r
111 addMarker: function(marker, old) {
\r
112 var map = this.maps[this.api];
\r
113 var pin = marker.toProprietary(this.api);
\r
114 map.addOverlay(pin);
\r
115 YEvent.Capture(pin, EventsList.MouseClick, function() {
\r
116 marker.click.fire();
\r
118 YEvent.Capture(pin, EventsList.openSmartWindow, function() {
\r
119 marker.openInfoBubble.fire();
\r
121 YEvent.Capture(pin, EventsList.closeSmartWindow, function() {
\r
122 marker.closeInfoBubble.fire();
\r
127 removeMarker: function(marker) {
\r
128 var map = this.maps[this.api];
\r
129 map.removeOverlay(marker.proprietary_marker);
\r
132 removeAllMarkers: function() {
\r
133 var map = this.maps[this.api];
\r
134 map.removeMarkersAll();
\r
137 declutterMarkers: function(opts) {
\r
138 throw 'Not implemented';
\r
141 addPolyline: function(polyline, old) {
\r
142 var map = this.maps[this.api];
\r
143 var pl = polyline.toProprietary(this.api);
\r
144 map.addOverlay(pl);
\r
148 removePolyline: function(polyline) {
\r
149 var map = this.maps[this.api];
\r
150 map.removeOverlay(polyline.proprietary_polyline);
\r
153 getCenter: function() {
\r
154 var map = this.maps[this.api];
\r
155 var pt = map.getCenterLatLon();
\r
156 var point = new mxn.LatLonPoint(pt.Lat, pt.Lon);
\r
160 setCenter: function(point, options) {
\r
161 var map = this.maps[this.api];
\r
162 var pt = point.toProprietary(this.api);
\r
163 map.panToLatLon(pt);
\r
166 setZoom: function(zoom) {
\r
167 var map = this.maps[this.api];
\r
168 var yzoom = 18 - zoom; // maybe?
\r
169 map.setZoomLevel(yzoom);
\r
172 getZoom: function() {
\r
173 var map = this.maps[this.api];
\r
174 return 18 - map.getZoomLevel();
\r
177 getZoomLevelForBoundingBox: function( bbox ) {
\r
178 throw 'Not implemented';
\r
181 setMapType: function(type) {
\r
182 var map = this.maps[this.api];
\r
185 case mxn.Mapstraction.ROAD:
\r
186 map.setMapType(YAHOO_MAP_REG);
\r
188 case mxn.Mapstraction.SATELLITE:
\r
189 map.setMapType(YAHOO_MAP_SAT);
\r
191 case mxn.Mapstraction.HYBRID:
\r
192 map.setMapType(YAHOO_MAP_HYB);
\r
195 map.setMapType(YAHOO_MAP_REG);
\r
199 getMapType: function() {
\r
200 var map = this.maps[this.api];
\r
201 var type = map.getCurrentMapType();
\r
203 case YAHOO_MAP_REG:
\r
204 return mxn.Mapstraction.ROAD;
\r
205 case YAHOO_MAP_SAT:
\r
206 return mxn.Mapstraction.SATELLITE;
\r
207 case YAHOO_MAP_HYB:
\r
208 return mxn.Mapstraction.HYBRID;
\r
214 getBounds: function () {
\r
215 var map = this.maps[this.api];
\r
216 var ybox = map.getBoundsLatLon();
\r
217 return new mxn.BoundingBox(ybox.LatMin, ybox.LonMin, ybox.LatMax, ybox.LonMax);
\r
220 setBounds: function(bounds){
\r
221 var map = this.maps[this.api];
\r
222 var sw = bounds.getSouthWest();
\r
223 var ne = bounds.getNorthEast();
\r
225 if(sw.lon > ne.lon) {
\r
228 var center = new YGeoPoint((sw.lat + ne.lat)/2, (ne.lon + sw.lon)/2);
\r
230 var container = map.getContainerSize();
\r
231 for(var zoom = 1 ; zoom <= 17 ; zoom++){
\r
232 var sw_pix = mxn.util.convertLatLonXY_Yahoo(sw,zoom);
\r
233 var ne_pix = mxn.util.convertLatLonXY_Yahoo(ne,zoom);
\r
234 if(sw_pix.x > ne_pix.x) {
\r
235 sw_pix.x -= (1 << (26 - zoom)); //earth circumference in pixel
\r
237 if(Math.abs(ne_pix.x - sw_pix.x) <= container.width
\r
238 && Math.abs(ne_pix.y - sw_pix.y) <= container.height){
\r
239 map.drawZoomAndCenter(center, zoom); //Call drawZoomAndCenter here: OK if called multiple times anyway
\r
245 addImageOverlay: function(id, src, opacity, west, south, east, north, oContext) {
\r
246 throw 'Not implemented';
\r
249 setImagePosition: function(id) {
\r
250 throw 'Not implemented';
\r
253 addOverlay: function(url, autoCenterAndZoom) {
\r
254 var map = this.maps[this.api];
\r
255 map.addOverlay(new YGeoRSS(url));
\r
258 addTileLayer: function(tile_url, opacity, copyright_text, min_zoom, max_zoom) {
\r
259 throw 'Not implemented';
\r
262 toggleTileLayer: function(tile_url) {
\r
263 throw 'Not implemented';
\r
266 getPixelRatio: function() {
\r
267 throw 'Not implemented';
\r
270 mousePosition: function(element) {
\r
271 throw 'Not implemented';
\r
278 toProprietary: function() {
\r
279 return new YGeoPoint(this.lat,this.lon);
\r
282 fromProprietary: function(yahooPoint) {
\r
283 this.lat = yahooPoint.Lat;
\r
284 this.lon = yahooPoint.Lon;
\r
291 toProprietary: function() {
\r
293 var infoBubble, event_action, infoDiv, div;
\r
295 if(this.iconSize) {
\r
296 size = new YSize(this.iconSize[0], this.iconSize[1]);
\r
300 ymarker = new YMarker(this.location.toProprietary('yahoo'), new YImage(this.iconUrl, size));
\r
303 ymarker = new YMarker(this.location.toProprietary('yahoo'), new YImage(this.iconUrl));
\r
307 if(this.iconSize) {
\r
308 ymarker = new YMarker(this.location.toProprietary('yahoo'), null, size);
\r
311 ymarker = new YMarker(this.location.toProprietary('yahoo'));
\r
315 if(this.labelText) {
\r
316 ymarker.addLabel(this.labelText);
\r
319 if(this.infoBubble) {
\r
320 infoBubble = this.infoBubble;
\r
322 event_action = EventsList.MouseOver;
\r
325 event_action = EventsList.MouseClick;
\r
327 YEvent.Capture(ymarker, event_action, function() {
\r
328 ymarker.openSmartWindow(infoBubble);
\r
334 infoDiv = this.infoDiv;
\r
337 event_action = EventsList.MouseOver;
\r
340 event_action = EventsList.MouseClick;
\r
342 YEvent.Capture(ymarker, event_action, function() {
\r
343 document.getElementById(div).innerHTML = infoDiv;
\r
350 openBubble: function() {
\r
351 var ypin = this.proprietary_marker;
\r
352 ypin.openSmartWindow(this.infoBubble);
\r
356 this.proprietary_marker.hide();
\r
360 this.proprietary_marker.unhide();
\r
363 update: function() {
\r
364 throw 'Not implemented';
\r
371 toProprietary: function() {
\r
374 for (var i = 0, length = this.points.length ; i< length; i++){
\r
375 ypoints.push(this.points[i].toProprietary('yahoo'));
\r
377 ypolyline = new YPolyline(ypoints,this.color,this.width,this.opacity);
\r
382 throw 'Not implemented';
\r
386 throw 'Not implemented';
\r