forked from hkdobrev/setmap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetmap.min.js
More file actions
111 lines (111 loc) · 5.04 KB
/
Copy pathsetmap.min.js
File metadata and controls
111 lines (111 loc) · 5.04 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
(function(f, s, j, k) {
function h(d, a) {
f.error(typeof d === t ? d : w[d] + (a ? a : m))
}
function u(d, a, c) {
a = c ? new g.LatLng(a, c) : a;
d.mapObj.setCenter(a);
return a
}
function x(d, a, c) {
d = f.trim(d);
y(d, function(b) {
u(a, b);
o(b, a, function(a) {
typeof c === n && c(b.lat(), b.lng(), a)
})
})
}
function z(d, a, c) {
function b() {
a.b = new g.LatLng(a.map.center.lat, a.map.center.lng);
try {
a.mapObj = new g.Map(d, {zoom:a.map.zoom, center:a.b, mapTypeId:a.map.type, zoomControlOptions:{style:a.map.g}, draggable:a.map.draggable, disableDefaultUI:a.map.disabled === i, scrollwheel:a.map.disabled === e, keyboardShortcuts:a.map.disabled === e, disableDoubleClickZoom:a.map.disabled === i, streetViewControl:a.map.f}), f.isArray(a.markers) ? (a.markerObjects = [], f.each(a.markers, function(c, b) {
var d = {map:a.mapObj, animation:b.animation || a.markerOptions.c, draggable:b.draggable || a.markerOptions.draggable, position:b.position ? new g.LatLng(b.position.lat, b.position.lng) : new g.LatLng(a.markerOptions.position.lat, a.markerOptions.position.lng), title:b.title || a.markerOptions.title}, e = new g.Marker(d), f;
typeof a.drop === n && d.draggable === i && (f = g.event.addListener(e, "dragend", function(b) {
o(b.latLng, a, function(d) {
a.drop.call({id:c, position:{lat:b.latLng.lat(), lng:b.latLng.lng(), address:d}})
})
}));
a.markerObjects.push({e:e, a:f, id:c})
}), c(i)) : (h(5), c(e))
}catch(b) {
h(b.message), c(e)
}
}
a.map.current ? s.geolocation ? s.geolocation.getCurrentPosition(function(c) {
a.map.center = {lat:c.coords.latitude, lng:c.coords.longitude};
b()
}, function() {
h(0);
b()
}) : (h(1), b()) : b()
}
function o(d, a, c) {
v.geocode({latLng:d}, function(b, d) {
var l = m;
d === g.GeocoderStatus.OK ? (a.d ? l = b[0].address_components : f.each(b[0].address_components, function(a, b) {
0 < a && (l += ", ");
l += b.long_name
}), c(l)) : (h(2, d), c(e))
})
}
function y(d, a) {
v.geocode({address:d}, function(c, b) {
b === g.GeocoderStatus.OK ? a(c[0].geometry.location) : (h(2, b), a(e))
})
}
var g = j.maps, v = new g.Geocoder, e = !1, i = !0, n = "function", m = "", t = "string", A = {map:{zoom:12, type:"hybrid", draggable:i, streetView:e, disabled:e, center:{lat:34.051, lng:-118.246}, current:!1, zoomControls:"large"}, markers:[], markerOptions:{animation:"drop", draggable:i, title:m, current:e, icon:e}, drop:e, components:e}, p = ["HYBRID", "TERRAIN", "ROADMAP", "SATELLITE"], q = ["DROP", "BOUNCE"], r = ["SMALL", "LARGE"], w = ["The Geolocation service failed", "Your browser doesn't support geolocation",
"Geocode was not successful for the following reason: ", "You should destroy the setmap instance first!", "The Gogle Maps Javascript API is not loaded!"];
"object" !== typeof j || "object" !== typeof j.maps ? h(4) : f.fn.setmap = function(d) {
var a = arguments, c, b, j = {init:function(a) {
if("object" === typeof c && !f.isPlainObject(c)) {
return h(3), b
}
f.extend(i, c, A, a);
b.attr("style") !== k && b.data("style.setmap", b.attr("style") + m);
c.map.type = g.MapTypeId[p[f.inArray(c.map.type.toUpperCase(), p)] || p[0]];
c.markerOptions.animation = g.Animation[q[f.inArray(c.markerOptions.animation.toUpperCase(), q)] || q[0]];
if(c.map.disabled !== e) {
c.map.disabled = i
}
c.map.zoomControls = g.ZoomControlStyle[r[f.inArray(c.map.zoomControls.toUpperCase(), r)] || r[0]];
z(this, c, function(a) {
a && b.data("object.setmap", c)
});
return b
}, getMap:function() {
return c.mapObj
}, zoom:function(a) {
if(a === k) {
return c.mapObj.getZoom()
}
"number" === typeof a && 0 < a && c.mapObj.setZoom(a);
return b
}, center:function(a, d, e) {
if("number" === typeof a && ("number" === typeof d || d === k)) {
var f = c, a = u(f, a, d);
typeof e === n && o(a, f, e);
return b
}
return typeof a === t && (d === k || typeof d === n) ? (x(a, c, d), b) : c.mapObj.getCenter()
}, type:function(a) {
return a === k ? c.mapObj.getMapTypeId() : b
}, destroy:function() {
f.isPlainObject(c) || (b.data("style.setmap") !== k ? b.attr("style", b.data("style.setmap")) : b.removeAttr("style"), b.removeData("object.setmap"), b.removeData("style.setmap"), b.unbind(".setmap"), b.empty(), c.a && g.event.removeListener(c.a));
return b
}};
return this.each(function() {
b = f(this);
c = b.data("object.setmap") || {};
if(j[d] && "init" !== d) {
return j[d].apply(this, Array.prototype.slice.call(a, 1))
}
if("object" === typeof d || !d) {
return j.init.apply(this, a)
}
h("Method " + d + " does not exist on the setmap plugin!");
return e
})
}
})(jQuery, navigator, google);