Haritaya tıkladığımda, işaretçinin en yakın caddeye geçmesini istiyorum. Burada iyi bir exmaple var: http://econym.org.uk/gmap/example_snappath.htm (Ana Sayfa: http://econym.org.uk/gmap/snap.htm). Ancak - bu örnek google maps sürüm 2 içindir. Bunu v3'te yapmanın bir yolu var mı?Google Maps V3 en yakın caddeye yapışıyor
14
A
cevap
16
Verdiğiniz örnek, bir yön arama yaparak ve ardından ilk konumu elde ederek sonuca ulaşır. Oldukça güzel işler Revolution42 api v3 bu "haritası"
var directionsService = new google.maps.DirectionsService();
google.maps.event.addListener(map, 'click', function(event) {
var request = {
origin:event.latLng,
destination:event.latLng,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
var marker = new google.maps.Marker({
position: response.routes[0].legs[0].start_location,
map: map,
title:"Hello World!"
});
}
});
});
1
çok teşekkürler haritanızın adıdır aşağıdaki kodla gerçekleştirilir
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
<script type="text/javascript"
src="http://maps.googleapis.com/maps/api/js?key=YOU API KEY&sensor=false">
</script>
<script type="text/javascript">
function initialize() {
var myOptions = {
center: new google.maps.LatLng(-34.397, 150.644),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
var directionsService = new google.maps.DirectionsService();
google.maps.event.addListener(map, 'click', function(event) {
var request = {
origin:event.latLng,
destination:event.latLng,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
var marker = new google.maps.Marker({
position: response.routes[0].legs[0].start_location,
map: map,
title:"Hello World!"
});
}
});
});
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="width:100%; height:100%"></div>
</body>
</html>
İlgili konular
- 1. google maps api v3 - en yakın sokak görünümü
- 2. Google Maps En Yakın Kamu Hizmetlerini Bul
- 3. Google Maps v3 - mil
- 4. google maps v3
- 5. GWT + Google Maps API v3
- 6. Google Maps: Google Maps V3 ve ben kullanıyorum
- 7. Google Maps API V3 yumuşak zumu kapat
- 8. Google Maps API v3: Çizim Yöneticisi
- 9. google maps v3 API mouseover çokgenlerle mi?
- 10. Google Maps API v3: Özel işaretleyici
- 11. v2 - v3 Google Maps sarmalayıcı API'si
- 12. Oluşturduğum Google Maps V3 Circle & Circle, eşleşmiyor
- 13. Google Maps API V3 fromDivPixelToLatLng tutarlı değil
- 14. Google maps v3 Çoklu çizgi ipucu
- 15. Google Maps v3 API - Otomatik Tamamla (adres)
- 16. Google Maps API V3: harita sınırlarını sınırla
- 17. Çokgen çizimi tamamlandığında, google maps api v3
- 18. google maps api v3 etiketleri yok mu?
- 19. Google Maps API etiketi ile v3 işaretleyici
- 20. Google Maps v3 InfoWindow Çok Geniş
- 21. Google Maps API v3 - GIcon tanımlı değil
- 22. Google maps API V3 yöntemi fitBounds()
- 23. Google Maps v3 panTo Geri Arama?
- 24. Google maps marker görünmüyor API v3
- 25. Google Maps api V3 güncelleme işareti
- 26. google maps v3 yolunda rota rengini nasıl değiştirebilirim v3
- 27. Google maps v3 bilgi penceresi dış görünüm penceresi açılıyor
- 28. trigger google maps işaretçisi tıklayın
- 29. Google Maps için maksimum başlangıç zIndex V3 işaretçileri
- 30. Google Maps API v3 InfoBox eklentisi ile olay mizanpajı