Code Monkey home page Code Monkey logo

ymaps's Introduction

ymaps

ymaps related things

Examples: http://zxqfox.github.io/ymaps/examples/

Published under MIT License

Car

Simple javascript object for animating some route on yandex.maps (http://api.yandex.ru/maps/doc/jsapi/2.x/ref/)

Examples: http://zxqfox.github.io/ymaps/examples/car/

Simple example usage

$.getScript('car.js', function () {
  car = new Car();
  ymaps.route([
    'Москва, метро Смоленская', // from Smolenskaya subway station
    [55.740532, 37.625693] // to Tretyakovkaya subway station
  ]).then(function (route) {
    car.moveTo(route.getWayPoints().getPaths().get(0).getSegments());
  });
});

More complex

$.getScript('car.js', function () {
  car = new Car({
    // geoObject options
    iconLayout: ymaps.templateLayoutFactory.createClass(
      '<div class="b-car b-car_blue b-car-direction-$[properties.direction]"></div>'
    )
  });
  ymaps.route([
    'Москва, метро Смоленская', // from Smolenskaya subway station
    {
      type: 'viaPoint', // via Tretyakovskaya gallery
      point: 'Россия, Москва, Лаврушинский переулок, 10'
    },
    [55.740532, 37.625693] // to Tretyakovkaya subway station
  ], {
    // Router options
    mapStateAutoApply: true
  }).then(function (route) {
    // Setting custom label for routing points
    var points = route.getWayPoints();
    points.get(0).properties.set("iconContent", "A");
    points.get(1).properties.set("iconContent", "B");

    // Add route and car to map
    map.geoObjects.add(route);
    map.geoObjects.add(car);

    // Send car with specific move speed and directions count
    car.moveTo(route.getPaths().get(0).getSegments(), {
      speed: 10,
      directions: 8
    }, function (geoObject, coords, direction) { // тик движения
      // перемещаем машинку
      geoObject.geometry.setCoordinates(coords);
      // ставим машинке правильное направление - в данном случае меняем ей текст
      geoObject.properties.set('direction', direction.t);

    }, function (geoObject) { // приехали
      geoObject.properties.set('balloonContent', "Приехали!");
      geoObject.balloon.open();
    });
  });
});

ymaps's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ymaps's Issues

Движение по пешеходному маршруту

Приветствую, наткнулся на скрипт движения машинки по маршруту. Есть возможность сделать тоже самое только чтобы маршрут строился пешеходный а не для авто? Так как при указании координат для въезда в ТРЦ машинка петляет по неведомым маршрутам, а переключить на пешеходный не получается.

Анимация метки (pinMap)

Добрый день, посмотрел оригинальные примеры реализованные с АПИ Яндекс карты 2,0. Есть ли возможность сделать анимацию метки?
Сделать кастомную метку и применить к метке анимацию, например (bounce). Спасибо )

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.