-
Notifications
You must be signed in to change notification settings - Fork 2
/
bingmap.min.js
1 lines (1 loc) · 2.87 KB
/
bingmap.min.js
1
(function(a){var b={api:"Your API Key",type:"road",zoom:5,width:null,height:null,latitude:48.833,longitude:2.333,bing_logo:true,search_logo:false,scaleBar:false,control:false,copy:false,disable_zoom:true,disable_navigate:true},c,d,e,f=[],g=[{name:"road",def:Microsoft.Maps.MapTypeId.road},{name:"sky",def:Microsoft.Maps.MapTypeId.aerial},{name:"bird",def:Microsoft.Maps.MapTypeId.birdseye}],h=Microsoft.Maps.MapTypeId.road,i={init:function(e){var i=this;f[i.attr("id")]=[];return this.each(function(){if(e)c=a.extend(true,{},b,e);for(var f=0;f<=2;f++){if(c.type==g[f].name){h=g[f].def}}d=new Microsoft.Maps.Map(this,{credentials:c.api,mapTypeId:h,center:new Microsoft.Maps.Location(c.latitude,c.longitude),zoom:parseFloat(c.zoom),width:i.innerWidth(),height:i.innerHeight(),showScalebar:c.scaleBar,showMapTypeSelector:false,showDashboard:c.control,showLogo:c.bing_logo,showCopyright:c.copy,enableSearchLogo:c.search_logo,enableClickableLogo:false,disableKeyboardInput:true,fixedMapPosition:true,disableZooming:c.disable_zoom,disablePanning:c.disable_navigate})})},newPin:function(a){var b=this;return b.each(function(){var c=null;if("undefined"!==typeof a){if("undefined"===typeof a.length){var e=a.drag?true:false;c=new Microsoft.Maps.Pushpin({latitude:a.latitude,longitude:a.longitude},{draggable:e});d.entities.push(c);f[b.attr("id")].push(c)}else{for(c in a){b.bingmap("newPin",a[c])}}}if("undefined"!==typeof a.popup){a.popup.geo={latitude:a.latitude,longitude:a.longitude};a.popup.pin=c;b.bingmap("addPopup",a.popup)}})},addPopup:function(a){if("undefined"==typeof a.html)a.html="";if("undefined"==typeof a.width)a.width=200;if("undefined"==typeof a.height)a.height=50;var b=true;if("undefined"!==typeof a.onShow)b=false;var c={title:a.title,description:a.html,width:a.width,height:a.height,visible:b,showPointer:false,offset:new Microsoft.Maps.Point(15,35)};var e=new Microsoft.Maps.Infobox(new Microsoft.Maps.Location(a.geo.latitude,a.geo.longitude),c);if("undefined"!==typeof a.onShow){Microsoft.Maps.Events.addHandler(a.pin,"mouseover",f);Microsoft.Maps.Events.addHandler(a.pin,"mouseout",g);function f(){e.setOptions({visible:true})}function g(){e.setOptions({visible:false})}}d.entities.push(e)},onPin:function(a){return this.each(function(b,c){return a(f[c.getAttribute("id")],d)})},onMap:function(a){return a(d)},getPin:function(){return f[this.attr("id")]},getMap:function(){return d},getInfo:function(b){var d="http://dev.virtualearth.net/REST/v1/Locations/"+b.latitude+","+b.longitude+"?o=json&jsonp=?&key="+c.api;return this.each(function(c,e){a.getJSON(d,function(a){var c=a.authenticationResultCode=="ValidCredentials"?"success":"fail";return b.callback(c,a.resourceSets)})})}};a.fn.bingmap=function(b){if(i[b]){return i[b].apply(this,Array.prototype.slice.call(arguments,1))}else if(typeof b==="object"||!b){return i.init.apply(this,arguments)}else{a.error("Method "+b+" does not exist on jQuery.BingMap")}}})(jQuery)