B
B
BlahBlag012014-10-10 14:09:29
JavaScript
BlahBlag01, 2014-10-10 14:09:29

How to redefine the coordinates and label after entering the address in Yandex maps?

I enter the address into the input-text, and it is necessary that after entering a new address with a label on the map. How can this be implemented? I more or less know Jaquery, but I rummaged through the Yandex api and didn’t manage to do anything.

<script type="text/javascript">

    $(function(){

      	ymaps.ready(init);
        var myMap,
            myPlacemark,
            city = "Москва",
            address = "NULL",
            myGeocoder = false;

        $("input[name=city_id]").on("change", function(){
        	city = $("input[name=city_id]").text();
        });


        function init(){
        	 $("input[name=address]").on("keypress", function(){
        		address = $("input[name=address]").val();
        	});
        	myGeocoder = ymaps.geocode("Россия"+city+","+address);
            myGeocoder.then(function(res){
            	getGeo = res.geoObjects.get(0).geometry.getCoordinates();
              myMap = new ymaps.Map ("map", {
            	    center: getGeo,
            	    zoom: 15,
            	    controls: ["zoomControl", "fullscreenControl"]
            	});

            	myPlacemark = new ymaps.Placemark(getGeo,{}, {});
          	
            	myMap.geoObjects.add(myPlacemark);
            });

        }

      });


lol I have nothing to do with other fresh questions on Yandex maps)))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Entelis, 2014-10-10
@DmitriyEntelis

I didn't quite understand the question.
You can enable the standard searchControl https://api.yandex.ru/maps/jsbox/2.1/customSet_controls
You can write your own search https://api.yandex.ru/maps/jsbox/2.1/direct_geocode
What is the question then? What do you want to do?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question