88 $mapId = (is_array($arUserField) ? $arUserField[
'FIELD_NAME'] :
'_new') .
'_settings';
93 $scale = intval($GLOBALS[$arHtmlControl[
"NAME"]][
"INIT_MAP_SCALE"]);
94 $lat = doubleval($GLOBALS[$arHtmlControl[
"NAME"]][
"INIT_MAP_LAT"]);
95 $lon = doubleval($GLOBALS[$arHtmlControl[
"NAME"]][
"INIT_MAP_LON"]);
97 elseif(is_array($arUserField))
99 $scale = intval($arUserField[
"SETTINGS"][
"INIT_MAP_SCALE"]);
100 $lat = doubleval($arUserField[
"SETTINGS"][
"INIT_MAP_LAT"]);
101 $lon = doubleval($arUserField[
"SETTINGS"][
"INIT_MAP_LON"]);
111 <td valign="top">'.GetMessage(
"USER_TYPE_GEO_INIT_MAP").
':</td>
116 $APPLICATION->IncludeComponent(
'bitrix:map.google.system',
'', array(
118 'INIT_MAP_SCALE' => $scale,
119 'INIT_MAP_LAT' => $lat,
120 'INIT_MAP_LON' => $lon,
124 var mapId =
'<?=$mapId?>';
126 function waitForMap()
128 if(window.GLOBAL_arMapObjects ===
null)
133 if(window.GLOBAL_arMapObjects[mapId] && window.google && window.google.maps && window.google.maps.event)
135 var map = window.GLOBAL_arMapObjects[mapId];
137 var getDataFromMap =
function()
139 BX(
'init_scale').value = map.getZoom();
140 BX(
'init_lat').value = map.getCenter().lat();
141 BX(
'init_lng').value = map.getCenter().lng();
144 map.addListener(
'bounds_changed', getDataFromMap);
150 setTimeout(waitForMap, 300);
157 $result .= ob_get_clean();
165 <td>'.GetMessage(
"USER_TYPE_GEO_INIT_MAP_SCALE").
':</td>
167 <input type="text" name="'.$arHtmlControl[
"NAME"].
'[INIT_MAP_SCALE]" size="5" maxlength="5" readonly="readonly" value="'.$scale.
'" id="init_scale" />
171 <td>'.GetMessage(
"USER_TYPE_GEO_INIT_MAP_LAT").
':</td>
173 <input type="text" name="'.$arHtmlControl[
"NAME"].
'[INIT_MAP_LAT]" size="20" maxlength="50" readonly="readonly" value="'.$lat.
'" id="init_lat" />
177 <td>'.GetMessage(
"USER_TYPE_GEO_INIT_MAP_LON").
':</td>
179 <input type="text" name="'.$arHtmlControl[
"NAME"].
'[INIT_MAP_LON]" size="20" maxlength="50" readonly="readonly" value="'.$lon.
'" id="init_lng" />
198 protected function showAdminEdit($arUserField, $arHtmlControl, $multiple =
false)
204 $value = $arHtmlControl[
'VALUE'];
205 if(!is_array($value))
207 $value = array($value);
210 $pointList = array();
211 foreach($value as $point)
215 $pointList[] = explode(
';', $point);
219 $center = static::getCenter($arUserField, $pointList);
221 $APPLICATION->IncludeComponent(
'bitrix:map.google.edit',
'', array(
222 'MAP_ID' => $arUserField[
'FIELD_NAME'],
223 'MULTIPLE' => $multiple ?
'Y' :
'N',
224 'POINTS' => $pointList,
225 'INIT_MAP_SCALE' => $arUserField[
'SETTINGS'][
'INIT_MAP_SCALE'],
226 'INIT_MAP_LAT' => $center[0],
227 'INIT_MAP_LON' => $center[1],
228 ),
null, array(
'HIDE_ICONS' =>
'Y'));
230 if(!is_array($arHtmlControl[
'VALUE']))
232 $arHtmlControl[
'VALUE'] = array($arHtmlControl[
'VALUE']);
235 <span style=
"display: none;" id=
"<?=$arUserField['FIELD_NAME']?>_valuewrap">
237 foreach($arHtmlControl[
'VALUE'] as $value)
240 <input type=
"hidden" name=
"<?=$arHtmlControl['NAME']?>" value=
"<?=$value?>" />
246 BX.Fileman.Map.instance(
'<?=\CUtil::JSEscape($arUserField['FIELD_NAME
'])?>').addListener(
function(map, points)
250 for(var i = 0; i < points.length; i++)
252 str +=
'<input type="hidden" name="<?=$arHtmlControl['NAME
']?>" value="' + points[i].getPosition().join(
';') +
'" />';
255 BX(
'<?=$arUserField['FIELD_NAME
']?>_valuewrap').innerHTML = str;
261 return ob_get_clean();
264 public static function getPublicEdit($arUserField, $arAdditionalParameters = array())
268 $mapId = $arUserField[
'FIELD_NAME'].
'_edit_'.Random::getString(5);
270 $fieldName = static::getFieldName($arUserField, $arAdditionalParameters);
271 $value = static::getFieldValue($arUserField, $arAdditionalParameters);
273 $pointList = array();
275 foreach($value as $point)
279 $pointList[] = explode(
';', $point);
285 $center = static::getCenter($arUserField, $pointList);
288 $APPLICATION->IncludeComponent(
'bitrix:map.google.edit',
'', array(
290 'MAP_WIDTH' =>
'100%',
291 'MULTIPLE' => $arUserField[
'MULTIPLE'] ==
'Y' ?
'Y' :
'N',
292 'POINTS' => $pointList,
293 'INIT_MAP_SCALE' => $arUserField[
'SETTINGS'][
'INIT_MAP_SCALE'],
294 'INIT_MAP_LAT' => $center[0],
295 'INIT_MAP_LON' => $center[1],
296 ),
null, array(
'HIDE_ICONS' =>
'Y'));
299<span style=
"display: none;" id=
"<?=$arUserField['FIELD_NAME']?>_valuewrap">
300 <input type=
"hidden" name=
"<?=HtmlFilter::encode($fieldName)?>" value=
""/>
302foreach($value as $point)
307 <input type=
"hidden" name=
"<?=HtmlFilter::encode($fieldName)?>" value=
"<?=$point?>"/>
314 BX.Fileman.Map.instance(
'<?=\CUtil::JSEscape($mapId)?>').addListener(
function(map, points)
316 var str =
'<input type="hidden" name="<?=\CUtil::JSEscape(HtmlFilter::encode($fieldName))?>" value=""/>';
318 for(var i = 0; i < points.length; i++)
320 str +=
'<input type="hidden" name="<?=\CUtil::JSEscape(HtmlFilter::encode($fieldName))?>" value="' + points[i].getPosition().join(
';') +
'" />';
323 BX(
'<?=HtmlFilter::encode($arUserField['FIELD_NAME
'])?>_valuewrap').innerHTML = str;
324 var inputList =
BX.Main.UF.Factory.get(
BX.Main.UF.TypeGeo.USER_TYPE_ID).findInput(
BX(
'<?=\CUtil::JSEscape($arUserField['FIELD_NAME
'])?>_valuewrap'),
'<?=\CUtil::JSEscape($fieldName)?>');
326 if(inputList.length > 0)
328 BX.fireEvent(inputList[0],
'change');
333 $html .= ob_get_clean();
338 public static function getPublicView($arUserField, $arAdditionalParameters = array())
342 $mapId = $arUserField[
'FIELD_NAME'].
'_view_'.Random::getString(5);
344 $value = static::normalizeFieldValue($arUserField[
"VALUE"]);
346 $placemarkList = array();
347 $pointList = array();
349 if(count($value) > 0)
351 foreach($value as $point)
355 $c = explode(
';', $point);
356 $placemarkList[] = array(
367 $center = static::getCenter($arUserField, $pointList);
370 $APPLICATION->IncludeComponent(
'bitrix:map.google.view',
'', array(
372 'MAP_WIDTH' =>
'100%',
373 'MAP_DATA' => serialize(array(
374 'google_scale' => $arUserField[
'SETTINGS'][
'INIT_MAP_SCALE'],
375 'google_lat' => $center[0],
376 'google_lon' => $center[1],
377 'PLACEMARKS' => $placemarkList
379 ),
null, array(
'HIDE_ICONS' =>
'Y'));
381 return ob_get_clean();