maps.js 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. $(document).ready(function(){
  2. /* Google maps */
  3. if($("#google_kyiv_map").length > 0){
  4. var gKyivCords = new google.maps.LatLng(50.43, 30.60);
  5. var gKyivOptions = {zoom: 10,center: gKyivCords, mapTypeId: google.maps.MapTypeId.ROADMAP}
  6. var gKyiv = new google.maps.Map(document.getElementById("google_kyiv_map"), gKyivOptions);
  7. var kcords = new google.maps.LatLng(50.43, 30.60);
  8. var kmarker = new google.maps.Marker({position: kcords, map: gKyiv, title: "Office title"});
  9. }
  10. if($("#google_world_map").length > 0){
  11. var gWorldCords = new google.maps.LatLng(50, 0);
  12. var gWorldOptions = {zoom: 1,center: gWorldCords, mapTypeId: google.maps.MapTypeId.ROADMAP}
  13. var gWorld = new google.maps.Map(document.getElementById("google_world_map"), gWorldOptions);
  14. var gEUCords = new google.maps.LatLng(50, 10);
  15. var gEUOptions = {zoom: 3,center: gEUCords, mapTypeId: google.maps.MapTypeId.ROADMAP}
  16. var gEU = new google.maps.Map(document.getElementById("google_eu_map"), gEUOptions);
  17. var gPTMCords = new google.maps.LatLng(50.43, 30.60);
  18. var gPTMOptions = {zoom: 8,center: gPTMCords, mapTypeId: google.maps.MapTypeId.ROADMAP}
  19. var gPTM = new google.maps.Map(document.getElementById("google_ptm_map"), gPTMOptions);
  20. var cords = new google.maps.LatLng(50.37, 30.65);
  21. var marker = new google.maps.Marker({position: cords, map: gPTM, title: "Marker 1"});
  22. cords = new google.maps.LatLng(50.5, 30.55);
  23. marker = new google.maps.Marker({position: cords, map: gPTM, title: "Marker 2"});
  24. cords = new google.maps.LatLng(50.8, 30.55);
  25. marker = new google.maps.Marker({position: cords, map: gPTM, title: "Marker 3"});
  26. function google_map_search() {
  27. var gSearch = new google.maps.Map(document.getElementById('google_search_map'), {
  28. mapTypeId: google.maps.MapTypeId.ROADMAP
  29. });
  30. var defaultBounds = new google.maps.LatLngBounds(
  31. new google.maps.LatLng(-33.8902, 151.1759),
  32. new google.maps.LatLng(-33.8474, 151.2631));
  33. gSearch.fitBounds(defaultBounds);
  34. var input = /** @type {HTMLInputElement} */(document.getElementById('target'));
  35. var searchBox = new google.maps.places.SearchBox(input);
  36. var markers = [];
  37. google.maps.event.addListener(searchBox, 'places_changed', function() {
  38. var places = searchBox.getPlaces();
  39. for (var i = 0, marker; marker = markers[i]; i++) {
  40. marker.setMap(null);
  41. }
  42. markers = [];
  43. var bounds = new google.maps.LatLngBounds();
  44. for (var i = 0, place; place = places[i]; i++) {
  45. var image = {
  46. url: place.icon,
  47. size: new google.maps.Size(71, 71),
  48. origin: new google.maps.Point(0, 0),
  49. anchor: new google.maps.Point(17, 34),
  50. scaledSize: new google.maps.Size(25, 25)
  51. };
  52. var marker = new google.maps.Marker({
  53. map: gSearch,
  54. icon: image,
  55. title: place.name,
  56. position: place.geometry.location
  57. });
  58. markers.push(marker);
  59. bounds.extend(place.geometry.location);
  60. }
  61. gSearch.fitBounds(bounds);
  62. });
  63. google.maps.event.addListener(gSearch, 'bounds_changed', function() {
  64. var bounds = gSearch.getBounds();
  65. searchBox.setBounds(bounds);
  66. });
  67. }
  68. google.maps.event.addDomListener(window, 'load', google_map_search);
  69. }
  70. /* EOF Google maps */
  71. });