我一直在使用Adobe muse开发网站,我选择在公司联系页面上实施自定义Google Map。我已经使用了一些基本的JavaScript,通过在里面插入'HTML Element'来插入到Muse文件中,我有我的JS。将Google Maps标记图标更改为自定义图标
我还应该提到,我通过页面的元数据(通过页面>页面属性>缪斯内的元数据访问)链接到页面'头部'的Google Maps API(以及我的相关密钥)。
遵循Google提供的指南,我创建了一个自定义地图,然后应用一些额外的样式,使用通过[https://snazzymaps.com]生成的JS。
我的问题出现在试图替换默认的标记图标,用我自己的标记在Illustrator中创建(本地存储在我的iMac中),我跟随了不同指南的负载,尝试了多种方式实现自定义图标,但没有任何运气 - 有人可以告诉我我要去哪里错了吗?这将非常感激。
这里是我JS的外观缪斯HTML元素>
<script>
function initMap() {
var myLatLng = {lat: 51.454137, lng: -2.473673};
var map = new google.maps.Map(document.getElementById('u64615'),{
zoom: 16,
center: myLatLng,
styles:
[
{
"featureType": "administrative",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#444444"
}
]
},
{
"featureType": "landscape",
"elementType": "all",
"stylers": [
{
"color": "#f2f2f2"
}
]
},
{
"featureType": "poi",
"elementType": "all",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "poi",
"elementType": "geometry",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "poi",
"elementType": "geometry.fill",
"stylers": [
{
"color": "#f10019"
},
{
"visibility": "simplified"
}
]
},
{
"featureType": "poi",
"elementType": "labels",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "poi",
"elementType": "labels.text",
"stylers": [
{
"visibility": "simplified"
},
{
"color": "#f10019"
}
]
},
{
"featureType": "poi",
"elementType": "labels.icon",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "poi.attraction",
"elementType": "all",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "poi.business",
"elementType": "all",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "poi.business",
"elementType": "geometry",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "poi.business",
"elementType": "geometry.fill",
"stylers": [
{
"visibility": "simplified"
},
{
"color": "#f10019"
}
]
},
{
"featureType": "poi.business",
"elementType": "geometry.stroke",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "poi.business",
"elementType": "labels",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "poi.business",
"elementType": "labels.text",
"stylers": [
{
"visibility": "on"
}
]
},
{
"featureType": "poi.business",
"elementType": "labels.icon",
"stylers": [
{
"visibility": "off"
},
{
"weight": "0.01"
}
]
},
{
"featureType": "poi.government",
"elementType": "all",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "poi.medical",
"elementType": "all",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "poi.park",
"elementType": "all",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "poi.place_of_worship",
"elementType": "all",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "poi.school",
"elementType": "all",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "poi.sports_complex",
"elementType": "all",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "road",
"elementType": "all",
"stylers": [
{
"saturation": -100
},
{
"lightness": 45
},
{
"visibility": "on"
}
]
},
{
"featureType": "road.highway",
"elementType": "all",
"stylers": [
{
"visibility": "simplified"
}
]
},
{
"featureType": "road.arterial",
"elementType": "all",
"stylers": [
{
"visibility": "on"
}
]
},
{
"featureType": "road.arterial",
"elementType": "labels.icon",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "transit",
"elementType": "all",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "water",
"elementType": "all",
"stylers": [
{
"color": "#163742"
},
{
"visibility": "on"
}
]
}]
});
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
title: 'Precision Profiles Manufacturing'
});
var contentString =
'<div>'+
'<div>'+
'</div>'+
'<h1 style = "font-size:20px;padding-bottom:10px;"><b>Precision Profiles Manuafcturing</b></h1>'+
'<div id="bodyContent">'+
'<p>The regions leading supplier of aircraft and precision engineering solutions.<p>'+
'</div>'+
'</div>';
var infowindow = new google.maps.InfoWindow({
content: contentString,
maxWidth: 200,
maxHeight: 400,
});
marker.addListener('click', function() {
infowindow.open(map, marker);
}); } </script>
这个效果很好,但是只有你提供的Google沙滩旗图标,所有的Google图标都能正常工作,但是当我链接到我自己的图标时,它不会。 'var image ='/Images/Assets/pp-location-split.svg'; var marker = new google.maps。标记({ 位置:myLatLng, 地图:地图, 图标:图像, 标题:“精密型材制造” });' –
我一定是不正确的链接我的自定义图标的图像,这就是我能想到的唯一原因会导致Google图标出现,但不是我自己的! –
尝试在初始化图标时设置完整的URL。你在控制台中看到一些错误吗? –