-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathjquery.simplemap.js
91 lines (71 loc) · 2.06 KB
/
jquery.simplemap.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
87
88
89
90
91
var mapGlobal;
var markers = [];
var infoWindow;
// This script was written by Steve Fenton
// http://www.stevefenton.co.uk/Content/Jquery-Simple=Map/
// Feel free to use this jQuery Plugin
// Version: 1.1.0
// Contributions by:
var SimpleMap = function() {
return {
MapList : new Array(),
Geocoder : new google.maps.Geocoder(),
GetLatLong : function (address) {
},
SetMarkers : function(addresses) {
var i;
for (i = 0; i < addresses.length; i++) {
this.Geocoder.geocode({ 'address': addresses[i] }, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var markersCount = markers.length;
markers[markersCount] = new google.maps.Marker({
position: results[0].geometry.location,
map: mapGlobal,
html: results[0].formatted_address.replace(/,/g, "<br>")
});
google.maps.event.addListener(markers[markersCount], "click", function () {
infoWindow.setContent(this.html);
infoWindow.open(mapGlobal, this);
});
} else {
alert("Could not load map: " + status);
}
});
}
},
StartMap : function(parentObject, config) {
infoWindow = new google.maps.InfoWindow({
content: "loading..."
});
this.Geocoder.geocode({ 'address': config.addressList[0] }, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var myOptions = {
zoom: config.zoom,
center: results[0].geometry.location,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
mapGlobal = new google.maps.Map(parentObject, myOptions);
} else {
alert("Could not load map: " + status);
}
});
this.SetMarkers(config.addressList);
}
};
}();
(function($) {
$.fn.simplemap = function (settings) {
var config = {
classModifier: "simplemaps",
addressList: ["Buckingham Palace, London", "Wellington Arch, London"],
zoom: 15
};
if (settings) {
$.extend(config, settings);
}
return this.each(function () {
SimpleMap.StartMap(this, config);
});
return this;
};
})(jQuery);