Javascript 无法显示特定坐标的谷歌地图
我正试图展示一幅海地国家的地图 发现其坐标为北纬18.5333度,西经72.3333度 我试图以不同的方式将它放在下面的代码中,但它不起作用 地图适合我自己的位置 我的代码:Javascript 无法显示特定坐标的谷歌地图,javascript,asp.net,google-maps,Javascript,Asp.net,Google Maps,我正试图展示一幅海地国家的地图 发现其坐标为北纬18.5333度,西经72.3333度 我试图以不同的方式将它放在下面的代码中,但它不起作用 地图适合我自己的位置 我的代码: if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function (p) { //Tried to put static lati longi in many ways p.coords.lati
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (p) {
//Tried to put static lati longi in many ways
p.coords.latitude = '18.5333';
p.coords.longitude = '72.3333';
//also Tried this :
//var LatLng = new google.maps.LatLng(18.5333, 72.3333);
//var LatLng = new google.maps.LatLng('18.5333', '72.3333');
var LatLng = new google.maps.LatLng(p.coords.latitude,
p.coords.longitude);
var mapOptions = {
center: LatLng,
zoom: 4,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("dvMap"),
mapOptions);
});
} else {
alert('Geo Location feature is not supported in this browser.');
}
这里缺少什么?确定找到了解决方案 只是需要改变坐标 以下站点提供了正确的坐标作为位置: 我的代码:
var mapOptions = {
center: new google.maps.LatLng(18.971187,-72.275215),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);