1 mxn.register('microsoft', {
\r
5 init: function(element, api) {
\r
8 this.maps[api] = new VEMap(element.id);
\r
12 this.maps[api].AttachEvent('onclick', function(event){
\r
16 var pixel = new VEPixel(x,y);
\r
17 me.click.fire({'location': new mxn.LatLonPoint(pixel.Latitude, pixel.Longitude)});
\r
21 this.maps[api].AttachEvent('onendzoom', function(event){
\r
22 me.moveendHandler(me);
\r
23 me.changeZoom.fire();
\r
27 this.maps[api].AttachEvent('onendpan', function(event){
\r
28 me.moveendHandler(me);
\r
33 this.maps[api].AttachEvent('onchangeview', function(event){
\r
38 this.maps[api].LoadMap();
\r
39 document.getElementById("MSVE_obliqueNotification").style.visibility = "hidden";
\r
41 //removes the bird's eye pop-up
\r
42 this.loaded[api] = true;
\r
46 alert(api + ' map script not imported')
\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
62 resizeTo: function(width, height){
\r
63 this.maps[this.api].Resize(width, height);
\r
66 addControls: function( args ) {
\r
67 var map = this.maps[this.api];
\r
70 map.SetDashboardSize(VEDashboardSize.Normal);
\r
73 map.SetDashboardSize(VEDashboardSize.Tiny)
\r
76 if (args.zoom == 'large') {
\r
77 map.SetDashboardSize(VEDashboardSize.Small)
\r
79 else if ( args.zoom == 'small' ) {
\r
80 map.SetDashboardSize(VEDashboardSize.Tiny)
\r
83 map.HideDashboard();
\r
90 addSmallControls: function() {
\r
91 var map = this.maps[this.api];
\r
92 map.SetDashboardSize(VEDashboardSize.Tiny);
\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
103 addMapTypeControls: function() {
\r
104 var map = this.maps[this.api];
\r
105 map.addTypeControl();
\r
109 dragging: function(on) {
\r
110 var map = this.maps[this.api];
\r
112 map.enableDragMap();
\r
115 map.disableDragMap();
\r
120 setCenterAndZoom: function(point, zoom) {
\r
121 var map = this.maps[this.api];
\r
122 var pt = point.toProprietary(this.api);
\r
124 map.SetCenterAndZoom(new VELatLong(point.lat,point.lon), vzoom)
\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
133 //give onclick event
\r
134 //give on double click event
\r
135 //give on close window
\r
136 //return the marker
\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
149 removeAllMarkers: function() {
\r
150 var map = this.maps[this.api];
\r
152 // TODO: Add provider code
\r
155 declutterMarkers: function(opts) {
\r
156 var map = this.maps[this.api];
\r
158 // TODO: Add provider code
\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
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
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
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
193 setZoom: function(zoom) {
\r
194 var map = this.maps[this.api];
\r
195 map.SetZoomLevel(zoom);
\r
200 getZoom: function() {
\r
201 var map = this.maps[this.api];
\r
202 var zoom = map.GetZoomLevel();
\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
214 // TODO: Add provider code
\r
219 setMapType: function(type) {
\r
220 var map = this.maps[this.api];
\r
222 case mxn.Mapstraction.ROAD:
\r
223 map.SetMapStyle(VEMapStyle.Road);
\r
225 case mxn.Mapstraction.SATELLITE:
\r
226 map.SetMapStyle(VEMapStyle.Aerial);
\r
228 case mxn.Mapstraction.HYBRID:
\r
229 map.SetMapStyle(VEMapStyle.Hybrid);
\r
232 map.SetMapStyle(VEMapStyle.Road);
\r
236 getMapType: function() {
\r
237 var map = this.maps[this.api];
\r
238 var mode = map.GetMapStyle();
\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
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
260 return new mxn.BoundingBox(bottomright.Latitude,topleft.Longitude,topleft.Latitude, bottomright.Longitude );
\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
268 var rec = new VELatLongRectangle(new VELatLong(ne.lat, ne.lon), new VELatLong(sw.lat, sw.lon));
\r
269 map.SetMapView(rec);
\r
275 addImageOverlay: function(id, src, opacity, west, south, east, north, oContext) {
\r
276 var map = this.maps[this.api];
\r
278 // TODO: Add provider code
\r
281 setImagePosition: function(id, oContext) {
\r
282 var map = this.maps[this.api];
\r
283 var topLeftPoint; var bottomRightPoint;
\r
285 // TODO: Add provider code
\r
287 // oContext.pixels.top = ...;
\r
288 // oContext.pixels.left = ...;
\r
289 // oContext.pixels.bottom = ...;
\r
290 // oContext.pixels.right = ...;
\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
303 addTileLayer: function(tile_url, opacity, copyright_text, min_zoom, max_zoom) {
\r
304 throw 'Not implemented';
\r
307 toggleTileLayer: function(tile_url) {
\r
308 throw 'Not implemented';
\r
311 getPixelRatio: function() {
\r
312 throw 'Not implemented';
\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
325 locDisp.innerHTML = "0.0000 / 0.0000";
\r
332 toProprietary: function() {
\r
333 return new VELatLong(this.lat, this.lon);
\r
336 fromProprietary: function(mpoint) {
\r
337 this.lat =mpoint.Latitude;
\r
338 this.lon =mpoint.Longitude;
\r
345 toProprietary: function() {
\r
346 var mmarker = new VEShape(VEShapeType.Pushpin, this.location.toProprietary('microsoft'));
\r
353 openBubble: function() {
\r
354 var mmarker = this.proprietary_marker;
\r
355 map.ClearInfoBoxStyles();
\r
356 mmarker.SetTitle(this.infoBubble);
\r
360 this.proprietary_marker.hide();
\r
364 this.proprietary_marker_unhide();
\r
367 update: function() {
\r
368 throw 'Not implemented';
\r
375 toProprietary: function() {
\r
377 for(var i =0, length = this.points.length; i < length; i++)
\r
379 mpoints.push(this.points[i].toProprietary('microsoft'));
\r
381 var mpolyline = new VEShape(VEShapeType.Polyline, mpoints);
\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
388 // TODO ability to change line width
\r
393 this.proprietary_polyline.Show();
\r
397 this.proprietary_polyline.Hide();
\r