<?php
/*------------------------------------------------------------------------
# com_zhosmmap - Zh OpenStreetMap
# ------------------------------------------------------------------------
# author:    Dmitry Zhuk
# copyright: Copyright (C) 2011 zhuk.cc. All Rights Reserved.
# license:   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or later
# website:   http://zhuk.cc
# Technical Support Forum: http://forum.zhuk.cc/
-------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');

use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Uri\Uri;

use ZhukDL\Component\ZhOSMMap\Site\Helper\MapPlacemarksHelper;

// ------- fixing ----------
// default for external call
$db = Factory::getDBO();

if (!isset($currentmarker->rating_value)){$currentmarker->rating_value = 0;}
if (!isset($currentmarker->includeinlist)){$currentmarker->includeinlist = 0;}
if (!isset($currentmarker->zoombyclick)){$currentmarker->zoombyclick = 100;}
if (!isset($currentmarker->tag_show)){$currentmarker->tag_show = 0;}
if (!isset($currentmarker->tabid)){$currentmarker->tabid = 0;}
if (!isset($currentmarker->openbaloon)){$currentmarker->openbaloon = 0;}
if (!isset($currentmarker->createddate)){$currentmarker->createddate = "";}
if (!isset($currentmarker->overridemarkericon)){$currentmarker->overridemarkericon = 0;}
if (!isset($currentmarker->hrefimage)){$currentmarker->hrefimage = "";}
if (!isset($currentmarker->hoverhtml)){$currentmarker->hoverhtml = "";}
if (!isset($currentmarker->descriptionhtml)){$currentmarker->descriptionhtml = "";}
if (!isset($currentmarker->descriptionfullhtml)){$currentmarker->descriptionfullhtml = "";}
if (!isset($currentmarker->labelcontent)){$currentmarker->labelcontent = "";}
if (!isset($currentmarker->createdbyuser)){$currentmarker->createdbyuser = "";}
//


if (!isset($currentmarker->tab1)){$currentmarker->tab1 = "";}
if (!isset($currentmarker->tab2)){$currentmarker->tab2 = "";}
if (!isset($currentmarker->tab3)){$currentmarker->tab3 = "";}
if (!isset($currentmarker->tab4)){$currentmarker->tab4 = "";}
if (!isset($currentmarker->tab5)){$currentmarker->tab5 = "";}
if (!isset($currentmarker->tab6)){$currentmarker->tab6 = "";}
if (!isset($currentmarker->tab7)){$currentmarker->tab7 = "";}
if (!isset($currentmarker->tab8)){$currentmarker->tab8 = "";}
if (!isset($currentmarker->tab9)){$currentmarker->tab9 = "";}
if (!isset($currentmarker->tab10)){$currentmarker->tab10 = "";}
if (!isset($currentmarker->tab11)){$currentmarker->tab11 = "";}
if (!isset($currentmarker->tab12)){$currentmarker->tab12 = "";}
if (!isset($currentmarker->tab13)){$currentmarker->tab13 = "";}
if (!isset($currentmarker->tab14)){$currentmarker->tab14 = "";}
if (!isset($currentmarker->tab15)){$currentmarker->tab15 = "";}
if (!isset($currentmarker->tab16)){$currentmarker->tab16 = "";}
if (!isset($currentmarker->tab17)){$currentmarker->tab17 = "";}
if (!isset($currentmarker->tab18)){$currentmarker->tab18 = "";}
if (!isset($currentmarker->tab19)){$currentmarker->tab19 = "";}
//
if (!isset($currentmarker->tab1title)){$currentmarker->tab1title = "";}
if (!isset($currentmarker->tab2title)){$currentmarker->tab2title = "";}
if (!isset($currentmarker->tab3title)){$currentmarker->tab3title = "";}
if (!isset($currentmarker->tab4title)){$currentmarker->tab4title = "";}
if (!isset($currentmarker->tab5title)){$currentmarker->tab5title = "";}
if (!isset($currentmarker->tab6title)){$currentmarker->tab6title = "";}
if (!isset($currentmarker->tab7title)){$currentmarker->tab7title = "";}
if (!isset($currentmarker->tab8title)){$currentmarker->tab8title = "";}
if (!isset($currentmarker->tab9title)){$currentmarker->tab9title = "";}
if (!isset($currentmarker->tab10title)){$currentmarker->tab10title = "";}
if (!isset($currentmarker->tab11title)){$currentmarker->tab11title = "";}
if (!isset($currentmarker->tab12title)){$currentmarker->tab12title = "";}
if (!isset($currentmarker->tab13title)){$currentmarker->tab13title = "";}
if (!isset($currentmarker->tab14title)){$currentmarker->tab14title = "";}
if (!isset($currentmarker->tab15title)){$currentmarker->tab15title = "";}
if (!isset($currentmarker->tab16title)){$currentmarker->tab16title = "";}
if (!isset($currentmarker->tab17title)){$currentmarker->tab17title = "";}
if (!isset($currentmarker->tab18title)){$currentmarker->tab18title = "";}
if (!isset($currentmarker->tab19title)){$currentmarker->tab19title = "";}
//
if (!isset($currentmarker->tab1image)){$currentmarker->tab1image = "";}
if (!isset($currentmarker->tab2image)){$currentmarker->tab2image = "";}
if (!isset($currentmarker->tab3image)){$currentmarker->tab3image = "";}
if (!isset($currentmarker->tab4image)){$currentmarker->tab4image = "";}
if (!isset($currentmarker->tab5image)){$currentmarker->tab5image = "";}
if (!isset($currentmarker->tab6image)){$currentmarker->tab6image = "";}
if (!isset($currentmarker->tab7image)){$currentmarker->tab7image = "";}
if (!isset($currentmarker->tab8image)){$currentmarker->tab8image = "";}
if (!isset($currentmarker->tab9image)){$currentmarker->tab9image = "";}
if (!isset($currentmarker->tab10image)){$currentmarker->tab10image = "";}
if (!isset($currentmarker->tab11image)){$currentmarker->tab11image = "";}
if (!isset($currentmarker->tab12image)){$currentmarker->tab12image = "";}
if (!isset($currentmarker->tab13image)){$currentmarker->tab13image = "";}
if (!isset($currentmarker->tab14image)){$currentmarker->tab14image = "";}
if (!isset($currentmarker->tab15image)){$currentmarker->tab15image = "";}
if (!isset($currentmarker->tab16image)){$currentmarker->tab16image = "";}
if (!isset($currentmarker->tab17image)){$currentmarker->tab17image = "";}
if (!isset($currentmarker->tab18image)){$currentmarker->tab18image = "";}
if (!isset($currentmarker->tab19image)){$currentmarker->tab19image = "";}



$returnText = '';

// Begin restriction 
    if (
            ((($currentmarker->markergroup != 0)
                    && ((int)$currentmarker->published == 1)
                    && ((int)$currentmarker->publishedgroup == 1)) || ($allowUserMarker == 1)
            ) || 
            ((($currentmarker->markergroup == 0)
                    && ((int)$currentmarker->published == 1)) || ($allowUserMarker == 1)
            ) 
    )
    {

            //$returnText .= '    alert("Work on marker '. $currentmarker->id.'");'."\n";
            $returnText .= 'var titlePlacemark'. $currentmarker->id.' = "'.htmlspecialchars(str_replace('\\', '/', $currentmarker->title), ENT_QUOTES, 'UTF-8').'";'."\n";
            if (($currentmarker->latitude != "" && $currentmarker->longitude != ""))
            {
                    {
                            $returnText .= 'var latlng'. $currentmarker->id.' = L.latLng('.$currentmarker->latitude.', ' .$currentmarker->longitude.');' ."\n";

                            if (isset($map->auto_center_zoom) && ((int)$map->auto_center_zoom !=0))
                            {
                                $returnText .= 'map_bounds'.$mapDivSuffix.'.extend(latlng'. $currentmarker->id.');' ."\n";
                            }
                            // Begin marker creation with lat,lng
                            // contentString - Begin
                            $returnText .= 'var contentString'. $currentmarker->id.' = "";'."\n";
                            if (($allowUserMarker == 0)
                             || ((int)$map->usermarkersupdate == 0)
                             || (isset($currentmarker->userprotection) && (int)$currentmarker->userprotection == 1)
                             || ($currentUserID == 0)
                             || (isset($currentmarker->createdbyuser) 
                                && (((int)$currentmarker->createdbyuser != $currentUserID )
                                       || ((int)$currentmarker->createdbyuser == 0)))
                             )
                            {
                                    if (isset($map->useajax) && (int)$map->useajax != 0)
                                    {
                                            // do not create content string, create by loop only in the end
                                    }
                                    else
                                    {
                                            if (((int)$currentmarker->actionbyclick == 1)
                                              || (int)$currentmarker->actionbyclick == 4) 
                                            {
                                                    if ((int)$currentmarker->actionbyclick == 1)
                                                    {                                        
                                                            $returnText .= 'contentString'. $currentmarker->id.' = '.
                                                                    MapPlacemarksHelper::get_placemark_content_string(
                                                                            $mapDivSuffix, 
                                                                            $currentmarker, $map->usercontact, $map->useruser,
                                                                            $userContactAttrs, $service_DoDirection,
                                                                            $imgpathIcons, $imgpathUtils, $directoryIcons, $map->placemark_rating, $main_lang, $placemarkTitleTag, $map->showcreateinfo,
                                                                            $map->gogoogle, $fv_override_gogoogle_text,
                                                                            $fv_placemark_date_fmt);                                            
                                                            $returnText .= ';'."\n";
                                                    }
                                                    if ((int)$currentmarker->actionbyclick == 4)
                                                    {
                                                        if ($managePanelInfowin == 1)                    
                                                        {
                                                                    $returnText .= 'contentString'. $currentmarker->id.' = '.
                                                                            MapPlacemarksHelper::get_placemark_tabs_content_string(
                                                                                    $placemarkTitleTag, "panel",
                                                                                    $mapDivSuffix, $currentmarker,
                                                                                    MapPlacemarksHelper::get_placemark_content_string(
                                                                                            $mapDivSuffix, 
                                                                                            $currentmarker, $map->usercontact, $map->useruser,
                                                                                            $userContactAttrs, $service_DoDirection,
                                                                                            $imgpathIcons, $imgpathUtils, $directoryIcons, $map->placemark_rating, $main_lang, $placemarkTitleTag, $map->showcreateinfo,
                                                                                            $map->gogoogle, $fv_override_gogoogle_text,
                                                                                            $fv_placemark_date_fmt),
                                                                                    $imgpathIcons, $imgpathUtils, $directoryIcons, $main_lang);                                            
                                                                    $returnText .= ';'."\n";
                                                        }
                                                        else 
                                                        {
                                                                    $returnText .= 'contentString'. $currentmarker->id.' = '.
                                                                            MapPlacemarksHelper::get_placemark_tabs_content_string(
                                                                                    $placemarkTitleTag, "popup",
                                                                                    $mapDivSuffix, $currentmarker,
                                                                                    MapPlacemarksHelper::get_placemark_content_string(
                                                                                            $mapDivSuffix, 
                                                                                            $currentmarker, $map->usercontact, $map->useruser,
                                                                                            $userContactAttrs, $service_DoDirection,
                                                                                            $imgpathIcons, $imgpathUtils, $directoryIcons, $map->placemark_rating, $main_lang, $placemarkTitleTag, $map->showcreateinfo,
                                                                                            $map->gogoogle, $fv_override_gogoogle_text,
                                                                                            $fv_placemark_date_fmt),
                                                                                    $imgpathIcons, $imgpathUtils, $directoryIcons, $main_lang);                                            
                                                                    $returnText .= ';'."\n";
                                                        }

                                                    }                                    


                                            }
                                    }
                            }
                            else
                            {
                                    // contentString - User Placemark can Update - Begin
                                    $returnText .= MapPlacemarksHelper::get_placemark_content_update_string(
                                                                                    $map->usermarkersicon, 
                                                                                    $map->usercontact, 
                                                                                    $currentmarker,
                                                                                    $imgpathIcons, $imgpathUtils, $directoryIcons,
                                                                                    $newMarkerGroupList
                                                                                    );
                                    // contentString - User Placemark can Update - End
                            }

                            if (isset($map->hovermarker) && ((int)$map->hovermarker !=0))    
                            {
                                    if (isset($map->useajax) && (int)$map->useajax != 0)
                                    {
                                            // do not create content string, create by loop only in the end
                                    }
                                    else
                                    {
                                            if ((int)$map->hovermarker != 0)
                                            {
                                                    if ($currentmarker->hoverhtml != "")
                                                    {
                                                            $returnText .= 'var hoverString'. $currentmarker->id.' = '.
                                                                    MapPlacemarksHelper::get_placemark_hover_string(
                                                                            $currentmarker);                                    
                                                    }
                                            }
                                    }
                            }

                            if ((int)$currentmarker->baloon != 0) 
                            {

                                    if (((int)$currentmarker->baloon == 5
                                      || (int)$currentmarker->baloon == 52
                                      || (int)$currentmarker->baloon == 54)
                                    && (int)$currentmarker->overridemarkericon == 0) 
                                    {
                                            $returnText .= 'var marker'. $currentmarker->id.' = L.marker(latlng'. $currentmarker->id.', {' ."\n";
                                    }
                                    else
                                    {
                                        $returnText .= 'var marker'. $currentmarker->id.' = L.marker(latlng'. $currentmarker->id.', {icon:' ."\n";
                                        $returnText .= MapPlacemarksHelper::get_placemark_icon_definition(
                                                                                $imgpathIcons,
                                                                                $imgpath4size,
                                                                                $currentmarker). ',';                                                                
                                    }


                                    if (($allowUserMarker == 0)
                                     || ((int)$map->usermarkersupdate == 0)
                                     || (isset($currentmarker->userprotection) && (int)$currentmarker->userprotection == 1)
                                     || ($currentUserID == 0)
                                     || (isset($currentmarker->createdbyuser) 
                                            && (((int)$currentmarker->createdbyuser != $currentUserID )
                                               || ((int)$currentmarker->createdbyuser == 0))))
                                    {
                                                    $returnText .= '      draggable: false,' ."\n";
                                    }
                                    else
                                    {
                                                    $returnText .= '      draggable: true,' ."\n";
                                    }

                                    // Replace to new, because all charters are shown
                                    //$returnText .= '      title:"'.htmlspecialchars(str_replace('\\', '/', $currentmarker->title), ENT_QUOTES, 'UTF-8').'"' ."\n";
                                    if (isset($currentmarker->markercontent) &&
                                            (((int)$currentmarker->markercontent == 0) ||
                                             ((int)$currentmarker->markercontent == 1) ||
                                             ((int)$currentmarker->markercontent == 9))
                                            )
                                    {
                                            $returnText .= '      title:"'.str_replace('\\', '/', str_replace('"', '\'\'', $currentmarker->title)).'"' ."\n";
                                    }
                                    else
                                    {
                                            $returnText .= '      title:""' ."\n";
                                    }


                                    $returnText .= '});'."\n";


                                    if ((isset($map->markercluster) && (int)$map->markercluster == 0))
                                    {
                                        $returnText .= 'marker'. $currentmarker->id.'.addTo(map'.$mapDivSuffix.');' ."\n";
                                    }



                                    if ($externalmarkerlink == 1)
                                    {
                                            $returnText .= 'PlacemarkByIDAdd('. $currentmarker->id.
                                                                                                            ', '.$currentmarker->latitude.
                                                                                                            ', '.$currentmarker->longitude.
                                                                                                            ', marker'. $currentmarker->id.
                                                                                                            ', latlng'. $currentmarker->id.
                                                                                                            ', '.(int)$currentmarker->rating_value.
                                                                                                            ');'."\n";
                                    }

                                    $returnText .= '  marker'. $currentmarker->id.'.zhomRating = '.(int)$currentmarker->rating_value.';' ."\n";    
                                    $returnText .= '  marker'. $currentmarker->id.'.zhomCreateddate = "'.$currentmarker->createddate.'";' ."\n";
                                    $fv_date_user = "";
                                    if ($currentmarker->createddate == "0000-00-00 00:00:00")
                                    {
                                        $fv_date_user = "";
                                    }
                                    else
                                    {
                                        if ($fv_placemark_date_fmt != "")
                                        {
                                            $fv_date = new DateTime($currentmarker->createddate);
                                            $fv_date_user = $fv_date->format($fv_placemark_date_fmt);
                                        }
                                        else
                                        {
                                            $fv_date_user = $currentmarker->createddate;
                                        }
                                    }
                                    $returnText .= '  marker'. $currentmarker->id.'.zhomExtraFieldsList = [];' ."\n";
                                    $returnText .= '  marker'. $currentmarker->id.'.zhomCreateddateUser = "'.$fv_date_user.'";' ."\n";
                                    $returnText .= '  marker'. $currentmarker->id.'.zhomPlacemarkID = '.$currentmarker->id.';' ."\n";                            
                                    $returnText .= '  marker'. $currentmarker->id.'.zhomContactAttrs = userContactAttrs;' ."\n";
                                    $returnText .= '  marker'. $currentmarker->id.'.zhomUserContact = "'.str_replace(';', ',', $map->usercontact).'";' ."\n";
                                    $returnText .= '  marker'. $currentmarker->id.'.zhomUserUser = "'.str_replace(';', ',', $map->useruser).'";' ."\n";
                                    $returnText .= '  marker'. $currentmarker->id.'.zhomOriginalPosition = latlng'.$currentmarker->id.';' ."\n";
                                    $returnText .= '  marker'. $currentmarker->id.'.zhomInfowinContent = contentString'. $currentmarker->id.';' ."\n";    
                                    $returnText .= '  marker'. $currentmarker->id.'.zhomTitle = "'.str_replace('\\', '/', str_replace('"', '\'\'', $currentmarker->title)).'";' ."\n";
                                    $returnText .= '  marker'. $currentmarker->id.'.zhomIncludeInList = '.(int)$currentmarker->includeinlist.';' ."\n";                            
                                    if ($fv_override_placemark_list_search == 1)
                                    {
                                        $returnText .= '  marker'. $currentmarker->id.'.zhomPlacemarkDescription = "'.str_replace('\\', '/', str_replace('"', '\'\'', $currentmarker->description)).'";' ."\n";                                                                                                                    
                                    }

                                    if ($placemarkSearch != 0)                
                                    {
                                            $returnText .= '  zhomObjMgr'.$mapDivSuffix.'.allObjectsAddPlacemark('. $currentmarker->id.', marker'. $currentmarker->id.');'."\n";
                                    }

                                    if (isset($map->hovermarker) && ((int)$map->hovermarker !=0))    
                                    {
                                            if ($currentmarker->hoverhtml != "")
                                            {
                                                    if (isset($map->useajax) && (int)$map->useajax != 0)
                                                    {
                                                            // do not create listeners, create by loop only in the end
                                                            $returnText .= '  ajaxmarkersLLhover'.$mapDivSuffix.'.push(marker'. $currentmarker->id.');'."\n";
                                                    }
                                                    else
                                                    {
                                                            if ((int)$map->hovermarker != 0)
                                                            {
                                                                    $returnText .= '  marker'. $currentmarker->id.'.bindTooltip(hoverString'. $currentmarker->id.$fv_hover_marker_options.');'."\n";

                                                                    $returnText .= '  marker'. $currentmarker->id.'.on(\'mouseover\', function(event) {' ."\n";
                                                                    $returnText .= '    marker'. $currentmarker->id.'.openTooltip();' ."\n";
                                                                    $returnText .= '  });' ."\n";

                                                                    $returnText .= '  marker'. $currentmarker->id.'.on(\'mouseout\', function(event) {' ."\n";
                                                                    $returnText .= '    marker'. $currentmarker->id.'.closeTooltip();' ."\n";
                                                                    $returnText .= '  });' ."\n";
                                                            }

                                                    }
                                            }
                                    }


                                    //  If user can change placemark - override content string - begin
                                    //  override content string
                                    if (($allowUserMarker == 0)
                                     || ((int)$map->usermarkersupdate == 0)
                                     || (isset($currentmarker->userprotection) && (int)$currentmarker->userprotection == 1)
                                     || ($currentUserID == 0)
                                     || (isset($currentmarker->createdbyuser) 
                                            && (((int)$currentmarker->createdbyuser != $currentUserID )
                                               || ((int)$currentmarker->createdbyuser == 0)))
                                    )
                                    {
                                            if (isset($map->useajax) && (int)$map->useajax != 0)
                                            {
                                                    // do not create listeners, create by loop only in the end
                                                    $returnText .= '  ajaxmarkersLL'.$mapDivSuffix.'.push(marker'. $currentmarker->id.');'."\n";
                                            }
                                            else
                                            {
                                            // Action By Click - Begin        

                                            switch ((int)$currentmarker->actionbyclick)
                                            {
                                                    // None
                                                    case 0:
                                                            if ((int)$currentmarker->zoombyclick != 100)
                                                            {
                                                                $returnText .= '  marker'. $currentmarker->id.'.on(\'click\', function(event) {' ."\n";
                                                                $returnText .= '  map'.$mapDivSuffix.'.setView(this.getLatLng(), '.(int)$currentmarker->zoombyclick.');' ."\n";    
                                                                    $returnText .= '  }));' ."\n";
                                                            }
                                                    break;
                                                    // Info
                                                    case 1:
                                                            if ($managePanelInfowin == 1)
                                                            {
                                                                // do not bind popup for panel
                                                            }
                                                            else
                                                            {
                                                                if ((int)$currentmarker->tabid == 0)
                                                                {
                                                                    if ($fv_override_placemark_popup_style != 0)
                                                                    {
                                                                        $scripttext_pp_style = MapPlacemarksHelper::get_placemark_infobubble_style_by_id($fv_override_placemark_popup_style, '');
                                                                    }
                                                                    else
                                                                    {
                                                                        $scripttext_pp_style = MapPlacemarksHelper::get_placemark_infobubble_style_string($currentmarker, '');
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    $scripttext_pp_style = MapPlacemarksHelper::get_placemark_infobubble_style_string($currentmarker, '');
                                                                }

                                                                if ($scripttext_pp_style != "")
                                                                {
                                                                    $returnText .= '  marker'. $currentmarker->id.'.bindPopup(L.popup('.$scripttext_pp_style.').setContent(marker'. $currentmarker->id.'.zhomInfowinContent));'."\n";
                                                                }
                                                                else
                                                                {
                                                                    if (isset($map->disableautopan) && ((int)$map->disableautopan == 1))    
                                                                    {
                                                                        $returnText .= '  marker'.$currentmarker->id.'.bindPopup(L.popup('.$scripttext_pp_main_style.').setContent(marker'. $currentmarker->id.'.zhomInfowinContent));'."\n";
                                                                    }
                                                                    else
                                                                    {
                                                                        $returnText .= '  marker'. $currentmarker->id.'.bindPopup(marker'. $currentmarker->id.'.zhomInfowinContent);'."\n";
                                                                    }                                                                               
                                                                }       
                                                            }
                                                              
                                            
                                                            $returnText .= '  marker'. $currentmarker->id.'.on(\'click\', function(event) {' ."\n";

                                                            if ((int)$currentmarker->zoombyclick != 100)
                                                            {
                                                                    $returnText .= '  map'.$mapDivSuffix.'.setView(this.getLatLng(), '.(int)$currentmarker->zoombyclick.');' ."\n";
                                                            }

                                                            if ((int)$map->markerlistpos != 0)
                                                            {
                                                                    $returnText .= '  Map_Animate_Marker_Hide(map'.$mapDivSuffix.', marker'. $currentmarker->id.');'."\n";    
                                                            }
                                                            if ($managePanelInfowin == 1)
                                                            {                                                                                                    
                                                                    $returnText .= '  zhomObjMgr'.$mapDivSuffix.'.panelShowPlacemarkContent(this.zhomInfowinContent);' ."\n";
                                                            }    
                                                            else
                                                            {                                            
                                                                    $returnText .= ' this.openPopup();' ."\n";

                                                            }


                                                            if (isset($map->placemark_rating) && ((int)$map->placemark_rating !=0))
                                                            {
                                                                    $returnText .= '  PlacemarkRateDivOut'.$mapDivSuffix.'('. $currentmarker->id.', 5);' ."\n";
                                                            }


                                                            $returnText .= '  });' ."\n";
                                                    break;
                                                    // Link
                                                    case 2:
                                                            if ($currentmarker->hrefsite != "")
                                                            {
                                                                    $returnText .= '  marker'. $currentmarker->id.'.on(\'click\', function(event) {' ."\n";


                                                                    if ((int)$currentmarker->zoombyclick != 100)
                                                                    {
                                                                            $returnText .= '  map'.$mapDivSuffix.'.setView(this.getLatLng(), '.(int)$currentmarker->zoombyclick.');' ."\n";
                                                                    }
                                                                    $returnText .= '  window.open("'.$currentmarker->hrefsite.'");' ."\n";


                                                                    $returnText .= '  });' ."\n";
                                                            }
                                                            else
                                                            {
                                                                    if ((int)$currentmarker->zoombyclick != 100)
                                                                    {
                                                                            $returnText .= '  marker'. $currentmarker->id.'.on(\'click\', function(event) {' ."\n";

                                                                            $returnText .= '  map'.$mapDivSuffix.'.setView(this.getLatLng(), '.(int)$currentmarker->zoombyclick.');' ."\n";

                                                                            $returnText .= '  });' ."\n";
                                                                    }
                                                            }
                                                    break;
                                                    // Link in self
                                                    case 3:
                                                            if ($currentmarker->hrefsite != "")
                                                            {
                                                                    $returnText .= '  marker'. $currentmarker->id.'.on(\'click\', function(event) {' ."\n";

                                                                    if ((int)$currentmarker->zoombyclick != 100)
                                                                    {
                                                                            $returnText .= '  map'.$mapDivSuffix.'.setView(this.getLatLng(), '.(int)$currentmarker->zoombyclick.');' ."\n";
                                                                    }
                                                                    $returnText .= '  window.location = "'.$currentmarker->hrefsite.'";' ."\n";

                                                                    $returnText .= '  });' ."\n";
                                                            }
                                                            else
                                                            {
                                                                    if ((int)$currentmarker->zoombyclick != 100)
                                                                    {
                                                                            $returnText .= '  marker'. $currentmarker->id.'.on(\'click\', function(event) {' ."\n";

                                                                            $returnText .= '  map'.$mapDivSuffix.'.setView(this.getLatLng(), '.(int)$currentmarker->zoombyclick.');' ."\n";

                                                                            $returnText .= '  });' ."\n";
                                                                    }
                                                            }
                                                    break;
                                                    // Info with tabs
                                                    case 4:
                                                            if ($managePanelInfowin == 1)
                                                            {
                                                                // do not bind popup for panel
                                                            }
                                                            else
                                                            {
                                                                if ((int)$currentmarker->tabid == 0)
                                                                {
                                                                    if ($fv_override_placemark_popup_style != 0)
                                                                    {
                                                                        $scripttext_pp_style = MapPlacemarksHelper::get_placemark_infobubble_style_by_id($fv_override_placemark_popup_style, '');
                                                                    }
                                                                    else
                                                                    {
                                                                        $scripttext_pp_style = MapPlacemarksHelper::get_placemark_infobubble_style_string($currentmarker, '');
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    $scripttext_pp_style = MapPlacemarksHelper::get_placemark_infobubble_style_string($currentmarker, '');
                                                                }
                                                                if ($scripttext_pp_style != "")
                                                                {
                                                                    $returnText .= '  marker'. $currentmarker->id.'.bindPopup(L.popup('.$scripttext_pp_style.').setContent(marker'. $currentmarker->id.'.zhomInfowinContent));'."\n";                                                                                  
                                                                }
                                                                else
                                                                {
                                                                    if (isset($map->disableautopan) && ((int)$map->disableautopan == 1))    
                                                                    {
                                                                        $returnText .= '  marker'.$currentmarker->id.'.bindPopup(L.popup('.$scripttext_pp_main_style.').setContent(marker'. $currentmarker->id.'.zhomInfowinContent));'."\n";
                                                                    }
                                                                    else
                                                                    {
                                                                        $returnText .= '  marker'. $currentmarker->id.'.bindPopup(marker'. $currentmarker->id.'.zhomInfowinContent);'."\n";
                                                                    }                                                                                   
                                                                }
                                                            }
                                                            
                                                            $returnText .= '  marker'. $currentmarker->id.'.on(\'click\', function(event) {' ."\n";

                                                            if ((int)$currentmarker->zoombyclick != 100)
                                                            {
                                                                    $returnText .= '  map'.$mapDivSuffix.'.setView(this.getLatLng(), '.(int)$currentmarker->zoombyclick.');' ."\n";
                                                            }

                                                            if ((int)$map->markerlistpos != 0)
                                                            {
                                                                    $returnText .= '  Map_Animate_Marker_Hide(map'.$mapDivSuffix.', marker'. $currentmarker->id.');'."\n";    
                                                            }
                                                            if ($managePanelInfowin == 1)
                                                            {                                                                                                    
                                                                    $returnText .= '  zhomObjMgr'.$mapDivSuffix.'.panelShowPlacemarkContentTabs(this.zhomInfowinContent);' ."\n";
                                                            }    
                                                            else
                                                            {                                            
                                                                    $returnText .= ' this.openPopup();' ."\n";
                                                                    $returnText .= ' var p_show = document.getElementById("zhom-tablinks'.(int)$currentmarker->id.'_1");' ."\n";
                                                                    $returnText .= ' if (p_show != null) {' ."\n";
                                                                    $returnText .= '    p_show.click();' ."\n";
                                                                    $returnText .= ' }' ."\n";

                                                            }


                                                            if (isset($map->placemark_rating) && ((int)$map->placemark_rating !=0))
                                                            {
                                                                    $returnText .= '  PlacemarkRateDivOut'.$mapDivSuffix.'('. $currentmarker->id.', 5);' ."\n";
                                                            }                                    

                                                            $returnText .= '  });' ."\n";
                                                    break;
                                                    // Contact
                                                    case 10:
                                                            $marker_link = "";
                                                            if (isset($currentmarker->hrefcontact) && $currentmarker->hrefcontact != "")
                                                            {
                                                                    // Check alternative contact URL
                                                                    $marker_link = $currentmarker->hrefcontact;
                                                            }
                                                            else if (isset($currentmarker->contactid) && (int)$currentmarker->contactid != 0)
                                                            {
                                                                    // Check contact ID for default URL
                                                                    $marker_link = Route::_('index.php?option=com_contact&view=contact&id='.$currentmarker->contactid);
                                                            }

                                                            if ($marker_link != "")
                                                            {
                                                                    $returnText .= '  marker'. $currentmarker->id.'.on(\'click\', function(event) {' ."\n";

                                                                    if ((int)$currentmarker->zoombyclick != 100)
                                                                    {
                                                                            $returnText .= '  map'.$mapDivSuffix.'.setView(this.getLatLng(), '.(int)$currentmarker->zoombyclick.');' ."\n";
                                                                    }
                                                                    $returnText .= '  window.open("'.$marker_link.'");' ."\n";

                                                                    $returnText .= '  });' ."\n";
                                                            }
                                                            else
                                                            {
                                                                    if ((int)$currentmarker->zoombyclick != 100)
                                                                    {
                                                                            $returnText .= '  marker'. $currentmarker->id.'.on(\'click\', function(event) {' ."\n";

                                                                            $returnText .= '  map'.$mapDivSuffix.'.setView(this.getLatLng(), '.(int)$currentmarker->zoombyclick.');' ."\n";

                                                                            $returnText .= '  });' ."\n";
                                                                    }
                                                            }
                                                    break;
                                                    // Contact in self
                                                    case 11:
                                                            $marker_link = "";
                                                            if (isset($currentmarker->hrefcontact) && $currentmarker->hrefcontact != "")
                                                            {
                                                                    // Check alternative contact URL
                                                                    $marker_link = $currentmarker->hrefcontact;
                                                            }
                                                            else if (isset($currentmarker->contactid) && (int)$currentmarker->contactid != 0)
                                                            {
                                                                    // Check contact ID for default URL
                                                                    $marker_link = Route::_('index.php?option=com_contact&view=contact&id='.$currentmarker->contactid);
                                                            }

                                                            if ($marker_link != "")
                                                            {
                                                                    $returnText .= '  marker'. $currentmarker->id.'.on(\'click\', function(event) {' ."\n";

                                                                    if ((int)$currentmarker->zoombyclick != 100)
                                                                    {
                                                                            $returnText .= '  map'.$mapDivSuffix.'.setView(this.getLatLng(), '.(int)$currentmarker->zoombyclick.');' ."\n";
                                                                    }
                                                                    $returnText .= '  window.location = "'.$marker_link.'";' ."\n";

                                                                    $returnText .= '  });' ."\n";
                                                            }
                                                            else
                                                            {
                                                                    if ((int)$currentmarker->zoombyclick != 100)
                                                                    {
                                                                            $returnText .= '  marker'. $currentmarker->id.'.on(\'click\', function(event) {' ."\n";

                                                                            $returnText .= '  map'.$mapDivSuffix.'.setView(this.getLatLng(), '.(int)$currentmarker->zoombyclick.');' ."\n";

                                                                            $returnText .= '  });' ."\n";
                                                                    }
                                                            }
                                                    break;
                                                    // Article
                                                    case 12:
                                                            $marker_link = "";
                                                            if (isset($currentmarker->hrefarticle) && $currentmarker->hrefarticle != "")
                                                            {
                                                                    // Check alternative contact URL
                                                                    $marker_link = $currentmarker->hrefarticle;
                                                            }
                                                            else if (isset($currentmarker->articleid) && (int)$currentmarker->articleid != 0)
                                                            {
                                                                    // Check contact ID for default URL
                                                                    $article_category = MapPlacemarksHelper::get_ArticleCategory($currentmarker->articleid);
                                                                    $marker_link = Route::_('index.php?option=com_content&view=article&id='.$currentmarker->articleid.'&catid='.(int)$article_category);
                                                            }

                                                            if ($marker_link != "")
                                                            {
                                                                    $returnText .= '  marker'. $currentmarker->id.'.on(\'click\', function(event) {' ."\n";

                                                                    if ((int)$currentmarker->zoombyclick != 100)
                                                                    {
                                                                            $returnText .= '  map'.$mapDivSuffix.'.setView(this.getLatLng(), '.(int)$currentmarker->zoombyclick.');' ."\n";
                                                                    }
                                                                    $returnText .= '  window.open("'.$marker_link.'");' ."\n";

                                                                    $returnText .= '  });' ."\n";
                                                            }
                                                            else
                                                            {
                                                                    if ((int)$currentmarker->zoombyclick != 100)
                                                                    {
                                                                            $returnText .= '  marker'. $currentmarker->id.'.on(\'click\', function(event) {' ."\n";

                                                                            $returnText .= '  map'.$mapDivSuffix.'.setView(this.getLatLng(), '.(int)$currentmarker->zoombyclick.');' ."\n";

                                                                            $returnText .= '  });' ."\n";
                                                                    }
                                                            }
                                                    break;
                                                    // Article in self
                                                    case 13:
                                                            $marker_link = "";
                                                            if (isset($currentmarker->hrefarticle) && $currentmarker->hrefarticle != "")
                                                            {
                                                                    // Check alternative article URL
                                                                    $marker_link = $currentmarker->hrefarticle;
                                                            }
                                                            else if (isset($currentmarker->articleid) && (int)$currentmarker->articleid != 0)
                                                            {
                                                                    // Check article ID for default URL
                                                                    $article_category = MapPlacemarksHelper::get_ArticleCategory($currentmarker->articleid);
                                                                    $marker_link = Route::_('index.php?option=com_content&view=article&id='.$currentmarker->articleid.'&catid='.(int)$article_category);
                                                            }

                                                            if ($marker_link != "")
                                                            {
                                                                    $returnText .= '  marker'. $currentmarker->id.'.on(\'click\', function(event) {' ."\n";

                                                                    if ((int)$currentmarker->zoombyclick != 100)
                                                                    {
                                                                            $returnText .= '  map'.$mapDivSuffix.'.setView(this.getLatLng(), '.(int)$currentmarker->zoombyclick.');' ."\n";
                                                                    }
                                                                    $returnText .= '  window.location = "'.$marker_link.'";' ."\n";

                                                                    $returnText .= '  });' ."\n";
                                                            }
                                                            else
                                                            {
                                                                    if ((int)$currentmarker->zoombyclick != 100)
                                                                    {
                                                                            $returnText .= '  marker'. $currentmarker->id.'.on(\'click\', function(event) {' ."\n";

                                                                            $returnText .= '  map'.$mapDivSuffix.'.setView(this.getLatLng(), '.(int)$currentmarker->zoombyclick.');' ."\n";

                                                                            $returnText .= '  });' ."\n";
                                                                    }
                                                            }
                                                    break;
                                                    // Details
                                                    case 14:
                                                            $marker_link = "";
                                                            if (isset($currentmarker->hrefdetail) && $currentmarker->hrefdetail != "")
                                                            {
                                                                    // Check alternative detail URL
                                                                    $marker_link = $currentmarker->hrefdetail;
                                                            }
                                                            else if (isset($currentmarker->id) && (int)$currentmarker->id != 0)
                                                            {
                                                                    // Check details ID for default URL
                                                                    $detailsAttrs = str_replace(";", ',',$currentmarker->attributesdetail);
                                                                    $detailsAttrArray = explode(",", $detailsAttrs);

                                                                    for($i = 0; $i < count($detailsAttrArray); $i++) 
                                                                    {
                                                                            $detailsAttrArray[$i] = strtolower(trim($detailsAttrArray[$i]));
                                                                    }

                                                                    $load_bs = 9;
                                                                    $prop_thumbnail = 0;
                                                                    $prop_imagegalery = 0;
                                                                    $prop_hidedescriptionhtml = 1;
                                                                    $prop_showdescriptionfullhtml = 0;

                                                                    for($i = 0; $i < count($detailsAttrArray); $i++) 
                                                                    {

                                                                            switch ($detailsAttrArray[$i]) 
                                                                            {

                                                                                    case 'load bootstrap':
                                                                                            $load_bs = 0;
                                                                                    break;
                                                                                    case 'load bootstrap styles':
                                                                                            $load_bs = 1;
                                                                                    break;
                                                                                    case 'thumbnail':
                                                                                            $prop_thumbnail = 1;
                                                                                    break;
                                                                                    case 'image gallery':
                                                                                            $prop_imagegalery = 1;
                                                                                    break;
                                                                                    case 'image galery':
                                                                                            $prop_imagegalery = 1;
                                                                                    break;
                                                                                    case 'addition html text':
                                                                                            $prop_hidedescriptionhtml = 0;
                                                                                    break;
                                                                                    case 'full description': 
                                                                                            $prop_showdescriptionfullhtml = 1;
                                                                                    break;
                                                                            }                        
                                                                    }

                                                                    $marker_link = URI::base().'index.php?option=com_zhosmmap&view=placemark&load_bootstrap='.$load_bs
                                                                                                      .'&thumbnail='.$prop_thumbnail
                                                                                                      .'&imagegalery='.$prop_imagegalery
                                                                                                      .'&hidedescriptionhtml='.$prop_hidedescriptionhtml
                                                                                                      .'&showdescriptionfullhtml='.$prop_showdescriptionfullhtml
                                                                                                      .'&id=' . $currentmarker->id;
                                                            }

                                                            if ($marker_link != "")
                                                            {
                                                                    $returnText .= '  marker'. $currentmarker->id.'.on(\'click\', function(event) {' ."\n";

                                                                    if ((int)$currentmarker->zoombyclick != 100)
                                                                    {
                                                                            $returnText .= '  map'.$mapDivSuffix.'.setView(this.getLatLng(), '.(int)$currentmarker->zoombyclick.');' ."\n";
                                                                    }
                                                                    $returnText .= '  window.open("'.$marker_link.'");' ."\n";

                                                                    $returnText .= '  });' ."\n";
                                                            }
                                                            else
                                                            {
                                                                    if ((int)$currentmarker->zoombyclick != 100)
                                                                    {
                                                                            $returnText .= '  marker'. $currentmarker->id.'.on(\'click\', function(event) {' ."\n";

                                                                            $returnText .= '  map'.$mapDivSuffix.'.setView(this.getLatLng(), '.(int)$currentmarker->zoombyclick.');' ."\n";

                                                                            $returnText .= '  });' ."\n";
                                                                    }
                                                            }
                                                    break;
                                                    // Details in self
                                                    case 15:
                                                            $marker_link = "";
                                                            if (isset($currentmarker->hrefdetail) && $currentmarker->hrefdetail != "")
                                                            {
                                                                    // Check alternative detail URL
                                                                    $marker_link = $currentmarker->hrefdetail;
                                                            }
                                                            else if (isset($currentmarker->id) && (int)$currentmarker->id != 0)
                                                            {
                                                                    // Check details ID for default URL
                                                                    $detailsAttrs = str_replace(";", ',',$currentmarker->attributesdetail);
                                                                    $detailsAttrArray = explode(",", $detailsAttrs);

                                                                    for($i = 0; $i < count($detailsAttrArray); $i++) 
                                                                    {
                                                                            $detailsAttrArray[$i] = strtolower(trim($detailsAttrArray[$i]));
                                                                    }

                                                                    $load_bs = 9;
                                                                    $prop_thumbnail = 0;
                                                                    $prop_imagegalery = 0;
                                                                    $prop_hidedescriptionhtml = 1;
                                                                    $prop_showdescriptionfullhtml = 0;

                                                                    for($i = 0; $i < count($detailsAttrArray); $i++) 
                                                                    {

                                                                            switch ($detailsAttrArray[$i]) 
                                                                            {

                                                                                    case 'load bootstrap':
                                                                                            $load_bs = 0;
                                                                                    break;
                                                                                    case 'load bootstrap styles':
                                                                                            $load_bs = 1;
                                                                                    break;
                                                                                    case 'thumbnail':
                                                                                            $prop_thumbnail = 1;
                                                                                    break;
                                                                                    case 'image gallery':
                                                                                            $prop_imagegalery = 1;
                                                                                    break;
                                                                                    case 'image galery':
                                                                                            $prop_imagegalery = 1;
                                                                                    break;
                                                                                    case 'addition html text':
                                                                                            $prop_hidedescriptionhtml = 0;
                                                                                    break;
                                                                                    case 'full description': 
                                                                                            $prop_showdescriptionfullhtml = 1;
                                                                                    break;
                                                                            }                        
                                                                    }

                                                                    $marker_link = URI::base().'index.php?option=com_zhosmmap&view=placemark&load_bootstrap='.$load_bs
                                                                                                      .'&thumbnail='.$prop_thumbnail
                                                                                                      .'&imagegalery='.$prop_imagegalery
                                                                                                      .'&hidedescriptionhtml='.$prop_hidedescriptionhtml
                                                                                                      .'&showdescriptionfullhtml='.$prop_showdescriptionfullhtml
                                                                                                      .'&id=' . $currentmarker->id;
                                                            }

                                                            if ($marker_link != "")
                                                            {
                                                                    $returnText .= '  marker'. $currentmarker->id.'.on(\'click\', function(event) {' ."\n";

                                                                    if ((int)$currentmarker->zoombyclick != 100)
                                                                    {
                                                                            $returnText .= '  map'.$mapDivSuffix.'.setView(this.getLatLng(), '.(int)$currentmarker->zoombyclick.');' ."\n";
                                                                    }
                                                                    $returnText .= '  window.location = "'.$marker_link.'";' ."\n";

                                                                    $returnText .= '  });' ."\n";
                                                            }
                                                            else
                                                            {
                                                                    if ((int)$currentmarker->zoombyclick != 100)
                                                                    {
                                                                            $returnText .= '  marker'. $currentmarker->id.'.on(\'click\', function(event) {' ."\n";

                                                                            $returnText .= '  map'.$mapDivSuffix.'.setView(this.getLatLng(), '.(int)$currentmarker->zoombyclick.');' ."\n";

                                                                            $returnText .= '  });' ."\n";
                                                                    }
                                                            }
                                                    break;
                                                    default:
                                                            $returnText .= '' ."\n";
                                                    break;
                                            }

                                            // Action By Click - End
                                            }
                                    }
                                    else
                                    {
                                            // Action By click for update placemark = Open InfoWin
                                                    // for DML bugfix for every 2 time call show popup (see new marker)
                                                    $returnText .= 'marker'. $currentmarker->id.'.bindPopup();';
                                                    //
                                                    $returnText .= 'marker'. $currentmarker->id.'.on(\'click\', function(event) {' ."\n";

                                                    $returnText .= 'var contentStringButtons'.$currentmarker->id.' = "" +' ."\n";
                                                    $returnText .= '    \'<hr />\'+' ."\n";                    
                                                    $returnText .= '    \'<input name="markerlat" type="hidden" value="\'+marker'.$currentmarker->id.'.getLatLng().lat + \'" />\'+' ."\n";
                                                    $returnText .= '    \'<input name="markerlng" type="hidden" value="\'+marker'.$currentmarker->id.'.getLatLng().lng + \'" />\'+' ."\n";
                                                    $returnText .= '    \'<input name="marker_action" type="hidden" value="update" />\'+' ."\n";
                                                    $returnText .= '    \'<input name="markerid" type="hidden" value="'.$currentmarker->id.'" />\'+' ."\n";
                                                    $returnText .= '    \'<input name="contactid" type="hidden" value="'.$currentmarker->contactid.'" />\'+' ."\n";
                                                    $returnText .= '    \'<input name="markersubmit" type="submit" value="'.Text::_( 'COM_ZHOSMMAP_MAP_USER_BUTTON_UPDATE' ).'" />\'+' ."\n";
                                                    $returnText .= '    \'</form>\'+' ."\n";        
                                                    $returnText .= '\'</div>\'+'."\n";
                                                    // Form Delete
                                                    if ((int)$map->usermarkersdelete == 1)
                                                    {
                                                            $returnText .= '\'<div id="contentDeletePlacemark">\'+'."\n";
                                                            $returnText .= '    \'<form id="deletePlacemarkForm'.$currentmarker->id.'" action="'.URI::current().'" method="post">\'+'."\n";
                                                            $returnText .= '    \'<input name="marker_action" type="hidden" value="delete" />\'+' ."\n";
                                                            $returnText .= '    \'<input name="markerid" type="hidden" value="'.$currentmarker->id.'" />\'+' ."\n";
                                                            $returnText .= '    \'<input name="contactid" type="hidden" value="'.$currentmarker->contactid.'" />\'+' ."\n";
                                                            $returnText .= '    \'<input name="markersubmit" type="submit" value="'.Text::_( 'COM_ZHOSMMAP_MAP_USER_BUTTON_DELETE' ).'" />\'+' ."\n";
                                                            $returnText .= '    \'</form>\'+' ."\n";        
                                                            $returnText .= '\'</div>\';'."\n";
                                                    }
                                                    else
                                                    {
                                                            $returnText .= '\'\';'."\n";
                                                    }

                                                    $returnText .= '  this.setPopupContent(contentStringPart1'.$currentmarker->id.'+';
                                                    $returnText .= 'contentInsertPlacemarkIcon.replace(/insertPlacemarkForm/g,"updatePlacemarkForm'. $currentmarker->id.'")';
                                                    $returnText .= '.replace(\'"markericonimage" src="\', \'"markericonimage" src="'.$imgpathIcons.str_replace("#", "%23", $currentmarker->icontype).'.png"\')';
                                                    $returnText .= '.replace(\'<option value="'.$currentmarker->icontype.'">'.$currentmarker->icontype.'</option>\', \'<option value="'.$currentmarker->icontype.'" selected="selected">'.$currentmarker->icontype.'</option>\')';
                                                    $returnText .= '+';
                                                    $returnText .= 'contentStringPart2'.$currentmarker->id.'+';
                                                    $returnText .= 'contentStringButtons'.$currentmarker->id;
                                                    $returnText .= ');' ."\n";
                                                    
                                                    $returnText .= '  this.openPopup();' ."\n";

                                                    $returnText .= '  });' ."\n";

                                                    $returnText .= '  marker'. $currentmarker->id.'.on(\'drag\', function(event) {' ."\n";

                                                    //$returnText .= '    latlng'. $currentmarker->id.' = event.latLng;';

                                                    $returnText .= '  });' ."\n";


                                    }

                                    // If user can change placemark - override content string - end

                                    if ($zhomObjectManager != 0)
                                    {
                                            // fix 07.02.2020 - only if management is enabled
                                            // fix for 19.02.2013
                                            //  if not managed placemarks (not enabled)
                                            if ((isset($map->markergroupcontrol) && (int)$map->markergroupcontrol != 0) 
                                             && (isset($map->markergroupctlmarker) && (int)$map->markergroupctlmarker != 0))
                                            {
                                                    $returnText .= '  zhomObjMgr'.$mapDivSuffix.'.PlacemarkAdd('.$currentmarker->markergroup.', '. $currentmarker->id.', marker'. $currentmarker->id.', null);'."\n";
                                            }
                                            else
                                            {                                    
                                                    // 22.08.2014 placemarks in clusters, therefore not only 0-cluster
                                                    if ((isset($map->markercluster) && (int)$map->markercluster == 1))
                                                    {
                                                            if ((isset($map->markerclustergroup) && (int)$map->markerclustergroup == 1))
                                                            {
                                                                    $returnText .= '  zhomObjMgr'.$mapDivSuffix.'.PlacemarkAdd('.$currentmarker->markergroup.', '. $currentmarker->id.', marker'. $currentmarker->id.', null);'."\n";
                                                            }
                                                            else
                                                            {
                                                                    $returnText .= '  zhomObjMgr'.$mapDivSuffix.'.PlacemarkAdd(0, '. $currentmarker->id.', marker'. $currentmarker->id.', null);'."\n";
                                                            }
                                                    }
                                                    else
                                                    {
                                                            if ((isset($map->markerclustergroup) && (int)$map->markerclustergroup == 1))
                                                            {
                                                                    $returnText .= '  zhomObjMgr'.$mapDivSuffix.'.PlacemarkAdd('.$currentmarker->markergroup.', '. $currentmarker->id.', marker'. $currentmarker->id.', null);'."\n";
                                                            }
                                                            else
                                                            {
                                                                    // 28.04.2020 bugfix
                                                                    // disable clusterer
                                                                    // enable placemark control
                                                                    // disable group control
                                                                    $returnText .= '  zhomObjMgr'.$mapDivSuffix.'.PlacemarkAdd(0, '. $currentmarker->id.', marker'. $currentmarker->id.', null);'."\n";
                                                            }
                                                    }
                                                    // /////
                                            }
                                    }

                                    // add animation after it added on map 
                                    if ((int)$currentmarker->baloon == 2
                                     || (int)$currentmarker->baloon == 22
                                     || (int)$currentmarker->baloon == 52
                                    ) 
                                    {
                                        $returnText .= 'marker'.$currentmarker->id.'.setBouncingOptions({';
                                        $returnText .= 'exclusive: false,';
                                        $returnText .= 'elastic: false';
                                        $returnText .= '});'."\n";
                                        $returnText .= 'marker'. $currentmarker->id.'.bounce();'."\n";                                          
                                    }     
                                    else if ((int)$currentmarker->baloon == 4
                                          || (int)$currentmarker->baloon == 24
                                          || (int)$currentmarker->baloon == 54
                                    )
                                    {
                                        $returnText .= 'marker'.$currentmarker->id.'.setBouncingOptions({';
                                        $returnText .= 'exclusive: false,';
                                        $returnText .= 'elastic: true';
                                        $returnText .= '});'."\n";
                                        $returnText .= 'marker'. $currentmarker->id.'.bounce();'."\n";                                                            
                                    }

                                    //
                                    // Generate list elements for each marker.
                                    $returnText .= MapPlacemarksHelper::get_placemarklist_string(
                                                                            0,
                                                                            $mapDivSuffix, 
                                                                            $currentmarker, 
                                                                            $markerlistcssstyle,
                                                                            $map->markerlistpos,
                                                                            $map->markerlistcontent,
                                                                            $map->markerlistaction,
                                                                            $imgpathIcons);
                                    // Generating Placemark List - End
                            }

                            // Change Map center and set Center Placemark Action
                            if ($currentPlacemarkCenter != "do not change")
                            {
                                    if ((int)$currentPlacemarkCenter == $currentmarker->id)
                                    {
                                            $returnText .= 'map'.$mapDivSuffix.'.setView(latlng'.(int)$currentPlacemarkCenter.', map'.$mapDivSuffix.'.getZoom());'."\n";
                                            $returnText .= 'latlng'.$mapDivSuffix.' = latlng'.(int)$currentPlacemarkCenter.';'."\n";
                                            $returnText .= 'routedestination'.$mapDivSuffix.' = latlng'.$mapDivSuffix.';'."\n";
                                    }
                            }


                            if ($currentPlacemarkActionID != "do not change")
                            {
                                    if ((int)$currentPlacemarkActionID == $currentmarker->id)
                                    {

                                            if ($currentPlacemarkAction != "")
                                            {
                                                    $currentPlacemarkExecuteArray = explode(";", $currentPlacemarkAction);

                                                    for($i = 0; $i < count($currentPlacemarkExecuteArray); $i++) 
                                                    {
                                                            switch (strtolower(trim($currentPlacemarkExecuteArray[$i])))
                                                            {
                                                                    case "":
                                                                       // null
                                                                    break;
                                                                    case "do not change":
                                                                            // do not change
                                                                    break;
                                                                    case "click":
                                                                        /*
                                                                        if ((isset($map->markercluster) && (int)$map->markercluster == 1))
                                                                        {
                                                                            if ((isset($map->markerclustergroup) && (int)$map->markerclustergroup == 1))
                                                                            {
                                                                                    $scripttext_pm_action .= 'markerCluster'.$currentmarker->markergroup.'.fire("click", marker'.$currentmarker->id.');'."\n";
                                                                            }
                                                                            else
                                                                            {
                                                                                    $scripttext_pm_action .= 'markerCluster0.fire("click", marker'.$currentmarker->id.');'."\n";
                                                                               }
                                                                        }
                                                                        else
                                                                        {

                                                                        */
                                                                            $scripttext_pm_action .= '  marker'.$currentmarker->id.'.fire("click");' ."\n";
                                                                        //}
                                                                    break;
                                                                    case "exclusive elastic bounce":
                                                                            $scripttext_pm_action .= 'marker'.$currentmarker->id.'.setBouncingOptions({';
                                                                            $scripttext_pm_action .= 'exclusive: true,';
                                                                            $scripttext_pm_action .= 'elastic: true';
                                                                            $scripttext_pm_action .= '});'."\n";
                                                                            $scripttext_pm_action .= 'marker'.$currentmarker->id.'.bounce();'."\n";
                                                                    break;
                                                                    case "elastic bounce":
                                                                            $scripttext_pm_action .= 'marker'.$currentmarker->id.'.setBouncingOptions({';
                                                                            $scripttext_pm_action .= 'exclusive: false,';
                                                                            $scripttext_pm_action .= 'elastic: true';
                                                                            $scripttext_pm_action .= '});'."\n";
                                                                            $scripttext_pm_action .= 'marker'.$currentmarker->id.'.bounce();'."\n";
                                                                    break;
                                                                    case "exclusive bounce":
                                                                            $scripttext_pm_action .= 'marker'.$currentmarker->id.'.setBouncingOptions({';
                                                                            $scripttext_pm_action .= 'exclusive: true,';
                                                                            $scripttext_pm_action .= 'elastic: false';
                                                                            $scripttext_pm_action .= '});'."\n";
                                                                            $scripttext_pm_action .= 'marker'.$currentmarker->id.'.bounce();'."\n";
                                                                    break;
                                                                    case "bounce":
                                                                            $scripttext_pm_action .= 'marker'.$currentmarker->id.'.setBouncingOptions({';
                                                                            $scripttext_pm_action .= 'exclusive: false,';
                                                                            $scripttext_pm_action .= 'elastic: false';
                                                                            $scripttext_pm_action .= '});'."\n";
                                                                            $scripttext_pm_action .= 'marker'.$currentmarker->id.'.bounce();'."\n";
                                                                    break;
                                                                    default:
                                                                            $scripttext_pm_action .= 'marker'.$currentmarker->id.'.setIcon("'.$imgpathIcons.str_replace("#", "%23", trim($currentPlacemarkExecuteArray[$i])).'.png");'."\n";
                                                                    break;
                                                            }
                                                    }
                                            }
                                    }

                            }                    

                            if ((int)$currentmarker->openbaloon == 1)
                            {
                                    $lastmarker2open = $currentmarker;
                            }

                            // End marker creation with lat,lng
                    }

            }


    }
    // End restriction