7. JavaScript API
Quick start
Add API script
<script src=“http://api-maps.yandex.ru/{version}/key={API-
key}”/>
Add placeholder for the map
<div id=“mapID” style=“width:200px; height:200px;”>
Initialize the map
var map = new YMaps.Map(YMaps.jQuery(“#mapID”));
map.setCenter(
new YMaps.GeoPoint(39.68,47.25), // set center
10, // set zoom
YMaps.MapType.MAP // map type
);
Example: http://api.yandex.ru/maps/jsapi/examples/mapbasics.html
8. JavaScript API
User interac8on
– Built-in functions
(dragging map, zooming by double-click, zooming by mouse wheel, right-click area selection,
hot keys, ruler)
– Standard control elements
(search bar, toolbar, map type selector, zoom control, preview map window)
– YMaps.IControl – to create your custom controls
Example: http://api.yandex.ru/maps/jsapi/examples/mapcontrolsadding.html
9. JavaScript API
Objects on the map
Placemarks
http://api.yandex.ru/maps/jsapi/examples/coordinatesmarkers.html
Polylines
http://api.yandex.ru/maps/jsapi/examples/mappolylinesediting.html
Polygons
http://api.yandex.ru/maps/jsapi/examples/mapstylepolygon.html
You can customize object styles: placemark icon and shadow image, color and
thickness of lines and polygon border, polygon fill color
YMaps.IOverlay – to create your custom objects
10. • Здесь нужна картинка кальки
Static API
Embedded map image on your page
11. Stati
c
API
Map parameters
Size
Zoom
View area
Map objects: placemarks, polylines, polygons
Example: http://static-maps.yandex.ru/1.x/?l=map&pl=c:8822DDC0,w:
5,37.656577,55.741176,37.656748,55.741419,37.655131,55.741814,37.658257,55.74252
4,37.659811,55.743066,37.659667,55.743233,37.659551,55.743603,37.659775,55.74392
8,37.662398,55.745281&pt=37.656577,55.741176,pmrdm1~37.662398,55.745281,pmblm
2~37.667788,55.732017,pmwtl3&key=ABYQNEkBAAAAgM-
ZTwMAK_IKAfJkc-72mWoAq8el6lFmTeEAAAAAAAAAAAChHQgTyECkUqGduyet_fMaeQ
6ckw==
More StaticAPI examples: http://api.yandex.ru/maps/staticapi/examples/
13. Geocoder
– reverse-geocoding
– coordinates into address
– spell-checking
– viewport biasing
– language selection
– paging
14. Geocoder
Geocoder interfaces
JavaScript geocoder:
– YMaps.Geocoder object in JavaScript API
– Search bar control (YMaps.SearchControl)
XML-based HTTP-service
http://geocode-maps.yandex.ru/1.x/
16. Router
YMaps.Router object in JS API
– returns
– route length and time
– detailed driving directions
– route geometry (polyline)
– now available in Moscow and Ukraine (in «beta»)
17. Thank you
Developers forum – http://clubs.ya.ru/mapsapi/
Support – support@api-maps.yandex.ru
Documentation – http://api.yandex.ru/maps/doc/
Website – http://api.yandex.ru/maps/
Andrey Karmatsky
karma@yandex‐team.ru