$(document).ready(function () {
$(document).on('click', '.to_favorites', function() { // работа с закладками
var name = 'FOREVER';
var cookie_zac = BX.getCookie(name);
if($(this).hasClass('active')){
$(this).removeClass('active');
var znach = $(this).attr('data-cookieid')+"|";
var new_zac = cookie_zac.replace(znach,"");
$('.goods_icon-counter').html(
+($('.goods_icon-counter').html())-1
);
if($(this).data('remove')) {
$(this).closest('.favour-item').remove();
}
BX.setCookie(name, new_zac, {expires: 86400,path:'/'});
}else{
$(this).addClass('active');
if(cookie_zac == undefined){
var znach = "|"+$(this).attr('data-cookieid')+"|";
BX.setCookie(name, znach, {expires: 86400,path:'/'});
}else{
var znach = cookie_zac+$(this).attr('data-cookieid')+"|";
BX.setCookie(name, znach, {expires: 86400,path:'/'});
}
}
activZacladca();
return false;
});
activZacladca();
});
function activZacladca() { // проверка есть ли товар в закладках
var name = 'FOREVER';
var cookie_zac = BX.getCookie(name);
if (cookie_zac !== undefined) {
var mas = cookie_zac.split('|');
mas.forEach(function (item, i, mas) {
if (item != "" ) {
$('#favour_in .goods_icon-counter').html(
i
);
$(".to_favorites[data-cookieid='"+item+"']").addClass('active');
}
});
$('#favour_in .goods_icon-counter').html(mas.length-1);
}
}
<?
$mass2 = array("type" =>"Feature","id" => "",
"geometry" => array("type" => "Polygon","coordinates" => 1), //сюда надо вставаить координаты
"properties" => array(
"description" => "",
"fill" => "#ff931e",
"fill-opacity"=>0.3,
"stroke"=>"#e6761b",
"stroke-width"=>"2",
"stroke-opacity"=>0.9
),
);
$mass3 = array(
'type' => "FeatureCollection",
'features'=> "",
);
$featuresMass=[];
\Bitrix\Main\Loader::includeModule('iblock');
$arSelect = Array("ID", "IBLOCK_ID", "NAME", "DATE_ACTIVE_FROM",);
$arFilter = Array("IBLOCK_ID"=>11, "ACTIVE_DATE"=>"Y", "ACTIVE"=>"Y");
$res = CIBlockElement::GetList(Array(), $arFilter, false, Array("nPageSize"=>10), $arSelect);
//$mass=[];
$map = 0;
$map2 = 0;
$map3 = 0;
while($ob = $res->GetNextElement()){
$arFields = $ob->GetFields();
$arProps = $ob->GetProperties();
$str = $arProps['COORDINATES']['VALUE']; //координаты
$array = array(
'coordinates' => json_decode($str)
);
$json_ne = json_encode($array, true);
//echo $json_ne;
$mass2['id']=$arFields["ID"];
$mass2['properties']['description']=$arFields["NAME"];
$mass2['geometry']['coordinates']=$json_ne;
echo '<pre>';
//print_r($mass2);
//print_r($arProps);
echo '</pre>';
array_push($featuresMass,$mass2);
}
$data_for_write ='';
$mass3['features'] = $featuresMass;
$json = json_encode($mass3);
?>
[[[[-3546.84,2290.81],[-2390.84,2290.81],[-2394.84,1790.81],[-3542.84,1790.81],[-3546.84,2290.81]]]]
<?php
$str = "[[[-3546.84, 2290.81], [-2390.84, 2290.81], [-2394.84, 1790.81], [-3542.84, 1790.81], [-3546.84, 2290.81]]]";
$array = array(
'coordinates' => $str
);
$json = json_encode($array, true);
echo $json;
$array_de = json_decode($json);
echo $array_de;
?>
{"coordinates":"[[[-354684, 229081], [-239084, 229081], [-239484, 179081], [-354284, 179081], [-354684, 229081]]]"}<br />
<b>Fatal error</b>: Uncaught Error: Object of class stdClass could not be converted to string in [...][...]:11
Stack trace:
#0 {main}
thrown in <b>[...][...]</b> on line <b>11</b><br />
$generate_xml = $_GET['generate_xml']; //просто для проверки
$json_object = $_GET['json_object'];
if($_GET['generate_xml']) {
$dir = $_SERVER['DOCUMENT_ROOT'].'/scheme/geoObjects2.geojson';
$write = file_put_contents( $dir , $json_object );
if($write) { $info = "Запись прошла";} else {$info = "Запись не прошла";}
echo $info;
}