我是新来的,所以我知道我没有任何可信度。我是一名艺术家,并且是编程新手,所以我知道如果没有人会接受这个。我发布这个是因为这是一个简单的问题。-S
这是创建多个标记的代码(主要来自谷歌开发者网站)。它工作正常并为每个标记创建一个自定义图标。单击时,每个标记都应该播放不同的音频文件(现在只有最后一个创建的标记会播放)。我还想在播放音频文件时更改图标。我正在使用 javascript 和声音管理器 2 播放音频 - 但我感兴趣的是:我如何引用数组中的每个标记,以便我可以播放分配给该特定标记的特定音频文件?
我希望我在没有 XML 和数据库的情况下做到这一点。-萨宾
以下是相关代码:
setMarkers(map, beaches);
}
var beaches = [
['Devotion', 40.710431,-73.948432, 0],
['Tester', 40.711223,-73.958416, 1],
];
function setMarkers(map, locations) {
var image = new google.maps.MarkerImage('biker.png',
// This marker is 20 pixels wide by 32 pixels tall.
new google.maps.Size(32, 32),
// The origin for this image is 0,0.
new google.maps.Point(0,0),
// The anchor for this image is the base of the flagpole at 0,32.
new google.maps.Point(0, 32)
);
var newimage = new google.maps.MarkerImage('biker_click.png',
// This marker is 20 pixels wide by 32 pixels tall.
new google.maps.Size(32, 32),
// The origin for this image is 0,0.
new google.maps.Point(0,0),
// The anchor for this image is the base of the flagpole at 0,32.
new google.maps.Point(0, 32)
);
var shape = {
coord: [1, 1, 1, 20, 18, 20, 18 , 1],
type: 'poly'
};
for (var i = 0; i < locations.length; i++) {
var beach = locations[i];
var myLatLng = new google.maps.LatLng(beach[1], beach[2]);
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
icon: image,
shape: shape,
title: beach[0],
zIndex: beach[3],
});
}
function markerClick() {
console.log('click');
}
google.maps.event.addListener(marker, 'click', markerClick);
function markerClick() {
var playing = sm2.toggle('http://mm1.ellieirons.com/wp-content/uploads/2012/03/beeps_bubbles.mp3', true);
if (playing) {
this.setIcon(newimage);
} else {
this.setIcon(image);
}
}