【发布时间】:2015-06-02 03:58:21
【问题描述】:
我必须为一家公司制作地图,我必须将公司徽标放在一个标记上,并将容器图标放在其他 10 个标记上 但我不知道该怎么做: 这是我当前的代码:(所以我有第一个带有我的徽标的标记,但它是个人图像,所以看不到标记) 我必须创建一个像“marker2”这样的新变量吗? 并为图标的每个位置创建新变量?
var nice = new google.maps.LatLng(43.7101728,7.2619532);
var centre = new google.maps.LatLng(43.7101728,7.2619532);
var marker;
var map;
function initialize() {
var mapOptions = {
zoom: 14,
center: nice,
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
marker = new google.maps.Marker({
map:map,
draggable:false,
animation: google.maps.Animation.DROP,
position: centre,
icon:'image/abi06B.png'
});
google.maps.event.addListener(marker, 'click', toggleBounce);
}
function toggleBounce() {
if (marker.getAnimation() != null) {
marker.setAnimation(null);
} else {
marker.setAnimation(google.maps.Animation.BOUNCE);
}
}
google.maps.event.addDomListener(window, 'load', initialize);
#map-canvas {
position: absolute;
height: 100%;
width:100%;
}
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
<div id="map-canvas">
</div>
【问题讨论】:
-
不,我正在寻找不同的图标
-
(新的)可能的重复对每个标记都有不同的图标。您现有的代码不包含其他标记的任何信息。
标签: javascript google-maps icons marker