окей, разобрался почти-что!
РЕБЯТ НУ ПОМОГИТЕ!
Все вроде бы окей, но только консоль уже ругается
TypeError: marker.getPosition is not a function. (In 'marker.getPosition()', 'marker.getPosition' is undefined)
Тобишь, если я правильно интерпретировал, то он не может в блоке
Javascript | 1
2
3
4
| var marker = new google.maps.Marker({
map: map,
position: point,
icon: icon.icon}); |
|
получить данные позиции поинтера.
Ругается причем на официальные гугловские js-скрипты (14 ошибок)
Вот весь листинг:
Javascript | 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
| //<![CDATA[
var customIcons = {
restaurant: {icon: 'assets/img/map/pointer_green.png'},
bar: {icon: 'assets/img/map/pointer_favourited.png'}};
var options = {imagePath: 'assets/img/map/pointer_green.png'};
function load() {
var map = new google.maps.Map(document.getElementById("map"), {
center: {lat: 47.6145, lng: -122.3418},
zoom: 10,
mapTypeId: 'roadmap',
disableDefaultUI: 'true'
});
var infoWindow = new google.maps.InfoWindow;
navigator.geolocation.getCurrentPosition(function(position) {
var pos = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
map.setCenter(pos);
});
downloadUrl("system/phpsqlajax_genxml.php", function(data) {
var xml = data.responseXML;
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var name = markers[i].getAttribute("name");
var address = markers[i].getAttribute("address");
var type = markers[i].getAttribute("type");
var point = new google.maps.LatLng(
parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
var html = "<img scr='/assets/img/map/pointer_green.png'><b>" + name + "</b> <br/>" + address + "<form><button>follow</button></form>";
var icon = customIcons[type] || {};
var marker = new google.maps.Marker({
map: map,
position: point,
icon: icon.icon});
var markerCluster = new MarkerClusterer(map, markers,options);
bindInfoWindow(marker, map, infoWindow, html);
}
});
}
function bindInfoWindow(marker, map, infoWindow, html) {
google.maps.event.addListener(marker, 'click', function() {
infoWindow.setContent(html);
infoWindow.open(map, marker);
});
}
function downloadUrl(url, callback) {
var request = window.ActiveXObject ?
new ActiveXObject('Microsoft.XMLHTTP') :
new XMLHttpRequest;
request.onreadystatechange = function() {
if (request.readyState == 4) {
request.onreadystatechange = doNothing;
callback(request, request.status);
}
};
request.open('GET', url, true);
request.send(null);
}
function doNothing() {}
//]]> |
|
Добавлено через 51 минуту
РЕШЕНО!
Если есть вопросы, попробую ответить)
Javascript | 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
| //<![CDATA[
var customIcons = {
restaurant: {icon: 'assets/img/map/pointer_green.png'},
bar: {icon: 'assets/img/map/pointer_favourited.png'}};
var options = {imagePath: 'assets/img/map/m'};
function load() {
var map = new google.maps.Map(document.getElementById("map"), {
center: {lat: 47.6145, lng: -122.3418},
// center: new google.maps.LatLng(47.6145, -122.3418),
// zoom: 15,
zoom: 10,
mapTypeId: 'roadmap',
disableDefaultUI: 'true'
});
var infoWindow = new google.maps.InfoWindow;
// ---------------------
// ---------------------Try HTML5 geolocation.
// ---------------------
navigator.geolocation.getCurrentPosition(function(position) {
var pos = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
map.setCenter(pos);
});
// ---------------------
//--------------------end of geolocation
// ---------------------
// Change this depending on the name of your PHP file
downloadUrl("system/phpsqlajax_genxml.php", function(data) {
var xml = data.responseXML;
var markerss = [];
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var name = markers[i].getAttribute("name");
var address = markers[i].getAttribute("address");
var type = markers[i].getAttribute("type");
var point = new google.maps.LatLng(
parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
//custom infowindow creating here
var html = "<img scr='/assets/img/map/pointer_green.png'><b>" + name + "</b> <br/>" + address + "<form><button>follow</button></form>";
var icon = customIcons[type] || {};
var marker = new google.maps.Marker({
map: map,
position: point,
icon: icon.icon});
markerss.push(marker);
bindInfoWindow(marker, map, infoWindow, html);
}
var markerCluster = new MarkerClusterer(map, markerss,options);
});
}
function bindInfoWindow(marker, map, infoWindow, html) {
google.maps.event.addListener(marker, 'click', function() {
infoWindow.setContent(html);
infoWindow.open(map, marker);
});
}
function downloadUrl(url, callback) {
var request = window.ActiveXObject ?
new ActiveXObject('Microsoft.XMLHTTP') :
new XMLHttpRequest;
request.onreadystatechange = function() {
if (request.readyState == 4) {
request.onreadystatechange = doNothing;
callback(request, request.status);
}
};
request.open('GET', url, true);
request.send(null);
}
function doNothing() {}
//]]> |
|
0
|