Googleマップの抜粋をいくつか表示し、いくつかのマーカーをクラスタにまとめた(完了した)ページを開発することが提案されました。私はjavascriptでの経験がなく、ボタンをクリックしてもしなくても、自分の位置を取得し、地図上のどの点が私に近いかを自動的に知らせることができます。誰か助けてくれますか?あなたが空中距離について話している場合は 座標を取得し、距離を測定し、それらを比較する
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 13,
center: {lat: 40.963308, lng: -8.594651}
});
// Create an array of alphabetical characters used to label the markers.
var labels = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
// Add some markers to the map.
// Note: The code uses the JavaScript Array.prototype.map() method to
// create an array of markers based on a given "locations" array.
// The map() method here has nothing to do with the Google Maps API.
var markers = locations.map(function(location, i) {
return new google.maps.Marker({
position: location,
label: labels[i % labels.length]
});
});
// Add a marker clusterer to manage the markers.
var markerCluster = new MarkerClusterer(map, markers,
{imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m'});
}
var locations = [
{lat: 40.962157, lng: -8.593313},
{lat: 40.962149, lng: -8.595695},
{lat: 40.960351, lng: -8.598922},
{lat: 40.967305, lng: -8.591450},
{lat: 40.961682, lng: -8.608136}
]
</script>
[Google Maps API - 郵便番号に最も近いポイントを取得する]の複製が可能です(https://stackoverflow.com/questions/17280787/google-maps-api-getting-closest-points-to-zipcode) – geocodezip