google_maps.js
1.37 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
var map;
var mapPoints = {};
var mapBounds;
var mapDefaultIcon = new GIcon(G_DEFAULT_ICON);
function mapPutMarker(lat, lng, title, _icon, url) {
var point_str = lat + ":" + lng;
var icon = _icon == null ? mapDefaultIcon : _icon;
if (mapPoints[point_str]) {
lng += (Math.random() - 0.5) * 0.02;
lat += (Math.random() - 0.5) * 0.02;
} else {
mapPoints[point_str] = true;
}
var point = new GLatLng(lat, lng);
var options = { 'title' : title, 'icon' : icon };
var marker = new GMarker(point, options);
map.addOverlay(marker);
GEvent.addListener(marker, 'click', function() {
if (url) {
jQuery.ajax({url: url,
success: function(data) {
map.openInfoWindowHtml(point, jQuery(data).html());
}
});
}
});
mapBounds.extend(point);
return marker;
}
window.unload = function() {
GUnload();
};
function mapLoad(initial_zoom) {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
new GKeyboardHandler(map);
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
centerPoint = new GLatLng(-15.0, -50.1419);
map.setCenter(centerPoint, initial_zoom);
mapBounds = new GLatLngBounds();
}
}
function mapCenter(latlng) {
map.setZoom(map.getBoundsZoomLevel(mapBounds));
map.setCenter(latlng ? latlng : mapBounds.getCenter());
}