Unload labels from MySql and add to the map via html form


There is a service station database and an html form, into which the user enters the brand and the service stations working with this brand of cars must be unloaded. I manage to generate json and unload it if I enter the SQL query myself, that is, it is static, but it is necessary that the data is sent from the html form and the found ones are displayed.

Json formation file:

$result = mysql_query("SELECT * FROM ymapapiv2_markers WHERE id = '4'");
while ($mar = mysql_fetch_array($result)){
$json =  array(icontext=>$mar['iconText'], hinttext=>$mar['hintText'], balloontext=>$mar['balloonText'], styleplacemark=>$mar['stylePlacemark'], lat=>$mar['lat'], lon=>$mar['lon']);
$markers[] = $json;
$points = array(markers=>$markers);
echo json_encode($points);

form itself:

<form name="" action="vivodpointsmap.php" method="get">
    <div class="form-grp">
    <input class="select-menu" name="mark" type="text">
    <input class="select-menu" type="submit" value="search" name="search" id="submit">

I understand why they are not displayed, since there is no map output in the form handler, but if I add something there, then it does not work.

unloading the card:


        //Определение начальных параметров карты
        function init () {
            var myMap = new ymaps.Map("map", {
                    center: [55.035130661714284, 82.89889020518926], 
                    zoom: 10
                }, {
                    balloonMaxWidth: 600

            //Добавляем элементы управления 

            //Запрос данных и вывод маркеров на карту
                for (i = 0; i < json.markers.length; i++) {

                    var myPlacemark = new ymaps.Placemark([json.markers[i].lat,json.markers[i].lon], {
                    // Свойства
                    iconContent: json.markers[i].icontext, 
                    hintContent: json.markers[i].hinttext,
                    balloonContentBody: json.markers[i].balloontext                   
                    }, {
                    // Опции
                    preset: json.markers[i].styleplacemark                  

                // Добавляем метку на карту




I would venture to suggest that you confused Lat and Lng ( Lon ). In Yandex maps, in contrast to Google maps, latitude comes first, then longitude.

Scroll to Top