Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function reInitMap(){
- address = "";
- if($("#Apartment_customCity").is(":visible") && $("#Apartment_customCity").length){
- address += addAddressString($("#ap_country option:selected").html());
- address += addAddressString($("#Apartment_customCity").val());
- }
- else {
- if($("#Apartment_city_id").length){
- address += addAddressString($("#Apartment_city_id option:selected").html());
- } else {
- address += addAddressString($("#ap_country option:selected").html());
- address += addAddressString($("#ap_city option:selected").html());
- }
- }
- if ($("#id_Apartmentaddress_"+lang).val()) {
- address += addAddressString($("#id_Apartmentaddress_"+lang).val());
- }
- else if ($("input[name=\'Apartment[address_"+lang+"]\']").val()) {
- address += addAddressString($("input[name=\'Apartment[address_"+lang+"]\']").val());
- }
- $("#address_for_map").val(address);
- // place code to end of queue
- if(useGoogleMap){
- setTimeout(function(){
- var tmpGmapCenter = mapGMap.getCenter();
- google.maps.event.trigger($("#googleMap")[0], "resize");
- mapGMap.setCenter(tmpGmapCenter);
- }, 0);
- }
- if(useYandexMap){
- setTimeout(function(){
- ymaps.ready(function () {
- globalYMap.container.fitToViewport();
- globalYMap.setCenter(globalYMap.getCenter());
- });
- }, 0);
- }
- if(useOSMap){
- setTimeout(function(){
- L.Util.requestAnimFrame(mapOSMap.invalidateSize,mapOSMap,!1,mapOSMap._container);
- }, 0);
- }
- }
- function findByAddress(){
- var address = $("#address_for_map").val();
- if(!address){
- error("' . tc('Please enter address') . '");
- return false;
- }
- $.ajax({
- url: "' . Yii::app()->createUrl('/apartments/main/getGeo', array('id' => $model->id)) . '",
- data: { address: address },
- method: "get",
- dataType: "json",
- success: function(data) {
- if(data.status == "ok"){
- var newAddressLat = data.lat;
- var newAddressLng = data.lng;
- if(useGoogleMap && typeof markersGMap[' . $model->id . '] !== "undefined" && typeof mapGMap !== "undefined"){
- var latLng = new google.maps.LatLng(newAddressLat, newAddressLng);
- markersGMap[' . $model->id . '].setPosition(latLng);
- mapGMap.setCenter(latLng);
- }
- if(useYandexMap && typeof placemark !== "undefined" && typeof globalYMap !== "undefined"){
- placemark.geometry.setCoordinates([newAddressLat, newAddressLng]);
- globalYMap.setCenter([newAddressLat, newAddressLng]);
- }
- if(useOSMap && typeof markersOSMap[' . $model->id . '] !== "undefined" && typeof mapOSMap !== "undefined"){
- var newLatLng = new L.LatLng(newAddressLat, newAddressLng);
- markersOSMap[' . $model->id . '].setLatLng(newLatLng);
- mapOSMap.setView(newLatLng);
- }
- message(data.msg);
- } else {
- error(data.msg);
- }
- }
- });
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement