gpt4 book ai didi

javascript - 上传到服务器后谷歌地图标记不显示,本地工作正常

转载 作者:行者123 更新时间:2023-11-30 08:39:22 26 4
gpt4 key购买 nike

我正在尝试实现一个启用了谷歌地图的简单页面,但我遇到了一个问题,即在将文件上传到主机后我的谷歌地图标记没有显示,但它在本地运行良好。

我尝试使用自定义标记和默认标记,问题是一样的,它在本地有效但上传后无效。

这是我正在使用的脚本

/*GOOGLE MAPS*/

function initialize() {

// Declare map style
var grayscale = [{"featureType":"landscape","stylers":[{"saturation":-100},{"lightness":65},{"visibility":"on"}]},{"featureType":"poi","stylers":[{"saturation":-100},{"lightness":51},{"visibility":"simplified"}]},{"featureType":"road.highway","stylers":[{"saturation":-100},{"visibility":"simplified"}]},{"featureType":"road.arterial","stylers":[{"saturation":-100},{"lightness":30},{"visibility":"on"}]},{"featureType":"road.local","stylers":[{"saturation":-100},{"lightness":40},{"visibility":"on"}]},{"featureType":"transit","stylers":[{"saturation":-100},{"visibility":"simplified"}]},{"featureType":"administrative.province","stylers":[{"visibility":"off"}]},{"featureType":"water","elementType":"labels","stylers":[{"visibility":"on"},{"lightness":-25},{"saturation":-100}]},{"featureType":"water","elementType":"geometry","stylers":[{"hue":"#ffff00"},{"lightness":-25},{"saturation":-97}]}];

var mapOptions = {
center: {lat: 46.211000, lng: 16.913157},
zoom: 13,
scrollwheel: false

};

var map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);

// Change map style
map.setOptions({styles: grayscale});

var image = 'img/vemo-google-map-marker.png';
var marker = new google.maps.Marker({
position: {lat: 46.211000, lng: 16.913157},
map: map,
title: "VEMO TRADE d.o.o.",
icon: image,
});

}
google.maps.event.addDomListener(window, 'load', initialize);

enter image description here

最佳答案

您需要在此处指定完整的绝对路径:

var image = '//YOUR_DOMAIN/img/vemo-google-map-marker.png';

关于javascript - 上传到服务器后谷歌地图标记不显示,本地工作正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28112570/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com