Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JavaScript信息窗口未显示_Javascript_Google Maps - Fatal编程技术网

JavaScript信息窗口未显示

JavaScript信息窗口未显示,javascript,google-maps,Javascript,Google Maps,在使用GoogleMapAPI时,我希望对我的第一个标记应用一个infoWindow,但它不会显示。我试着四处寻找帮助,但似乎没有任何效果。有什么想法吗?谢谢你的帮助 函数初始化(){ var mylatng=new google.maps.LatLng(51.843143,-2.643555), map=new google.maps.map(document.getElementById('map'){ 缩放:18, 中心:myLatlng }), var infowindow=new g

在使用GoogleMapAPI时,我希望对我的第一个标记应用一个infoWindow,但它不会显示。我试着四处寻找帮助,但似乎没有任何效果。有什么想法吗?谢谢你的帮助

函数初始化(){
var mylatng=new google.maps.LatLng(51.843143,-2.643555),
map=new google.maps.map(document.getElementById('map'){
缩放:18,
中心:myLatlng
}),
var infowindow=new google.maps.infowindow({
内容:“我们的总部设在这里。”
});
marker=新的google.maps.marker({
职位:myLatlng,
地图:地图,
标题:“我们的总部设在这里。”
});
google.maps.event.addListener(标记'click',函数(){
信息窗口。打开(地图、标记);
});
var accessPoint1=new google.maps.LatLng(51.840913,-2.638603),
marker1=新的google.maps.Marker({
位置:accessPoint1,
地图:地图,
标题:“接入点1”
});
var accessPoint2=new google.maps.LatLng(51.840913,-3.638603),
marker2=新的google.maps.Marker({
位置:accessPoint2,
地图:地图,
标题:“接入点2”
});
控件[google.maps.ControlPosition.TOP_CENTER].push($(“#findButton”)[0]);
函数成功回调(位置){
var latlng=new google.maps.latlng(position.coords.latitude,
位置坐标经度),
myOptions={
缩放:3,
中心:拉特林,
mapTypeControl:false,
导航控制选项:{
样式:google.maps.NavigationControlStyle.SMALL
},
mapTypeId:google.maps.mapTypeId.ROADMAP
},
边界=新的google.maps.LatLngBounds(latlng);
extend(marker.getPosition());
map.setOptions(myOptions);
映射边界(bounds);
新的google.maps.Marker({
位置:latlng,
地图:地图,
标题:“你在这里!”,
图标:'http://maps.gstatic.com/mapfiles/markers2/boost-marker-mapview.png'
});
}
函数errorCallback(){
警报(“恐怕您的浏览器不支持地理定位。”);
}
函数findMe(){
$(this.hide();
if(导航器.地理位置){
navigator.geolocation.getCurrentPosition(successCallback、errorCallback、{
超时:10000
});
}否则{
警报(“恐怕您的浏览器不支持地理定位。”);
}
}
$(“#findButton”)。单击(FindDME);
}

google.maps.event.addDomListener(窗口“加载”,初始化)我收到一个javascript错误,发布的代码
未捕获的SyntaxError:Unexpected token var
。在逗号分隔列表中间不能用分号来分隔变量声明:

var myLatlng = new google.maps.LatLng(51.843143, -2.643555),
    map = new google.maps.Map(document.getElementById('map'), {
        zoom: 18,
        center: myLatlng
    }),  //** comma

var infowindow = new google.maps.InfoWindow({
  content: "We are based here."
});  // semicolon, terminates the line
工作代码段:

函数初始化(){
var mylatng=new google.maps.LatLng(51.843143,-2.643555),
map=new google.maps.map(document.getElementById('map'){
缩放:12,
中心:myLatlng
}),
infowindow=新建google.maps.infowindow({
内容:“我们的总部设在这里。”
}),
marker=新的google.maps.marker({
职位:myLatlng,
地图:地图,
标题:“我们在这里!”
});
google.maps.event.addListener(标记'click',函数(){
信息窗口。打开(地图、标记);
});
var accessPoint1=new google.maps.LatLng(51.840913,-2.638603),
marker1=新的google.maps.Marker({
位置:accessPoint1,
地图:地图,
标题:“接入点1”
});
控件[google.maps.ControlPosition.TOP_CENTER].push($(“#findButton”)[0]);
函数成功回调(位置){
var latlng=new google.maps.latlng(position.coords.latitude,
位置坐标经度),
myOptions={
缩放:3,
中心:拉特林,
mapTypeControl:false,
导航控制选项:{
样式:google.maps.NavigationControlStyle.SMALL
},
mapTypeId:google.maps.mapTypeId.ROADMAP
},
边界=新的google.maps.LatLngBounds(latlng);
extend(marker.getPosition());
map.setOptions(myOptions);
映射边界(bounds);
新的google.maps.Marker({
位置:latlng,
地图:地图,
标题:“你在这里!”,
图标:'http://maps.gstatic.com/mapfiles/markers2/boost-marker-mapview.png'
});
}
函数errorCallback(){
警报(“恐怕您的浏览器不支持地理定位。”);
}
函数findMe(){
$(this.hide();
if(导航器.地理位置){
navigator.geolocation.getCurrentPosition(successCallback、errorCallback、{
超时:10000
});
}否则{
警报(“恐怕您的浏览器不支持地理定位。”);
}
}
$(“#findButton”)。单击(FindDME);
}
google.maps.event.addDomListener(窗口“加载”,初始化)
html,
身体,
#地图{
高度:500px;
宽度:500px;
边际:0px;
填充:0px
}