-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathjquery-ui.placepicker.bing-maps.js
86 lines (72 loc) · 1.91 KB
/
jquery-ui.placepicker.bing-maps.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
( function ( $ ) {
function BingMap ( options ) {
var self = this;
self.options = options;
self.zoom[ $.ui.placepicker.zoom.STREET ] = 14;
if ( self.options.click ) {
options.map.AttachEvent( 'onclick', function ( e ) {
self.options.click( self._getLatLng( {
latLong: e.latLong,
pixel: new VEPixel( e.mapX, e.mapY )
} ) );
} );
}
}
$.extend( BingMap.prototype, $.ui.placepicker.Map.prototype, {
markers: [],
defaults: {
marker: {
}
},
panTo: function ( latlng ) {
options.map.PanToLatLong(
new VELatLong( latlng.lat, latlng.lng ) );
},
zoom: function ( zoom ) {
options.map.SetZoomLevel( this.zoom[ zoom ] );
},
createMarker: function ( options ) {
var latlng = new VELatLong( 0, 0 );
if ( options.latlng ) {
latlng = this._bingLatLng( options.latlng );
}
options._bingPin = new VEShape( VEShapeType.Pushpin, latlng );
if ( options.icon ) {
options._bingPin.SetCustomIcon( options.icon );
}
this.options.map.AddShape(options._bingPin);
return options;
},
showMarker: function ( marker, latlng ) {
marker._bingPin.SetPoints( [ this._bingLatLng( latlng ) ] );
marker._bingPin.Show();
},
hideMarker: function ( marker ) {
marker._bingPin.Hide();
},
updateMarker: function ( marker ) {
// TODO: Update changed properties
//if ( marker.latlng
},
getCenter: function () {
var latlng = this.options.map.GetCenter();
return {
lat: latlng.Latitude,
lng: latlng.Longitude
};
},
_bingLatLng: function ( latlng ) {
return new VELatLong( latlng.lat, latlng.lng );
},
_getLatLng: function ( query ) {
var latlng = query.latLong ? query.latLong
: options.map.PixelToLatLong( query.pixel );
return {
lat: latlng.Latitude,
lng: latlng.Longitude
};
}
} );
$.ui.placepicker.map.push( BingMap );
$.ui.placepicker.map[ 'Bing' ] = BingMap;
} )( jQuery );