Архив рубрики: api

yandex maps

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 <title>Быстрый старт. Размещение интерактивной карты на странице</title>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <script src="https://api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script>
 <script src="http://maps.googleapis.com/maps/api/js?v=3" type="text/javascript"></script>
 <script type="text/javascript">
 // var map = new google.maps.Map(document.getElementById('map'), {
 // zoom: 12,
 // center: new google.maps.LatLng(0, 0)
 // });
 ymaps.ready(function () {
 ymaps.geolocation.get({
 provider: 'yandex'
 }).then(function (result) {
 var find_result = result.geoObjects.get(0)
 var coords = find_result.geometry.getCoordinates();
 // map.setCenter(new google.maps.LatLng(coords[0], coords[1]));
 ya_map = new ymaps.Map ("ya_map", {
 center: [coords[0], coords[1]],
 zoom: 12
 });
 console.log(coords);
 console.log(find_result.properties.get('metaDataProperty.GeocoderMetaData.AddressDetails.Country.CountryName'));
 console.log(find_result.properties.get('metaDataProperty.GeocoderMetaData.AddressDetails.Country.CountryNameCode'));
 console.log(find_result.properties.get('metaDataProperty.GeocoderMetaData.AddressDetails.Country.AddressLine'));
 console.log(find_result.properties.get('metaDataProperty.GeocoderMetaData.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName'));
 console.log(find_result.properties.get('metaDataProperty.GeocoderMetaData.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName'));
 console.log(find_result.properties.get('metaDataProperty.GeocoderMetaData.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName'));
 });
 });
 </script>
</head>
<body>
 <!-- <div id="map" style="width: 600px; height: 400px"></div> -->
 <div id="ya_map" style="width: 600px; height: 400px"></div>
</body>
</html>