我想用一个不同的地标来构建一个网站的精确副本。
能否请您告诉我为了做到这一点我应该学习什么?
到目前为止,我已经创建了这个,并且不知道下一步该怎么做:
https://jsfiddle.net/hasnain721/01v7s2m4/6/
我是一个非常基本的程序员!
提前谢谢!
var map = new google.maps.Map(document.getElementById("map"), {
center: new google.maps.LatLng(53.3478, -6.2597),
zoom: 16,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var infoWindow = new google.maps.InfoWindow({
map: map
});
// Try HTML5 geolocation.
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var pos = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
//infoWindow.setPosition(pos);
// infoWindow.setContent('<b>You are here.</b><br><b>Lat:</b> '+position.coords.latitude+'<br><b>Lon:</b> '+position.coords.longitude);
map.setCenter(pos);
var marker = new google.maps.Marker({
position: pos,
map: map,
title: String(pos.lat) + ", " + String(pos.lng),
});
//draws out the path from current location to landmark
var flightPlanCoordinates = [{
lat: position.coords.latitude,
lng: position.coords.longitude
},
{
lat: 21.4224779,
lng: 39.8251832
}
];
var flightPath = new google.maps.Polyline({
path: flightPlanCoordinates,
geodesic: true,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2
});
flightPath.setMap(map);
//draws out the path from current location to landmark
},
function() {
handleLocationError(true, infoWindow, map.getCenter());
});
} else {
// Browser doesn't support Geolocation
handleLocationError(false, infoWindow, map.getCenter());
}
答案 0 :(得分:0)
您需要更改“ flightPlanCoordinates”变量的坐标。
指向自由女神像的样本:
var flightPlanCoordinates = [
{lat: position.coords.latitude, lng: position.coords.longitude},
{lat: 40.689249, lng: -74.0445}
];