Advertisement
Sdelkadrom

Untitled

Feb 23rd, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. function reInitMap(){
  2. address = "";
  3.  
  4. if($("#Apartment_customCity").is(":visible") && $("#Apartment_customCity").length){
  5. address += addAddressString($("#ap_country option:selected").html());
  6. address += addAddressString($("#Apartment_customCity").val());
  7. }
  8. else {
  9. if($("#Apartment_city_id").length){
  10. address += addAddressString($("#Apartment_city_id option:selected").html());
  11. } else {
  12. address += addAddressString($("#ap_country option:selected").html());
  13. address += addAddressString($("#ap_city option:selected").html());
  14. }
  15. }
  16.  
  17. if ($("#id_Apartmentaddress_"+lang).val()) {
  18. address += addAddressString($("#id_Apartmentaddress_"+lang).val());
  19. }
  20. else if ($("input[name=\'Apartment[address_"+lang+"]\']").val()) {
  21. address += addAddressString($("input[name=\'Apartment[address_"+lang+"]\']").val());
  22. }
  23.  
  24. $("#address_for_map").val(address);
  25.  
  26. // place code to end of queue
  27. if(useGoogleMap){
  28. setTimeout(function(){
  29. var tmpGmapCenter = mapGMap.getCenter();
  30.  
  31. google.maps.event.trigger($("#googleMap")[0], "resize");
  32. mapGMap.setCenter(tmpGmapCenter);
  33. }, 0);
  34. }
  35.  
  36. if(useYandexMap){
  37. setTimeout(function(){
  38. ymaps.ready(function () {
  39. globalYMap.container.fitToViewport();
  40. globalYMap.setCenter(globalYMap.getCenter());
  41. });
  42. }, 0);
  43. }
  44.  
  45. if(useOSMap){
  46. setTimeout(function(){
  47. L.Util.requestAnimFrame(mapOSMap.invalidateSize,mapOSMap,!1,mapOSMap._container);
  48. }, 0);
  49. }
  50. }
  51.  
  52. function findByAddress(){
  53. var address = $("#address_for_map").val();
  54. if(!address){
  55. error("' . tc('Please enter address') . '");
  56. return false;
  57. }
  58.  
  59. $.ajax({
  60. url: "' . Yii::app()->createUrl('/apartments/main/getGeo', array('id' => $model->id)) . '",
  61. data: { address: address },
  62. method: "get",
  63. dataType: "json",
  64. success: function(data) {
  65. if(data.status == "ok"){
  66. var newAddressLat = data.lat;
  67. var newAddressLng = data.lng;
  68. if(useGoogleMap && typeof markersGMap[' . $model->id . '] !== "undefined" && typeof mapGMap !== "undefined"){
  69. var latLng = new google.maps.LatLng(newAddressLat, newAddressLng);
  70. markersGMap[' . $model->id . '].setPosition(latLng);
  71. mapGMap.setCenter(latLng);
  72. }
  73. if(useYandexMap && typeof placemark !== "undefined" && typeof globalYMap !== "undefined"){
  74. placemark.geometry.setCoordinates([newAddressLat, newAddressLng]);
  75. globalYMap.setCenter([newAddressLat, newAddressLng]);
  76. }
  77. if(useOSMap && typeof markersOSMap[' . $model->id . '] !== "undefined" && typeof mapOSMap !== "undefined"){
  78. var newLatLng = new L.LatLng(newAddressLat, newAddressLng);
  79. markersOSMap[' . $model->id . '].setLatLng(newLatLng);
  80. mapOSMap.setView(newLatLng);
  81. }
  82. message(data.msg);
  83. } else {
  84. error(data.msg);
  85. }
  86. }
  87. });
  88.  
  89. return;
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement