Yandex Maps Kullanarak Koordinat Alıyoruz

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <script src="https://api-maps.yandex.ru/2.1/?lang=tr_TR&amp;apikey=<your API-key>" type="text/javascript"></script>

Api key olmadan da çalışıyor.

	<script>
	ymaps.ready(init);

function init() {
    var myPlacemark,
        myMap = new ymaps.Map('map', {
            center: [38.41880681091499,27.128671003178752],
            zoom: 14
        }, {
            searchControlProvider: 'yandex#search'
        });

        var coords = [38.41880681091499,27.128671003178752];

        // Moving the placemark if it was already created
        if (myPlacemark) {
            myPlacemark.geometry.setCoordinates(coords);
        }
        // Otherwise, creating it.
        else {
            myPlacemark = createPlacemark(coords);
            myMap.geoObjects.add(myPlacemark);
            // Listening for the dragging end event on the placemark.
            myPlacemark.events.add('dragend', function () {
         //      balloonContent: myPlacemark.geometry.getCoordinates();
			   document.getElementById("kullanici_harita").value = myPlacemark.geometry.getCoordinates();
            });
        }

 //   });

    // Creating a placemark
    function createPlacemark(coords) {
        return new ymaps.Placemark(coords, {
            iconCaption: ''
        }, {
            preset: 'islands#violetDotIconWithCaption',
            draggable: true
        });
    }
}
	
	</script>
</head>
<body>
<p class="header">
<input type="text" name="kullanici_harita" id="kullanici_harita" placeholder="99.999999,99.999999" class="validate[required] form-control" value="">
</p>
<div id="map"></div>
</body>
</html>

 


1 Yorum

  • Yorumlayan / 3 ay önce

    Yorumunuz Onaylandıktan Sonra Yayınlanacaktır.