]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/Mapstraction/js/mxn.microsoft.core.js
Merge remote-tracking branch 'upstream/master' into social-master
[quix0rs-gnu-social.git] / plugins / Mapstraction / js / mxn.microsoft.core.js
1 mxn.register('microsoft', {     \r
2 \r
3 Mapstraction: {\r
4         \r
5         init: function(element, api) {          \r
6                 var me = this;\r
7                 if (VEMap){\r
8                         this.maps[api] = new VEMap(element.id);\r
9          \r
10                         \r
11                         \r
12                         this.maps[api].AttachEvent('onclick', function(event){\r
13                                 me.clickHandler();\r
14                                 var x = event.mapX;\r
15                                 var y = event.mapY;\r
16                             var pixel = new VEPixel(x,y);\r
17                                 me.click.fire({'location': new mxn.LatLonPoint(pixel.Latitude, pixel.Longitude)});\r
18                         \r
19                                 \r
20                         });\r
21                         this.maps[api].AttachEvent('onendzoom', function(event){\r
22                                 me.moveendHandler(me);\r
23                                 me.changeZoom.fire();\r
24                                 \r
25                                 \r
26                         });\r
27                         this.maps[api].AttachEvent('onendpan', function(event){\r
28                                 me.moveendHandler(me);\r
29                                 me.endPan.fire();\r
30                                 \r
31                                 \r
32                         });\r
33                         this.maps[api].AttachEvent('onchangeview', function(event){\r
34                                 me.endPan.fire();\r
35                                 \r
36                                 \r
37                         });\r
38                         this.maps[api].LoadMap();\r
39                         document.getElementById("MSVE_obliqueNotification").style.visibility = "hidden"; \r
40                 \r
41                         //removes the bird's eye pop-up\r
42                         this.loaded[api] = true;\r
43                         me.load.fire(); \r
44                 }\r
45                 else{\r
46                         alert(api + ' map script not imported')\r
47                         \r
48                 }\r
49         \r
50         },\r
51         \r
52         applyOptions: function(){\r
53                 var map = this.maps[this.api];\r
54                 if(this.options.enableScrollWheelZoom){\r
55                         map.enableContinuousZoom();\r
56                         map.enableScrollWheelZoom();    \r
57                 \r
58                 }\r
59                 \r
60         },\r
61 \r
62         resizeTo: function(width, height){      \r
63                 this.maps[this.api].Resize(width, height);\r
64         },\r
65 \r
66         addControls: function( args ) {\r
67                 var map = this.maps[this.api];\r
68         \r
69         if (args.pan) {\r
70                         map.SetDashboardSize(VEDashboardSize.Normal);\r
71                 }\r
72                 else {\r
73                         map.SetDashboardSize(VEDashboardSize.Tiny)\r
74                 }\r
75 \r
76         if (args.zoom == 'large') {\r
77                         map.SetDashboardSize(VEDashboardSize.Small)\r
78                 }\r
79                 else if ( args.zoom == 'small' ) {\r
80                         map.SetDashboardSize(VEDashboardSize.Tiny)\r
81                 }\r
82                 else {\r
83                         map.HideDashboard();\r
84                         map.HideScalebar();\r
85                 }\r
86                 \r
87                 \r
88         },\r
89 \r
90         addSmallControls: function() {\r
91                 var map = this.maps[this.api];\r
92                 map.SetDashboardSize(VEDashboardSize.Tiny);\r
93                 \r
94         },\r
95 \r
96         addLargeControls: function() {\r
97                 var map = this.maps[this.api];\r
98                 map.SetDashboardSize(VEDashboardSize.Normal);\r
99                 this.addControlsArgs.pan=true;\r
100                 this.addControlsArgs.zoom = 'large';\r
101         },\r
102 \r
103         addMapTypeControls: function() {\r
104                 var map = this.maps[this.api];\r
105                 map.addTypeControl();\r
106         \r
107         },\r
108 \r
109         dragging: function(on) {\r
110                 var map = this.maps[this.api];\r
111                 if(on){\r
112                         map.enableDragMap();\r
113                 }\r
114                 else{\r
115                         map.disableDragMap();\r
116                         \r
117                 }\r
118         },\r
119 \r
120         setCenterAndZoom: function(point, zoom) { \r
121                 var map = this.maps[this.api];\r
122                 var pt = point.toProprietary(this.api);\r
123                 var vzoom =  zoom;\r
124                 map.SetCenterAndZoom(new VELatLong(point.lat,point.lon), vzoom)\r
125                 \r
126         },\r
127         \r
128         addMarker: function(marker, old) {\r
129                 var map = this.maps[this.api];\r
130                 marker.pinID = "mspin-"+new Date().getTime()+'-'+(Math.floor(Math.random()*Math.pow(2,16)));\r
131                 var pin = marker.toProprietary(this.api);\r
132                 map.AddShape(pin);\r
133                 //give onclick event\r
134                 //give on double click event\r
135                 //give on close window\r
136                 //return the marker\r
137                 \r
138                 \r
139                 return pin;\r
140         },\r
141 \r
142         removeMarker: function(marker) {\r
143                 var map = this.maps[this.api];\r
144                 var id = marker.proprietary_marker.GetID();\r
145                 var microsoftShape = map.GetShapeByID(id);\r
146                 map.DeleteShape(microsoftShape);\r
147         },\r
148 \r
149         removeAllMarkers: function() {\r
150                 var map = this.maps[this.api];\r
151                 \r
152                 // TODO: Add provider code\r
153         },\r
154         \r
155         declutterMarkers: function(opts) {\r
156                 var map = this.maps[this.api];\r
157                 \r
158                 // TODO: Add provider code\r
159         },\r
160 \r
161         addPolyline: function(polyline, old) {\r
162                 var map = this.maps[this.api];\r
163                 var pl = polyline.toProprietary(this.api);\r
164                 pl.HideIcon();//hide the icon VE automatically displays\r
165                 map.AddShape(pl);\r
166                 \r
167                 return pl;\r
168         },\r
169 \r
170         removePolyline: function(polyline) {\r
171                 var map = this.maps[this.api];\r
172                 var id = polyline.proprietary_polyline.GetID();\r
173                 var microsoftShape = map.GetShapeByID(id);\r
174                 map.DeleteShape(microsoftShape);\r
175         },\r
176         \r
177         getCenter: function() {\r
178                 var map = this.maps[this.api];\r
179                 var LL = map.GetCenter();\r
180                 var point = new mxn.LatLonPoint(LL.Latitude, LL.Longitude);\r
181                 return point;\r
182                 \r
183         },\r
184  \r
185         setCenter: function(point, options) {\r
186                 var map = this.maps[this.api];\r
187                 var pt = point.toProprietary(this.api);\r
188                 map.SetCenter(new VELatLong(point.lat, point.lon));\r
189                 \r
190                 \r
191         },\r
192 \r
193         setZoom: function(zoom) {\r
194                 var map = this.maps[this.api];\r
195                 map.SetZoomLevel(zoom);\r
196                 \r
197                 \r
198         },\r
199         \r
200         getZoom: function() {\r
201                 var map = this.maps[this.api];\r
202                 var zoom = map.GetZoomLevel();\r
203                 \r
204                 return zoom;\r
205         },\r
206 \r
207         getZoomLevelForBoundingBox: function( bbox ) {\r
208                 var map = this.maps[this.api];\r
209                 // NE and SW points from the bounding box.\r
210                 var ne = bbox.getNorthEast();\r
211                 var sw = bbox.getSouthWest();\r
212                 var zoom;\r
213                 \r
214                 // TODO: Add provider code\r
215                 \r
216                 return zoom;\r
217         },\r
218 \r
219         setMapType: function(type) {\r
220                 var map = this.maps[this.api];\r
221                 switch(type) {\r
222                         case mxn.Mapstraction.ROAD:\r
223                                 map.SetMapStyle(VEMapStyle.Road);\r
224                                 break;\r
225                         case mxn.Mapstraction.SATELLITE:\r
226                                 map.SetMapStyle(VEMapStyle.Aerial);\r
227                                 break;\r
228                         case mxn.Mapstraction.HYBRID:\r
229                                 map.SetMapStyle(VEMapStyle.Hybrid);\r
230                                 break;\r
231                         default:\r
232                                 map.SetMapStyle(VEMapStyle.Road);\r
233                 }        \r
234         },\r
235 \r
236         getMapType: function() {\r
237                 var map = this.maps[this.api];\r
238                 var mode = map.GetMapStyle();\r
239                 switch(mode){\r
240                         case VEMapStyle.Aerial:\r
241                                 return mxn.Mapstraction.SATELLITE;\r
242                         case VEMapStyle.Road:\r
243                                 return mxn.Mapstraction.ROAD;\r
244                         case VEMapStyle.Hybrid:\r
245                                 return mxn.Mapstraction.HYBRID;\r
246                         default:\r
247                                 return null;\r
248                         \r
249                 }\r
250         \r
251 \r
252         },\r
253 \r
254         getBounds: function () {\r
255                 var map = this.maps[this.api];\r
256                 view = map.GetMapView();\r
257                 var topleft = view.TopLeftLatLong;\r
258                 var bottomright = view.BottomRightLatLong;\r
259                 \r
260                 return new mxn.BoundingBox(bottomright.Latitude,topleft.Longitude,topleft.Latitude, bottomright.Longitude );\r
261         },\r
262 \r
263         setBounds: function(bounds){\r
264                 var map = this.maps[this.api];\r
265                 var sw = bounds.getSouthWest();\r
266                 var ne = bounds.getNorthEast();\r
267                 \r
268                 var rec = new VELatLongRectangle(new VELatLong(ne.lat, ne.lon), new VELatLong(sw.lat, sw.lon));\r
269                 map.SetMapView(rec);\r
270                 \r
271                 \r
272                 \r
273         },\r
274 \r
275         addImageOverlay: function(id, src, opacity, west, south, east, north, oContext) {\r
276                 var map = this.maps[this.api];\r
277                 \r
278                 // TODO: Add provider code\r
279         },\r
280 \r
281         setImagePosition: function(id, oContext) {\r
282                 var map = this.maps[this.api];\r
283                 var topLeftPoint; var bottomRightPoint;\r
284 \r
285                 // TODO: Add provider code\r
286 \r
287         //      oContext.pixels.top = ...;\r
288         //      oContext.pixels.left = ...;\r
289         //      oContext.pixels.bottom = ...;\r
290         //      oContext.pixels.right = ...;\r
291         },\r
292         \r
293         addOverlay: function(url, autoCenterAndZoom) {\r
294                 var map = this.maps[this.api];\r
295             var layer = new VEShapeLayer(); \r
296             var mlayerspec = new VEShapeSourceSpecification(VEDataType.GeoRSS, url, layer);\r
297                 map.AddShapeLayer(layer);\r
298           \r
299         \r
300                 \r
301         },\r
302 \r
303         addTileLayer: function(tile_url, opacity, copyright_text, min_zoom, max_zoom) {\r
304                 throw 'Not implemented';\r
305         },\r
306 \r
307         toggleTileLayer: function(tile_url) {\r
308                 throw 'Not implemented';\r
309         },\r
310 \r
311         getPixelRatio: function() {\r
312                 throw 'Not implemented';\r
313         },\r
314         \r
315         mousePosition: function(element) {\r
316                 var locDisp = document.getElementById(element);\r
317                 if (locDisp != null) {\r
318                         var map = this.maps[this.api];\r
319                         map.AttachEvent("onmousemove", function(veEvent){\r
320                                 var latlon = map.PixelToLatLong(new VEPixel(veEvent.mapX, veEvent.mapY));\r
321                                 var loc = latlon.Latitude.toFixed(4) + " / " + latlon.Longitude.toFixed(4);\r
322                                 locDisp.innerHTML = loc;\r
323 \r
324                         });\r
325                         locDisp.innerHTML = "0.0000 / 0.0000";\r
326                 }\r
327         }\r
328 },\r
329 \r
330 LatLonPoint: {\r
331         \r
332         toProprietary: function() {\r
333                 return  new VELatLong(this.lat, this.lon);\r
334         },\r
335 \r
336         fromProprietary: function(mpoint) {\r
337                 this.lat =mpoint.Latitude;\r
338                 this.lon =mpoint.Longitude;\r
339         }\r
340         \r
341 },\r
342 \r
343 Marker: {\r
344         \r
345         toProprietary: function() {\r
346                 var mmarker = new VEShape(VEShapeType.Pushpin, this.location.toProprietary('microsoft'));\r
347         \r
348         \r
349                 return mmarker;\r
350                 \r
351         },\r
352 \r
353         openBubble: function() {                \r
354                 var mmarker = this.proprietary_marker;\r
355                 map.ClearInfoBoxStyles();\r
356                 mmarker.SetTitle(this.infoBubble);\r
357         },\r
358 \r
359         hide: function() {\r
360                 this.proprietary_marker.hide();\r
361         },\r
362 \r
363         show: function() {\r
364                 this.proprietary_marker_unhide();\r
365         },\r
366 \r
367         update: function() {\r
368                 throw 'Not implemented';\r
369         }\r
370         \r
371 },\r
372 \r
373 Polyline: {\r
374 \r
375         toProprietary: function() {\r
376                 var mpoints =[];\r
377                 for(var i =0, length = this.points.length; i < length; i++)\r
378                 {\r
379                         mpoints.push(this.points[i].toProprietary('microsoft'));\r
380                 }\r
381                 var mpolyline = new VEShape(VEShapeType.Polyline, mpoints);\r
382                 if(this.color){\r
383                         var color = new mxn.util.Color(this.color);\r
384                         var opacity = (typeof(this.opacity) == 'undefined' || this.opacity === null) ? 1.0 : this.opacity;\r
385                         var vecolor = new VEColor(color.red, color.green, color.blue, opacity);\r
386                         mpolyline.SetLineColor(vecolor);\r
387                 }\r
388                 //      TODO ability to change line width\r
389                 return mpolyline;\r
390         },\r
391                 \r
392         show: function() {\r
393                         this.proprietary_polyline.Show();\r
394         },\r
395 \r
396         hide: function() {\r
397                         this.proprietary_polyline.Hide();\r
398         }\r
399         \r
400 }\r
401 \r
402 });\r