/
var
/
www
/
doncode.com.ua
/
www
/
views
/
user
/
js
/
/var/www/doncode.com.ua/www/views/user/js
mkdir
upload
Name
Size
Mode
Actions
forms/
-
0755
rm
map.doncode.js
9304
0644
edit
dl
rm
map.mqa.js
1440
0644
edit
dl
rm
map.yandex.js
6659
0644
edit
dl
rm
Edit:
/var/www/doncode.com.ua/www/views/user/js/map.doncode.js
(9304B)
//var map; var start; var finish; var route; var last_adreses = new Array(); var myObjectManager; function init_map () { /* var map = L.map('map', { center: [window.city_la, window.city_lo], zoom: window.zoom }); */ // carsCollection = new ymaps.GeoObjectCollection(null, { // preset: 'islands#blueIcon' // }); setup_buttons(); start = null; finish = null; route = null; // addEvents(); } function setup_buttons() { $('#button_taxi').html('<img src="/public/img/widget/Main view/Taxi/taxi-red.imageset/taxi-red.png">'); $('#button_adresses').html('<img src="/public/img/widget/Main view/SearchAdress/search-red-checked.imageset/search-red-checked.png">'); $('#button_comment').html('<img src="/public/img/widget/Main view/Comment/com-white.imageset/com-white.png">'); $('#button_time').html('<img src="/public/img/widget/Main view/Order date/clock-white.imageset/clock-white.png">'); } function addAdres(la,lo){ var plan = window.lrm.getPlan();//N48.4747, E39.2487 console.log('addAdres('+la+','+lo+') '+count_adres); plan.spliceWaypoints(count_adres, 1, L.latLng(la,lo)); if (count_adres==0) { window.laA = la; window.loA = lo; window.strA = la+','+lo; $('#button_taxi').html('<img src="/public/img/widget/Main view/Taxi/taxi-yellow.imageset/taxi-yellow.png">'); $('#button_taxi').attr('class',''); $('#adres_A').html('<input type="text" style="width:300px;border: 2px solid;border-radius: 25px;" class="form-control" placeholder="Куда подать машину?">'); $('#adres_A').attr('class',''); $('#button_adresses').html('<img src="/public/img/widget/Main view/SearchAdress/search-yellow-checked.imageset/search-yellow-checked.png">'); $('#button_adresses').attr('class',''); $('#button_comment').attr('class',''); $('#button_time').attr('class',''); }else{ window.laB = la; window.loB = lo; window.strB = la+','+lo; $('#button_taxi').html('<img src="/public/img/widget/Main view/Taxi/taxi-green.imageset/taxi-green.png">'); $('#button_taxi').attr('class',''); $('#button_adresses').html('<img src="/public/img/widget/Main view/SearchAdress/search-green-checked.imageset/search-green-checked.png">'); $('#button_adresses').attr('class',''); } count_adres++; } function clearRoute(){ console.log('clearRoute'); var plan = window.lrm.getPlan(); var x; for(x=0;x<count_adres;x++){ plan.spliceWaypoints(x, 1, null); } count_adres = 0; } //console.log(window); //addAdres(48.4747,38.2487); //addAdres(48.7747,38.8487); //console.log(window.lrm); /// --------------- OLD function addEvents(){ // Будем отслеживать изменение уровня масштабирования карты map.events.add('boundschange', function (event) { if (event.get('newZoom') != event.get('oldZoom')) { if (typeof(callback_zoom) == "function") { console.log('RUN CALLBACK: callback_zoom'); callback_zoom(event.get('newZoom')); } } if (event.get('newCenter') != event.get('oldCenter')) { if (typeof(callback_center) == "function") { console.log('RUN CALLBACK: callback_center'); callback_center(event.get('newCenter')); } } //console.log(event); }); } function geo_query(query,callback){ var url = "http://geocode-maps.yandex.ru/1.x/?format=json&results=1&geocode="+query; $.get(url,function(json){ var ret = json.response.GeoObjectCollection.featureMember; var result = ret[0].GeoObject.Point.pos.split(' '); var point = new Array(result[1],result[0]); if (callback) { console.log('RUN CALLBACK: callback_geo_query'); callback_geo_query(point); } },'json'); } function map_point(coords,name,baloon){ window[name] = new ymaps.Placemark(coords, { iconContent: baloon }, { preset: 'islands#darkblueStretchyIcon',draggable: false }); map.geoObjects.add(window[name]); } function del_map_point(name){ map.geoObjects.remove(window[name]); } function car_point(coords,baloon){ //carsCollection.add(collection); map.geoObjects.remove(carsCollection); carsCollection.add(new ymaps.Placemark(coords, { iconContent: baloon }, { preset: 'islands#dotCircleIcon',draggable: false })); map.geoObjects.add(carsCollection); } function del_car_points(){ map.geoObjects.remove(carsCollection); carsCollection.removeAll(); } function setA(address){ // alert(address); if (typeof(map) != "object") { return; } last_adreses = new Array(address); map.geoObjects.removeAll(); var myGeocoder = ymaps.geocode(address); myGeocoder.then( function (res) { start = new ymaps.Placemark(res.geoObjects.get(0).geometry.getCoordinates(), { iconContent: 'А' }, { preset: 'islands#violetStretchyIcon',draggable: false }); map.geoObjects.add(start); if (typeof(callback_start_point) == "function") { console.log('RUN CALLBACK: callback_start_point setA'); callback_start_point(res.geoObjects.get(0).geometry.getCoordinates()); } } ); } function getRoute(adreses){ if (typeof(map) != "object") { return; } if(arraysEqual(last_adreses,adreses)){ console.log('adreses equal'); return; } last_adreses = adreses; // console.log('START getRoute'); // console.log(adreses); // Объявляем набор опорных точек, и массив индексов транзитных точек. var referencePoints = adreses; map.geoObjects.removeAll(); // Создаем мультимаршрут и настраиваем его внешний вид с помощью опций. var multiRoute = new ymaps.multiRouter.MultiRoute({ referencePoints: referencePoints, params: { results: 2 } }, { // Внешний вид путевых точек. wayPointStartIconColor: "#0000FF", // Задаем собственную картинку для последней путевой точки. //wayPointFinishIconLayout: "default#image", //wayPointFinishIconImageHref: "images/sokolniki.png", //wayPointFinishIconImageSize: [30, 30], //wayPointFinishIconImageOffset: [-15, -15], // Внешний вид транзитных точек. viaPointIconRadius: 7, viaPointIconFillColor: "#000088", viaPointActiveIconFillColor: "#E63E92", // Транзитные точки можно перетаскивать, при этом // маршрут будет перестраиваться. viaPointDraggable: false, // Внешний вид точечных маркеров под путевыми точками. pinIconFillColor: "#000088", pinActiveIconFillColor: "#E63E92", // Внешний вид линии маршрута. routeStrokeWidth: 2, routeStrokeColor: "#000088", routeActiveStrokeWidth: 6, routeActiveStrokeColor: "#0000FF", // Автоматически устанавливать границы карты так, чтобы маршрут был виден целиком. boundsAutoApply: true }); multiRoute.model.events.add("requestsuccess", function (event) { if (typeof(callback_distance) == "function") { console.log('RUN CALLBACK: callback_distance'); callback_distance((multiRoute.getRoutes().get(0).properties.get("distance").value / 1000).toFixed(2)); } if (typeof(callback_start_point) == "function") { console.log('RUN CALLBACK: callback_start_point'); callback_start_point(multiRoute.getWayPoints().get(0).model.geometry.getCoordinates()); } }); //console.log(multiRoute.getRoutes().get(0).properties.get("distance").value); //var distance = Math.round(multiRoute.getLength() / 1000); //alert(distance); /* ymaps.modules.require([ 'MultiRouteColorizer' ], function (MultiRouteColorizer) { // Создаем объект, раскрашивающий линии сегментов маршрута. new MultiRouteColorizer(multiRoute); }); */ // Добавляем мультимаршрут на карту. map.geoObjects.add(multiRoute); // console.log('END getRoute'); } // Doncode Utils function arraysEqual(a, b) { if (a === b) return true; if (a == null || b == null) return false; if (a.length != b.length) return false; for (var i = 0; i < a.length; ++i) { if (a[i] !== b[i]) return false; } return true; }
Save
cmd:
run