[英]Google Map not showing after uploading to server, locally works fine
I'm trying to implement a simple page that have google maps enabled, but I'm having an issue where my google maps marker is not showing after uploading the files to the hosting, it works fine locally. 我正在尝试实现一个启用了Google Maps的简单页面,但是我遇到一个问题,在将文件上传到托管后,我的Google Maps标记未显示,在本地运行良好。
Here's the script I'm using 这是我正在使用的脚本
var styles = [ { "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":"on"} ] }, { "featureType":"water", "elementType":"labels", "stylers":[ {"visibility":"on"}, {"lightness":-25}, {"saturation":-100} ] }, { "featureType":"water", "elementType":"geometry", "stylers":[ {"hue":"#ffffff"}, {"lightness":0}, {"saturation":0} ] } ]; $("#my-map").gmap3({ marker:{ address: '96 New Moor St, Colombo' }, map:{ options:{ styles: styles, zoom: 14, scrollwheel: false, draggable: true, zoomControl: true, zoomControlOptions: { style: google.maps.ZoomControlStyle.SMALL }, mapTypeControl: false, scaleControl: false, scrollwheel: false, streetViewControl: false } } }); // Show Map $(".show-map").click(function(){ if ($(".map").hasClass("opened")) { $(".map").removeClass("opened"); $(".show-map i").removeClass("fa-minus"); $(".show-map span").text("Show Map"); } else { $(".map").addClass("opened"); $(".show-map i").addClass("fa-minus"); $(".show-map span").text("Hide Map"); } });
The snippet gives error "$ is not defined" . 该代码段给出错误“未定义$”。 I think you missed the JQuery import in your code , while uploading files to server, because that seems to be the issue.
我认为您在将文件上传到服务器时错过了代码中的JQuery导入,因为这似乎是问题所在。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.