现在,我必须设计一个简单的网页,其中输入GPS位置返回以下-
1. 最近的市场(s),最近的ATM(s),最近的地铁站(s),最近的餐厅(s)在地图上。
2. 这些点到表中输入位置的距离我已经四处阅读关于如何使用谷歌地图API,但我不能清楚地理解,我如何才能搜索特定类型的地方附近的给定坐标(半径内),然后适当地显示在我的谷歌地图:/
好吧,在工作了很多,看看这里和那里,这是我如何使用谷歌地图API v3:1.首先,您需要初始化您的地图,它应该以输入坐标为中心。
function initialize()
{
var lat=parseFloat(document.getElementById("Lat").value);
var lng=parseFloat(document.getElementById("Long").value);
map = new google.maps.Map(document.getElementById('map-canvas'),
{
center: new google.maps.LatLng(lat,lng),
zoom: 15,
styles: [
{
stylers: [
{ visibility: 'on' }
]
},
{
elementType: 'labels',
stylers: [
{ visibility: 'on' }
]
}
]
});
document.getElementById("map-canvas").style.borderColor="aquamarine ";
document.getElementById("help").innerHTML="<u>HELP</u><br> Click on a Place to find out the direction & distance.<br>";
/*The following creates a marker in the provided Coordiantes
using a DROP animation. Clicking on the marker will toggle
the animation between a BOUNCE animation and no animation.*/
var marker = new google.maps.Marker({
position: new google.maps.LatLng(lat,lng),
map: map,
animation: google.maps.Animation.DROP,
title:"You're Here!"
});
google.maps.event.addListener(marker,'click', toggleBounce);
infoWindow = new google.maps.InfoWindow();
service = new google.maps.places.PlacesService(map);
google.maps.event.addListenerOnce(map, 'bounds_changed', performSearch);
}
等等使用方向API和MAP API我创建了一个非常基本的地图适合任何初学者。https://drive.google.com/file/d/0B5NwjTjzPp9lV18zWGNMenF1Q0k/edit?usp=sharing