나는 하나의지도에 설정할 수 4 배, 그래서 나는 Google 개발자 예제를 사용하고 난 세트 3 노호 다음 함수에서
https://developers.google.com/maps/documentation/javascript/examples/icon-complex
그것을 트위스트 더 많은 색상 옵션 :
function setMarkers(map, locations) {
...
var image = {
url: 'img/bullet_amarelo.png',
// This marker is 20 pixels wide by 32 pixels tall.
size: new google.maps.Size(40, 40),
// The origin for this image is 0,0.
origin: new google.maps.Point(0,0),
// The anchor for this image is the base of the flagpole at 0,32.
anchor: new google.maps.Point(0, 40)
};
var image1 = {
url: 'img/bullet_azul.png',
// This marker is 20 pixels wide by 32 pixels tall.
size: new google.maps.Size(40, 40),
// The origin for this image is 0,0.
origin: new google.maps.Point(0,0),
// The anchor for this image is the base of the flagpole at 0,32.
anchor: new google.maps.Point(0, 40)
};
var image2 = {
url: 'img/bullet_vermelho.png',
// This marker is 20 pixels wide by 32 pixels tall.
size: new google.maps.Size(40, 40),
// The origin for this image is 0,0.
origin: new google.maps.Point(0,0),
// The anchor for this image is the base of the flagpole at 0,32.
anchor: new google.maps.Point(0, 40)
};
var image3 = {
url: 'img/bullet_verde.png',
// This marker is 20 pixels wide by 32 pixels tall.
size: new google.maps.Size(40, 40),
// The origin for this image is 0,0.
origin: new google.maps.Point(0,0),
// The anchor for this image is the base of the flagpole at 0,32.
anchor: new google.maps.Point(0, 40)
};
...
}
이
for (var i = 0; i < locations.length; i++) {
...
if (i==0) var imageV=image;
if (i==1) var imageV=image1;
if (i==2) var imageV=image2;
if (i==3) var imageV=image3;
...
# remember to change icon: image to icon: imageV
}
최종 결과 :
http://www.mercosul-line.com.br/site/teste.html
대단히 감사합니다 :) 이것은 내가 찾고있는 것입니다. 제가 알 수 있겠지만, 내가 이것을 보여 주거나 별도로 정의한 곳에서 마커를 인스턴스화하는 장소에 이것을 적용합니까? :) –
둘 다 작동합니다. 여러분은'icon' 속성을 추가하고 그것을 설정할 수도 있고'setIcon'을 사용할 수도 있습니다. 이것에 관한 메모를 추가하겠습니다. – jsalonen
도와 주셔서 대단히 감사합니다 :) –