Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I want to find a route between two points on Istanbul. For this, I try to run a simple code that taken from this guide . But this code doesn't work. I can't view a route path or map. My code is here.

<title>Quick start. Publishing an interactive map on a page</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://api-maps.yandex.ru/2.0-stable/?load=package.standard&lang=ru-RU" type="text/javascript"></script>
<script src="http://yandex.st/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
    var ymap;
    ymaps.ready(function(){ 
        ymap = new ymaps.Map ("map", {
            center: [41.01771, 28.968484],
            zoom: 10,
            controls: ['zoomControl', 'typeSelector',
                       'geolocationControl', 'trafficControl',
                       'fullscreenControl'] 
        ymaps.route([
            'Maltepe',
            'Kartal'
        ]).then(function (route){
            ymap.geoObjects.add(route);
            }, function(error){
               alert("Ошибка. " + error.status +
                     ":" + error.message);
</script>

The code in the example is correct. It is the page that needs to be fixed. You must add a properly positioned/sized DIV element to the HTML of your page. The id of this element ("map") is passed as a first argument to the constructor new ymaps.Map.

Here is a minimalistic working HTML and CSS code:

<script src="http://api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script>
<div id="map"></div>
body {
    height: 100%;
#map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;

I created a live example for you, see this fiddle

http/https issue. JSFiddle's "share link" gave me https link while I used http for JS URI. Fixed the link to JSFiddle to properly point to http. Sorry for that. – Baradzed Feb 11, 2015 at 19:18

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.