Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Google maps v3 i zoom przy wyznaczaniu trasy.
muwie
post
Post #1





Grupa: Zarejestrowani
Postów: 30
Pomógł: 1
Dołączył: 21.02.2007
Skąd: Milejów

Ostrzeżenie: (0%)
-----


Witam,
Mam problem. Otóż chce ustalić na sztywno zoom przy wyznaczaniu trasy w google maps. Poniżej przedstawiam wam kod
  1. <!DOCTYPE html>
  2. <head>
  3. <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
  4. <meta charset="utf-8">
  5. <title>Google Maps JavaScript API v3 Example: Directions Simple</title>
  6. <link href="/maps/documentation/javascript/examples/default.css" rel="stylesheet">
  7. <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
  8. var directionDisplay;
  9. var directionsService = new google.maps.DirectionsService();
  10. var map;
  11.  
  12. function initialize() {
  13. directionsDisplay = new google.maps.DirectionsRenderer();
  14. var chicago = new google.maps.LatLng(41.850033, -87.6500523);
  15. var mapOptions = {
  16. zoom:13,
  17. mapTypeId: google.maps.MapTypeId.ROADMAP,
  18. center: chicago,
  19.  
  20. }
  21. map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
  22. directionsDisplay.setMap(map);
  23. }
  24.  
  25. function calcRoute() {
  26.  
  27.  
  28. var start = document.getElementById('skad').value;
  29. var end = document.getElementById('dokad').value;
  30. var request = {
  31. origin:start,
  32. destination:end,
  33. travelMode: google.maps.DirectionsTravelMode.DRIVING
  34. };
  35. directionsService.route(request, function(response, status) {
  36. if (status == google.maps.DirectionsStatus.OK) {
  37. //directionsDisplay.setOptions({ });
  38.  
  39. directionsDisplay.setDirections(response);
  40. }
  41. });
  42. }
  43. </script>
  44. html, body {
  45. height: 100%;
  46. margin: 0;
  47. padding: 0;
  48. }
  49.  
  50. #map_canvas {
  51. height: 100%;
  52. }
  53.  
  54. @media print {
  55. html, body {
  56. height: auto;
  57. }
  58.  
  59. #map_canvas {
  60. height: 650px;
  61. }
  62. }
  63.  
  64. </head>
  65. <body onload="initialize()">
  66. <div>
  67. <b>Start: </b>
  68. <input id="skad">
  69.  
  70. <b>End: </b>
  71. <input id="dokad" >
  72. <input type="button" value="Pokaż" onclick="calcRoute();">
  73. </div>
  74. <div id="map_canvas" style="top:30px;"></div>
  75. </body>
  76. </html>
  77.  

Teraz zoom dobiera się optymalnie, a chciałbym zmniejszyć zoom
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
muwie
post
Post #2





Grupa: Zarejestrowani
Postów: 30
Pomógł: 1
Dołączył: 21.02.2007
Skąd: Milejów

Ostrzeżenie: (0%)
-----


Dzięki za odpowiedź, ale to nie pomogło
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.12.2025 - 17:42