User Tools

Site Tools


Yandex geocoder sample

Form for application RPC is another https://geocode-maps.yandex.ru/1.x/?geocode=<object>&format=json

sample.html
<!doctype html>
<!-- $Id: index.html,v 1.1 2017/10/27 10:20:04 root Exp root $ -->
<!-- $Author: Oleg Borodin <borodin@unix7.org> $ -->
 
<html class="no-js" lang="en" dir="ltr">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="x-ua-compatible" content="ie=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>DE2</title>
 
        <link rel="stylesheet" href="/icons/foundation-icons.css">
        <link rel="stylesheet" href="/css/foundation-float.min.css">
        <link rel="stylesheet" href="/css/app.css">
 
        <script src="/js/jquery.min.js"></script>
        <script src="/js/foundation.min.js"></script>
 
        <script src="https://api-maps.yandex.ru/2.1/?load=package.standard&lang=ru-RU&apikey=xxxxxxxxx-3c72-4dc3-af7c-6944aeafc3f2" type="text/javascri
pt"></script>
 
    </head>
 
    <body>
 
        <div class="title-bar">
            <button class="menu-icon" type="button" data-toggle="topbar-menu"></button>
            <ul class="dropdown menu" data-dropdown-menu>
                <li class="menu-text">De2.Unix7.org</li>
            </ul>
        </div>
 
        <div class="row">&nbsp;</div>
        <div class="row">
<!- end of head template ->
 
<div id="map" style="width:700px; height:500px"></div>
 
<script>
 
ymaps.ready(init);
function init() {
 
    var myMap = new ymaps.Map("map", {
        center: [56, 37],
        zoom: 3,
    });
 
    var address = 'Калининград, Ленинский проспект, 1';
 
    var geocoder = ymaps.geocode(address);
 
    geocoder.then(
        function (res) {
 
            var coordinates = res.geoObjects.get(0).geometry.getCoordinates();
 
            var placemark = new ymaps.Placemark(
                coordinates, {
                    'hintContent': address,
                    'balloonContent': 'Время работы: Пн-Пт, с 9 до 20'
                }, {
                    'preset': 'islands#redDotIcon'
                }
            );
 
            myMap.geoObjects.add(placemark);
 
            myMap.setBounds(myMap.geoObjects.getBounds(), {checkZoomRange:true}).then(function(){
               if(myMap.getZoom() > 15) myMap.setZoom(15);
            });
        }
    );
}
</script>
 
<!- begin of tail template ->
            </div>
        </div>
        <hr/>
        <div class="row">
            <p class="text-center">
 
            </p>
        </div>
        <script src="/js/app.js"></script>
    </body>
</html>
<!- end of tail template ->
<!- EOF ->

First PagePrevious PageBack to overview