Warning: Cannot use a scalar value as an array in /home/admin/public_html/forum/include/fm.class.php on line 757

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/include/fm.class.php on line 770

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/topic.php on line 737
Форумы портала PHP.SU :: яндекс карта и форма

 PHP.SU

Программирование на PHP, MySQL и другие веб-технологии
PHP.SU Портал     На главную страницу форума Главная     Помощь Помощь     Поиск Поиск     Поиск Яндекс Поиск Яндекс     Вакансии  Пользователи Пользователи


 Страниц (1): [1]   

> Описание: Как заставить яндекс брать данные из формы
ugg555
Отправлено: 31 Мая, 2014 - 17:47:28
Post Id


Новичок


Покинул форум
Сообщений всего: 16
Дата рег-ции: Сент. 2013  


Помог: 0 раз(а)




Здравствуйте!

Хочу переделать тему ДоскаОбъявлений на wordpress.
В стандарте, когда просматриваешь объявление http://ugg555[dot]ru/?ad_listing=garazh , то справа есть вкладка, в которой есть карта Google (показывает место положение указанные в объявлении : Страна, город, улица, индекс.)

Нашел код отвечающий за эту вкладку:
Контейнер div
Php скрипт извлечения адрес
Ну и сам скрипт.


CODE (htmlphp):
скопировать код в буфер обмена
  1.  
  2. <div id="gmap" class="mapblock">
  3.  
  4.   <?php
  5.    $make_address = get_post_meta($post->ID, 'cp_street', true) . '&nbsp;' . get_post_meta($post->ID, 'cp_city', true) . '&nbsp;' . get_post_meta($post->ID, 'cp_state', true) . '&nbsp;' . get_post_meta($post->ID, 'cp_zipcode', true);
  6.  
  7.    $coordinates = cp_get_geocode( $post->ID );
  8.  ?>
  9.  
  10.   <script type="text/javascript">var address = "<?php echo esc_js($make_address); ?>";</script>
  11.  
  12.   <?php cp_google_maps_js( $coordinates ); ?>
  13.  
  14.   <!-- google map div -->
  15.   <div id="map"></div>
  16.  
  17. </div>
  18.  
  19.  
  20. <?php
  21. // Google map on single page
  22. function cp_google_maps_js($coordinates) {
  23. ?>
  24. <script type="text/javascript">
  25. //<![CDATA[
  26.    jQuery(document).ready(function($) {
  27.      var clicked = false;
  28.  
  29.      if( $('#priceblock1').is(':visible') ) {
  30.        map_init();
  31.      } else {
  32.        jQuery('a[href=#priceblock1]').click( function() {
  33.          if( !clicked ) {
  34.            map_init();
  35.            clicked = true;
  36.          }
  37.        });
  38.      }
  39.  
  40.    });
  41.  
  42.    <?php
  43.    if(!empty($coordinates) && is_array($coordinates)) {
  44.      echo 'var SavedLatLng = new google.maps.LatLng('.$coordinates['lat'].', '.$coordinates['lng'].');';
  45.      $location_by = "'latLng':SavedLatLng";
  46.      $marker_position = "SavedLatLng";
  47.    } else {
  48.      $location_by = "'address': address";
  49.      $marker_position = "results[0].geometry.location";
  50.    }
  51.    ?>
  52.  
  53.    //var directionDisplay;
  54.    //var directionsService = new google.maps.DirectionsService();
  55.    var map = null;
  56.    var geocoder = null;
  57.    var fromAdd;
  58.    var toAdd;
  59.    var redFlag = "<?php echo esc_js( appthemes_locate_template_uri('images/red-flag.png') ); ?>";
  60.    var shadow = "<?php echo esc_js( appthemes_locate_template_uri('images/red-flag-shadow.png') ); ?>";
  61.    var noLuck = "<?php echo esc_js( appthemes_locate_template_uri('images/gmaps-no-result.gif') ); ?>";
  62.    var adTitle = "<?php echo esc_js( get_the_title() ); ?>";
  63.    var contentString = '<div id="mcwrap"><span>' + adTitle + '</span><br />' + address + '</div>';
  64.  
  65.    function map_init() {
  66.      jQuery(document).ready(function($) {
  67.        $('#map').hide();
  68.        load();
  69.        $('#map').fadeIn(1000);
  70.        codeAddress();
  71.      });
  72.    }
  73.  
  74.  
  75.    function load() {
  76.        geocoder = new google.maps.Geocoder();
  77.        //directionsDisplay = new google.maps.DirectionsRenderer();
  78.        var newyork = new google.maps.LatLng(40.69847032728747, -73.9514422416687);
  79.        var myOptions = {
  80.            zoom: 14,
  81.            center: newyork,
  82.            mapTypeId: google.maps.MapTypeId.ROADMAP,
  83.            mapTypeControlOptions: {
  84.                style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
  85.            }
  86.        }
  87.        map = new google.maps.Map(document.getElementById('map'), myOptions);
  88.        //directionsDisplay.setMap(map);
  89.    }
  90.  
  91.  
  92.    function codeAddress() {
  93.        geocoder.geocode( { <?php echo $location_by; ?> }, function(results, status) {
  94.          if (status == google.maps.GeocoderStatus.OK) {
  95.            map.setCenter();
  96.  
  97.            var marker = new google.maps.Marker({
  98.                map: map,
  99.                icon: redFlag,
  100.                shadow: shadow,
  101.                //title: title,
  102.                animation: google.maps.Animation.DROP,
  103.                position: <?php echo $marker_position; ?>
  104.            });
  105.  
  106.            var infowindow = new google.maps.InfoWindow({
  107.                maxWidth: 270,
  108.                content: contentString,
  109.                disableAutoPan: false
  110.            });
  111.  
  112.            infowindow.open(map, marker);
  113.  
  114.            google.maps.event.addListener(marker, 'click', function() {
  115.              infowindow.open(map,marker);
  116.            });
  117.  
  118.          } else {
  119.            (function($) {
  120.                $('#map').append('<div style="height:400px;background: url(' + noLuck + ') no-repeat center center;"><p style="padding:50px 0;text-align:center;"><?php echo esc_js( __( 'Sorry, the address could not be found.', APP_TD ) ); ?></p></div>');
  121.                return false;
  122.            })(jQuery);
  123.          }
  124.        });
  125.      }
  126.  
  127.    function showAddress(fromAddress, toAddress) {
  128.        calcRoute();
  129.        calcRoute1();
  130.    }
  131.    function calcRoute() {
  132.        var start = document.getElementById("fromAdd").value;
  133.        var end = document.getElementById("toAdd").value;
  134.        var request = {
  135.            origin: start,
  136.            destination: end,
  137.            travelMode: google.maps.DirectionsTravelMode.DRIVING
  138.        };
  139.        directionsService.route(request, function(response, status) {
  140.            if (status == google.maps.DirectionsStatus.OK) {
  141.                directionsDisplay.setDirections(response);
  142.            }
  143.        });
  144.    }
  145. //]]>
  146. </script>
  147.  
  148.  
  149. <?php
  150.  
  151. }
  152.  
  153. ?>
  154.  
  155.  



