次のコードは正しく機能しますが、「start」値は、マップを含むdivに割り当てられたdata-start属性から取得されます。
(ジオロケーションコードから)現在の場所の現在の座標を受け入れるには、次のものが必要です。
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ address: **start** }, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
opts.center = results[0].geometry.location;
self.map = new google.maps.Map($('#map')[0], opts);
$.post($('#stockists form').attr('action'), { query: start }, function(data) {
self.addMarkers(data.results);
});
self.locateUser();
} else {
alert("Geocoder failed due to: " + status);
}
});
開始値は、データ属性からの静的な値ではなく、現在の場所を取得することを想定しています。あなたはここで完全なコードを見ることができます
アイデアは、現在の場所に基づいてdata.resultsをロードすることです。