Порылся я у яндекса, так не понял как передать скрипту Яндекса адрес.

Может кто встречался с созданием Яндекс карты на своем сайте.... подскажите

Вот примерный набросок кода, что исправить (да и что то я запутался... как форму создать с выпадающим списком, где было бы город, страна, и улица - )

CODE (htmlphp):
скопировать код в буфер обмена
  1.  
  2. <!DOCTYPE html>
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5.     <title>Быстрый старт. Размещение интерактивной карты на странице</title>
  6.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7.     <script src="http://api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script>
  8.     <script type="text/javascript">
  9.        ymaps.ready(init);
  10.        var myMap,
  11.            myPlacemark;
  12.  
  13.        function init(){
  14.            myMap = new ymaps.Map("map", {
  15.                center: [55.76, 37.64],
  16.                zoom: 7
  17.            });
  18.            
  19.            myPlacemark = new ymaps.Placemark([55.76, 37.64], {
  20.                hintContent: 'Москва!',
  21.                balloonContent: 'Столица России'
  22.            });
  23.            
  24.            myMap.geoObjects.add(myPlacemark);
  25.        }
  26.    </script>
  27. </head>
  28.  
  29. <body>
  30.  
  31. <br>
  32. <form name="ab" action="" method="post">
  33.  
  34. <p><b>Город: </b></p> <input name="A" type="text"> <br>
  35. <input name="B" type="text">
  36. <input type="submit" value=" Найти ">
  37. <br>
  38.  
  39. <select>
  40.   <option>Пункт 1</option>
  41.   <option>Пункт 2</option>
  42. </select>
  43.  
  44.  
  45. </form>
  46.  
  47. <br>
  48. <br>
  49.  
  50.  
  51.     <div id="map" style="width: 324px; height: 400px"></div>
  52.  
  53.  



Как заставить яндекс брать данные из формы ?

Спасибо!
 
 Top
Страниц (1): [1]
Сейчас эту тему просматривают: 0 (гостей: 0, зарегистрированных: 0)
« Вопросы новичков »


Все гости форума могут просматривать этот раздел.
Только зарегистрированные пользователи могут создавать новые темы в этом разделе.
Только зарегистрированные пользователи могут отвечать на сообщения в этом разделе.
 



Powered by PHP  Powered By MySQL  Powered by Nginx  Valid CSS  RSS

 
Powered by ExBB FM 1.0 RC1. InvisionExBB