Your IP : 216.73.216.240


Current Path : /home/juvelize/www/administrator/components/com_zhgooglemap/views/mapmap/tmpl/
Upload File :
Current File : /home/juvelize/www/administrator/components/com_zhgooglemap/views/mapmap/tmpl/edit.php

<?php
/*------------------------------------------------------------------------
# com_zhgooglemap - Zh GoogleMap
# ------------------------------------------------------------------------
# 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
defined('_JEXEC') or die('Restricted access');
JHtml::_('behavior.tooltip');
JHtml::_('behavior.formvalidation');
JHtml::_('formbehavior.chosen', 'select');

$document = JFactory::getDocument();

// Map Types
$maptypes = $this->mapTypeList;

$urlProtocol = "http";
if ($this->httpsprotocol != "")
{
    if ((int)$this->httpsprotocol == 0)
    {
        $urlProtocol = 'https';
    }
}

if ($this->map_height != "")
{
    if ((int)$this->map_height == 0)
    {
        $map_height = "420px";
        $map_height_wrap = "450px";
    }
    else
    {
        $map_height = ((int)$this->map_height - 30) . "px";
        $map_height_wrap = (int)$this->map_height . "px";
    }
}
else 
{
    $map_height = "420px";
    $map_height_wrap = "450px";
}


$mainScriptBegin = $urlProtocol.'://maps.googleapis.com/maps/api/js?';

$mainScriptMiddle = "";

$mainScriptEnd = "";

if ($this->mapapiversion != "")
{
    if ($mainScriptMiddle == "")
    {
        $mainScriptMiddle = 'v='.$this->mapapiversion;
    }
    else
    {
        $mainScriptMiddle .= '&v='.$this->mapapiversion;
    }

}

if ($this->mapapikey4map != "")
{
    if ($mainScriptMiddle == "")
    {
        $mainScriptMiddle = 'key='.$this->mapapikey4map;
    }
    else
    {
        $mainScriptMiddle .= '&key='.$this->mapapikey4map;
    }        

}

$mainScriptBegin .= $mainScriptMiddle;


$mainScriptLibrary ="";

if (1==2)
{
    if ($mainScriptLibrary == "")
    {
        $mainScriptLibrary .= '&libraries=places';
    }
    else
    {
        $mainScriptLibrary .= ',places';
    }
}

$mainScriptBegin .= $mainScriptLibrary;

$mainScript = $mainScriptBegin . $mainScriptEnd;

$document->addScript($mainScript);

?>
<form action="<?php echo JRoute::_('index.php?option=com_zhgooglemap&layout=edit&id='.(int) $this->item->id); ?>" method="post" name="adminForm" id="adminForm" class="form-validate">
<div class="span12 form-horizontal">

<div class="tabbable">
    <ul class="nav nav-pills">
        <li class="active"><a href="#tab0" data-toggle="tab"><?php echo JText::_('COM_ZHGOOGLEMAP_MAP_MAP'); ?></a></li>
        <li><a href="#tab1" data-toggle="tab"><?php echo JText::_('COM_ZHGOOGLEMAP_MAP_DETAIL'); ?></a></li>
        <li><a href="#tab2" data-toggle="tab"><?php echo JText::_('COM_ZHGOOGLEMAP_MAP_DECOR_HEADER'); ?></a></li>
        <li><a href="#tab3" data-toggle="tab"><?php echo JText::_('COM_ZHGOOGLEMAP_MAP_DECOR_FOOTER'); ?></a></li>
        <li><a href="#tab4" data-toggle="tab"><?php echo JText::_('COM_ZHGOOGLEMAP_MAP_DECOR_STYLE'); ?></a></li>
        <li><a href="#tab5" data-toggle="tab"><?php echo JText::_('COM_ZHGOOGLEMAP_MAP_MAPDECOR'); ?></a></li>
        <li><a href="#tab6" data-toggle="tab"><?php echo JText::_('COM_ZHGOOGLEMAP_MAP_MAPMARKER'); ?></a></li>
        <li><a href="#tab7" data-toggle="tab"><?php echo JText::_('COM_ZHGOOGLEMAP_MAP_DETAIL_PLACEMARKLIST'); ?></a></li>
        <li><a href="#tab8" data-toggle="tab"><?php echo JText::_('COM_ZHGOOGLEMAP_MAP_MAPMARKERGROUP'); ?></a></li>
        <li><a href="#tab9" data-toggle="tab"><?php echo JText::_('COM_ZHGOOGLEMAP_MAP_MAPROUTE'); ?></a></li>
        <li><a href="#tab10" data-toggle="tab"><?php echo JText::_('COM_ZHGOOGLEMAP_MAP_PLACES'); ?></a></li>
        <li><a href="#tab12" data-toggle="tab"><?php echo JText::_('COM_ZHGOOGLEMAP_MAP_MAPADVANCED'); ?></a></li>
        <li><a href="#tab13" data-toggle="tab"><?php echo JText::_('COM_ZHGOOGLEMAP_MAP_GEOLOCATION'); ?></a></li>
        <li><a href="#tab14" data-toggle="tab"><?php echo JText::_('COM_ZHGOOGLEMAP_MAPMARKER_DETAIL_INTEGRATION'); ?></a></li>
        <?php
        $fieldSets = $this->form->getFieldsets('params');
        foreach ($fieldSets as $name => $fieldSet) :
        ?>
        <li><a href="#params-<?php echo $name;?>" data-toggle="tab"><?php echo JText::_($fieldSet->label);?></a></li>
        <?php endforeach; ?>
    </ul>
 </div>
    <div class="tab-content">
    
        <div class="tab-pane active" id="tab0">
            <div>
                <fieldset class="adminform">
                
                    <?php foreach($this->form->getFieldset('mapmain') as $field): ?>
                        <div class="control-group">
                        <?php 
                            ?>
                            <div class="control-label">
                            <?php 
                                echo $field->label;
                            ?>
                            </div>
                            <div class="controls">
                            <?php 
                                echo $field->input;
                            ?>
                            </div>
                            <?php 
                        ?>
                        </div>

                    <?php endforeach; ?>
                
                </fieldset>
            
                <div>
                    <div id="mapDivWrapper" style="margin:0;padding:0;width:100%;height:<?php echo $map_height_wrap ?>">

                        <div id="GMapsID" style="margin:0;padding:0;width:100%;height:<?php echo $map_height ?>">

                        <?php 


                        $loadmodules    ='';

                        $document->addStyleSheet(JURI::root() .'administrator/components/com_zhgooglemap/assets/css/admin.css');


                        $mapDefLat = $this->mapDefLat;
                        $mapDefLng = $this->mapDefLng;

                        $mapMapTypeGoogle = $this->mapMapTypeGoogle;
                        $mapMapTypeOSM = $this->mapMapTypeOSM;
                        $mapMapTypeCustom = $this->mapMapTypeCustom;


                        //Script begin
                        $scripttext = '<script type="text/javascript" >//<![CDATA[' ."\n";


                            $scripttext .= 'var initialLocation;' ."\n";
                            $scripttext .= 'var spblocation;' ."\n";
                            $scripttext .= 'var browserSupportFlag =  new Boolean();' ."\n";
                            $scripttext .= 'var map;' ."\n";
                            $scripttext .= 'var infowindow;' ."\n";
                            $scripttext .= 'var marker;' ."\n";


                            $scripttext .= 'function initialize() {' ."\n";

                            $scripttext .= 'infowindow = new google.maps.InfoWindow();' ."\n";
                            
                            if ($mapDefLat != "" && $mapDefLng !="")
                            {
                                $scripttext .= 'spblocation = new google.maps.LatLng('.$mapDefLat.', '.$mapDefLng.');' ."\n";
                            }
                            else
                            {
                                $scripttext .= 'spblocation = new google.maps.LatLng(59.9388, 30.3158);' ."\n";
                            }

                            $scripttext .= 'var myOptions = {' ."\n";
                            $scripttext .= '    zoom: 14,' ."\n";
                            $scripttext .= '    mapTypeId: google.maps.MapTypeId.ROADMAP,' ."\n";
                            $scripttext .= '      panControl: true,' ."\n";
                            $scripttext .= '      scrollwheel: false,' ."\n";
                            $scripttext .= '      zoomControl: true,' ."\n";
                            $scripttext .= '      zoomControlOptions: {' ."\n";
                            $scripttext .= '            position: google.maps.ControlPosition.LEFT_TOP,' ."\n";
                            $scripttext .= '            style: google.maps.ZoomControlStyle.DEFAULT' ."\n";
                            $scripttext .= '          },' ."\n";
                            $scripttext .= '      mapTypeControl: true,' ."\n";
                            $scripttext .= '      mapTypeControlOptions: {' ."\n";
                            $scripttext .= '      mapTypeIds: [' ."\n";

                            $curr_maptype_list = '';
                            
                            if ((int)$mapMapTypeGoogle != 0
                              || ((int)$mapMapTypeCustom == 0
                                 && (int)$mapMapTypeOSM == 0))
                            {
                                $curr_maptype_list .= '      google.maps.MapTypeId.ROADMAP,' ."\n";
                                $curr_maptype_list .= '      google.maps.MapTypeId.TERRAIN,' ."\n";
                                $curr_maptype_list .= '      google.maps.MapTypeId.SATELLITE,' ."\n";
                                $curr_maptype_list .= '      google.maps.MapTypeId.HYBRID' ."\n";
                            }

                            if ((int)$mapMapTypeOSM != 0)
                            {
                                if ($curr_maptype_list == '')
                                {
                                    $curr_maptype_list .= '     \'osm\'' ."\n";
                                }
                                else
                                {
                                    $curr_maptype_list .= '     ,\'osm\'' ."\n";
                                }
                            }
                            
                            if ((int)$mapMapTypeCustom != 0)
                            {
                                // Custom Map Type - part 0 (add to list) - begin
                                foreach ($maptypes as $key => $currentmaptype) 
                                {
                                    if ($currentmaptype->gettileurl != "")
                                    {
                                        if ($curr_maptype_list == '')
                                        {
                                            $curr_maptype_list .= '      \'customMapType'.$currentmaptype->id.'\'' ."\n";
                                        }
                                        else
                                        {
                                            $curr_maptype_list .= '      ,\'customMapType'.$currentmaptype->id.'\'' ."\n";
                                        }
                                    }
                                }
                                // Custom Map Type - part 0 (add to list) - end
                            }

                            $scripttext .= $curr_maptype_list;

                            $scripttext .= '    ]' ."\n";
                            $scripttext .= '      },' ."\n";
                            $scripttext .= '      scaleControl: false,' ."\n";
                            $scripttext .= '      streetViewControl: false,' ."\n";
                            $scripttext .= '      rotateControl: false,' ."\n";
                            $scripttext .= '      overviewMapControl: true' ."\n";

                            $scripttext .= '  };' ."\n";
                                
                            if ((int)$mapMapTypeOSM != 0)
                            {
                                $scripttext .= ' var openStreetType = new google.maps.ImageMapType({' ."\n";
                                $scripttext .= '  getTileUrl: function(ll, z) {' ."\n";
                                $scripttext .= '    var X = ll.x % (1 << z);  // wrap' ."\n";
                                $scripttext .= '    return "'.$urlProtocol.'://tile.openstreetmap.org/" + z + "/" + X + "/" + ll.y + ".png";' ."\n";
                                $scripttext .= '  },' ."\n";
                                $scripttext .= '  tileSize: new google.maps.Size(256, 256),' ."\n";
                                $scripttext .= '  isPng: true,' ."\n";
                                $scripttext .= '  maxZoom: 18,' ."\n";
                                $scripttext .= '  name: "OSM",' ."\n";
                                $scripttext .= '  alt: "'.JText::_('COM_ZHGOOGLEMAP_MAP_OPENSTREETLAYER').'"' ."\n";
                                $scripttext .= '}); ' ."\n";
                            }

                            if ((int)$mapMapTypeCustom != 0)
                            {
                                // Custom Map Type - part 1 (define) - begin
                                foreach ($maptypes as $key => $currentmaptype)     
                                {
                                
                                    if ($currentmaptype->gettileurl != "")
                                    {

                                        $scripttext .= ' var customMapType'.$currentmaptype->id.' = new google.maps.ImageMapType({' ."\n";
                                        $scripttext .= '  getTileUrl: '.$currentmaptype->gettileurl.',' ."\n";
                                        $scripttext .= '  tileSize: new google.maps.Size('.$currentmaptype->tilewidth.', '.$currentmaptype->tileheight.'),' ."\n";
                                        if ((int)$currentmaptype->ispng == 1)
                                        {
                                            $scripttext .= '  isPng: true,' ."\n";
                                        }
                                        else
                                        {
                                            $scripttext .= '  isPng: false,' ."\n";
                                        }
                                        if ((int)$currentmaptype->minzoom != 0)
                                        {
                                            $scripttext .= '  minZoom: '.(int)$currentmaptype->minzoom.',' ."\n";
                                        }
                                        if ((int)$currentmaptype->maxzoom != 0)
                                        {
                                            $scripttext .= '  maxZoom: '.(int)$currentmaptype->maxzoom.',' ."\n";
                                        }
                                        if ($currentmaptype->opacity != "")
                                        {
                                            $scripttext .= '  opacity: '.$currentmaptype->opacity.','."\n";
                                        }
                                        $scripttext .= '  name: "'.str_replace('"','', $currentmaptype->title).'",' ."\n";
                                        $scripttext .= '  alt: "'.str_replace('"','', $currentmaptype->description).'",' ."\n";
                                        $scripttext .= '}); ' ."\n";
                                        
                                        // Add projection
                                        if ($currentmaptype->fromlatlngtopoint != "" && $currentmaptype->frompointtolatlng != "")
                                        {
                                            $scripttext .= $currentmaptype->projectionglobal."\n";
                                            
                                            $scripttext .= ' function customMapTypeProjection'.$currentmaptype->id.'() {'."\n";
                                            $scripttext .= $currentmaptype->projectiondefinition."\n";
                                            $scripttext .= ' }'."\n";
                                            
                                            $scripttext .= ' customMapTypeProjection'.$currentmaptype->id.'.prototype.fromLatLngToPoint  = ';
                                            $scripttext .= $currentmaptype->fromlatlngtopoint."\n";
                                            $scripttext .= ';'."\n";

                                            $scripttext .= ' customMapTypeProjection'.$currentmaptype->id.'.prototype.fromPointToLatLng = ';
                                            $scripttext .= $currentmaptype->frompointtolatlng."\n";
                                            $scripttext .= ';'."\n";
                                            
                                            $scripttext .= ' customMapType'.$currentmaptype->id.'.projection  = new customMapTypeProjection'.$currentmaptype->id.'();' ."\n";
                                        }

                                    }
                                
                                }
                                // Custom Map Type - part 1 (define) - end
                            }
                            
                            $scripttext .= '    map = new google.maps.Map(document.getElementById("GMapsID"), myOptions);' ."\n";

                            if ((int)$mapMapTypeOSM != 0)
                            {
                                $scripttext .= ' map.mapTypes.set(\'osm\', openStreetType);' ."\n";
                                if (((int)$mapMapTypeOSM == 2)
                                 || ((int)$mapMapTypeGoogle == 0
                                    && (int)$mapMapTypeCustom == 0))
                                {
                                    $scripttext .= '    map.setMapTypeId(\'osm\');' ."\n";
                                }
                            }

                            if ((int)$mapMapTypeCustom != 0)
                            {
                                // Custom Map Type - part 2 (bind) - begin
                                foreach ($maptypes as $key => $currentmaptype)     
                                {
                                    if ($currentmaptype->gettileurl != "")
                                    {
                                        $scripttext .= ' map.mapTypes.set(\'customMapType'.$currentmaptype->id.'\', customMapType'.$currentmaptype->id.');' ."\n";    
                                        if (((int)$mapMapTypeCustom == 2)
                                            || ((int)$mapMapTypeGoogle == 0
                                                && (int)$mapMapTypeOSM == 0))
                                        {
                                            $scripttext .= '    map.setMapTypeId(\'customMapType'.$currentmaptype->id.'\', customMapType'.$currentmaptype->id.');' ."\n";
                                        }
                                    }
                                }
                                // Custom Map Type - part 2 (bind) - end
                            }
                            
                            
                            if (isset($this->item->mapbounds) && $this->item->mapbounds != "")
                            {
                                $mapSearchBoundsArray = explode(";", str_replace(',',';',$this->item->mapbounds));
                                if (count($mapSearchBoundsArray) != 4)
                                {
                                    //
                                }
                                else
                                {
                                    $scripttext .= ' var rectangleBounds = '."\n";
                                    $scripttext .=' new google.maps.LatLngBounds(new google.maps.LatLng('.str_replace(";","), new google.maps.LatLng(", $this->item->mapbounds).')) '."\n";
                                    $scripttext .= '; '."\n";
                                    $scripttext .= ' var plPath = new google.maps.Rectangle({'."\n";
                                    $scripttext .= ' bounds: rectangleBounds'."\n";
                                    $scripttext .= ',clickable: false'."\n";
                                    //$scripttext .= ',strokeColor: "'.$currentpath->color.'"'."\n";
                                    //$scripttext .= ',strokeOpacity: '.$currentpath->opacity."\n";
                                    //$scripttext .= ',strokeWeight: '.$currentpath->weight."\n";
                                    $scripttext .= ' });'."\n";

                                    $scripttext .= 'plPath.setMap(map);'."\n";

                                }
                            }                                

                            
                            if (isset($this->item->latitude) && isset($this->item->longitude) )
                            {
                                $scripttext .= 'initialLocation = new google.maps.LatLng('.$this->item->latitude.', ' .$this->item->longitude.');' ."\n";
                                    $scripttext .= '  map.setCenter(initialLocation);' ."\n";

                                $scripttext .= '  marker = new google.maps.Marker({' ."\n";
                                $scripttext .= '      position: initialLocation, ' ."\n";
                                $scripttext .= '      draggable:true, ' ."\n";
                                $scripttext .= '      map: map, ' ."\n";
                                $scripttext .= '      animation: google.maps.Animation.DROP,' ."\n";
                                // Replace to new, because all charters are shown
                                //$scripttext .= '      title:"'.htmlspecialchars(str_replace('\\', '/', $this->item->title) , ENT_QUOTES, 'UTF-8').'"' ."\n";        
                                $scripttext .= '      title:"'.str_replace('\\', '/', str_replace('"', '\'\'', $this->item->title)).'"' ."\n";
                                $scripttext .= '});'."\n";

                                $scripttext .= '    google.maps.event.addListener(marker, \'drag\', function(event) {' ."\n";
                                $scripttext .= '    document.forms.adminForm.jform_longitude.value = event.latLng.lng();' ."\n";
                                $scripttext .= '    document.forms.adminForm.jform_latitude.value = event.latLng.lat();' ."\n";
                                $scripttext .= '    });' ."\n";
                                
                                $scripttext .= '    google.maps.event.addListener(map, \'click\', function(event) {' ."\n";
                                $scripttext .= '    marker.setPosition(event.latLng);' ."\n";
                                $scripttext .= '    document.forms.adminForm.jform_longitude.value = event.latLng.lng();' ."\n";
                                $scripttext .= '    document.forms.adminForm.jform_latitude.value = event.latLng.lat();' ."\n";
                                $scripttext .= '    });' ."\n";

                            }
                            else
                            {
                                $scripttext .= 'initialLocation = spblocation;' ."\n";
                                    $scripttext .= '  map.setCenter(initialLocation);' ."\n";

                                $scripttext .= '  marker = new google.maps.Marker({' ."\n";
                                $scripttext .= '      position: initialLocation, ' ."\n";
                                $scripttext .= '      draggable:true, ' ."\n";
                                $scripttext .= '      map: map, ' ."\n";
                                $scripttext .= '      animation: google.maps.Animation.DROP,' ."\n";
                                // Replace to new, because all charters are shown
                                //$scripttext .= '      title:"'.htmlspecialchars(str_replace('\\', '/', $this->item->title) , ENT_QUOTES, 'UTF-8').'"' ."\n";        
                                $scripttext .= '      title:"'.str_replace('\\', '/', str_replace('"', '\'\'', $this->item->title)).'"' ."\n";
                                $scripttext .= '});'."\n";

                                $scripttext .= '    google.maps.event.addListener(marker, \'drag\', function(event) {' ."\n";
                                $scripttext .= '    document.forms.adminForm.jform_longitude.value = event.latLng.lng();' ."\n";
                                $scripttext .= '    document.forms.adminForm.jform_latitude.value = event.latLng.lat();' ."\n";
                                $scripttext .= '    });' ."\n";
                                
                                $scripttext .= '    google.maps.event.addListener(map, \'click\', function(event) {' ."\n";
                                $scripttext .= '    marker.setPosition(event.latLng);' ."\n";
                                $scripttext .= '    document.forms.adminForm.jform_longitude.value = event.latLng.lng();' ."\n";
                                $scripttext .= '    document.forms.adminForm.jform_latitude.value = event.latLng.lat();' ."\n";
                                $scripttext .= '    });' ."\n";

                                $scripttext .= '    map.setCenter(initialLocation);' ."\n";
                            $scripttext .= '    marker.setPosition(initialLocation);' ."\n";
                                    $scripttext .= '      // Try W3C Geolocation method (Preferred)' ."\n";
                                    $scripttext .= '      if(navigator.geolocation) {' ."\n";
                                    $scripttext .= '        browserSupportFlag = true;' ."\n";
                                    $scripttext .= '        navigator.geolocation.getCurrentPosition(function(position) {' ."\n";
                                    $scripttext .= '          initialLocation = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);' ."\n";
                                $scripttext .= '    map.setCenter(initialLocation);' ."\n";
                            $scripttext .= '    marker.setPosition(initialLocation);' ."\n";
                                    //$scripttext .= '          contentString = "Location found using W3C standard";' ."\n";
                                    //$scripttext .= '          infowindow.setContent(contentString);' ."\n";
                                    //$scripttext .= '          infowindow.setPosition(initialLocation);' ."\n";
                                    //$scripttext .= '          infowindow.open(map);' ."\n";
                                    $scripttext .= '        }, function() {' ."\n";
                                    $scripttext .= '          handleNoGeolocation(browserSupportFlag);' ."\n";
                                    $scripttext .= '        });' ."\n";
                                    $scripttext .= '      } else if (google.gears) {' ."\n";
                                    $scripttext .= '        // Try Google Gears Geolocation' ."\n";
                                    $scripttext .= '        browserSupportFlag = true;' ."\n";
                                    $scripttext .= '        var geo = google.gears.factory.create(\'beta.geolocation\');' ."\n";
                                    $scripttext .= '        geo.getCurrentPosition(function(position) {' ."\n";
                                    $scripttext .= '          initialLocation = new google.maps.LatLng(position.latitude,position.longitude);' ."\n";
                                $scripttext .= '    map.setCenter(initialLocation);' ."\n";
                            $scripttext .= '    marker.setPosition(initialLocation);' ."\n";
                                    //$scripttext .= '          contentString = "Location found using Google Gears";' ."\n";
                                    //$scripttext .= '          infowindow.setContent(contentString);' ."\n";
                                    //$scripttext .= '          infowindow.setPosition(initialLocation);' ."\n";
                                    //$scripttext .= '          infowindow.open(map);' ."\n";
                                    $scripttext .= '        }, function() {' ."\n";
                                    $scripttext .= '          handleNoGeolocation(browserSupportFlag);' ."\n";
                                    $scripttext .= '        });' ."\n";
                                    $scripttext .= '      } else {' ."\n";
                                    $scripttext .= '        // Browser doesn\'t support Geolocation' ."\n";
                                    $scripttext .= '        browserSupportFlag = false;' ."\n";
                                    $scripttext .= '        handleNoGeolocation(browserSupportFlag);' ."\n";
                                    $scripttext .= '      }' ."\n";
                            }


                        // end initialize    
                        $scripttext .= '};' ."\n";

                        $scripttext .= 'function handleNoGeolocation(errorFlag) {' ."\n";
                        $scripttext .= '  if (errorFlag == true) {' ."\n";
                        $scripttext .= '    initialLocation = spblocation;' ."\n";
                        //$scripttext .= '    contentString = "Error: The Geolocation service failed.";' ."\n";
                        $scripttext .= '  } else {' ."\n";
                        $scripttext .= '    initialLocation = spblocation;' ."\n";
                        //$scripttext .= '    contentString = "Error: Your browser doesn\'t support geolocation.";' ."\n";
                        $scripttext .= '  }' ."\n";
                        $scripttext .= '  map.setCenter(initialLocation);' ."\n";
                        $scripttext .= '  marker.setPosition(initialLocation);' ."\n";
                        //$scripttext .= '  infowindow.setContent(contentString);' ."\n";
                        //$scripttext .= '  infowindow.setPosition(initialLocation);' ."\n";
                        //$scripttext .= '  infowindow.open(map);' ."\n";
                        $scripttext .= '};' ."\n";


                        $scripttext .= ' function addLoadEvent(func) {' ."\n";
                        $scripttext .= '  var oldonload = window.onload;' ."\n";
                        $scripttext .= '  if (typeof window.onload != \'function\') {' ."\n";
                        $scripttext .= '    window.onload = func;' ."\n";
                        $scripttext .= '  } else {' ."\n";
                        $scripttext .= '    window.onload = function() {' ."\n";
                        $scripttext .= '      if (oldonload) {' ."\n";
                        $scripttext .= '        oldonload();' ."\n";
                        $scripttext .= '      }' ."\n";
                        $scripttext .= '      func();' ."\n";
                        $scripttext .= '    }' ."\n";
                        $scripttext .= '  }' ."\n";
                        $scripttext .= '}    ' ."\n";    

                        $scripttext .= 'addLoadEvent(initialize);' ."\n";
                            
                        $scripttext .= '//]]></script>' ."\n";
                        // Script end


                        echo $scripttext;

                        ?>
                        </div>
                        <?php
                            $credits ='<div>'."\n";
                            if ((int)$mapMapTypeOSM != 0)
                            {
                                $credits .= 'OSM '.JText::_('COM_ZHGOOGLEMAP_MAP_POWEREDBY').': ';
                                $credits .= '<a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> '.JText::_('COM_ZHGOOGLEMAP_MAP_CONTRIBUTORS')."\n";
                            }
                            $credits .='</div>'."\n";
                        echo $credits;
                        ?>

                        
                    </div>
                </div>
            </div>
        </div>


            
    
        <div class="tab-pane" id="tab1">
            <fieldset class="adminform">
                
                    <?php foreach($this->form->getFieldset('details') as $field): ?>
                        <div class="control-group">
                        <?php 
                        if ($field->id == 'jform_weathertypeid')
                        {
                            ?>
                            <div class="control-label">
                            <?php 
                                echo $field->label;
                            ?>
                            </div>
                            <div class="controls">
                            <?php 
                                array_unshift($this->mapWeatherTypeList, JHTML::_('select.option', '0', JText::_( 'COM_ZHGOOGLEMAP_MAP_DETAIL_WEATHERTYPEID_NO'), 'value', 'text')); 
                                echo JHTML::_( 'select.genericlist', $this->mapWeatherTypeList, 'jform[weathertypeid]',  'class="inputbox required" size="1"', 'value', 'text', (int)$this->item->weathertypeid, 'jform_weathertypeid');
                            ?>
                            </div>
                            <?php 
                            //echo $field->label;
                            //echo $field->input;
                        }
                        else if ($field->id == 'jform_catid')
                        {
                            if ($this->categoryListType == 1)
                            {
                                ?>
                                <div class="control-label">
                                <?php 
                                    echo $field->label;
                                ?>
                                </div>
                                <div class="controls">
                                <?php 
                                    array_unshift($this->categoryList, JHTML::_('select.option', '', JText::_( 'JOPTION_SELECT_CATEGORY'), 'value', 'text')); 
                                    echo JHTML::_( 'select.genericlist', $this->categoryList, 'jform[catid]',  'class="inputbox" size="1"', 'value', 'text', (int)$this->item->catid, 'jform_catid');
                                    //echo $field->label;
                                    //echo $field->input;
                                ?>
                                </div>
                                <?php 
                            }
                                else
                                {
                                ?>
                                <div class="control-label">
                                <?php 
                                    echo $field->label;
                                ?>
                                </div>
                                <div class="controls">
                                <?php 
                                    echo $field->input;
                                ?>
                                </div>
                                <?php 
                            }
                        }
                        else
                        {
                            ?>
                            <div class="control-label">
                            <?php 
                                echo $field->label;
                            ?>
                            </div>
                            <div class="controls">
                            <?php 
                                echo $field->input;
                            ?>
                            </div>
                            <?php 
                        }
                        ?>
                        </div>

                    <?php endforeach; ?>
                
            </fieldset>
        </div>
        <div class="tab-pane" id="tab2">
            <fieldset class="adminform">
                
                    <?php foreach($this->form->getFieldset('mapdecorheader') as $field): ?>
                        <div class="control-group">
                        <?php 
                        if ($field->id == 'jform_headerhtml')
                        {
                            echo '<div class="clr"></div>';
                            ?>
                            <div class="control-label">
                            <?php 
                                echo $field->label;
                            ?>
                            </div>
                            <div class="controls">
                            <?php 
                                echo '<div class="clr"></div>';
                                echo $field->input;
                            ?>
                            </div>
                            <?php 
                        }
                        else
                        {
                            ?>
                            <div class="control-label">
                            <?php 
                                echo $field->label;
                            ?>
                            </div>
                            <div class="controls">
                            <?php 
                                echo $field->input;
                            ?>
                            </div>
                            <?php 
                        }
                        ?>
                        </div>
                    <?php endforeach; ?>
                
            </fieldset>
        </div>
        <div class="tab-pane" id="tab3">
            <fieldset class="adminform">
                
                    <?php foreach($this->form->getFieldset('mapdecorfooter') as $field): ?>
                        <div class="control-group">
                        <?php 
                        if ($field->id == 'jform_footerhtml')
                        {
                            echo '<div class="clr"></div>';
                            ?>
                            <div class="control-label">
                            <?php 
                                echo $field->label;
                            ?>
                            </div>
                            <div class="controls">
                            <?php 
                                echo '<div class="clr"></div>';
                                echo $field->input;
                            ?>
                            </div>
                            <?php 
                        }
                        else
                        {
                            ?>
                            <div class="control-label">
                            <?php 
                                echo $field->label;
                            ?>
                            </div>
                            <div class="controls">
                            <?php 
                                echo $field->input;
                            ?>
                            </div>
                            <?php 
                        }
                        ?>
                        </div>
                    <?php endforeach; ?>
                
            </fieldset>
        </div>
        <div class="tab-pane" id="tab4">
            <fieldset class="adminform">
                
                    <?php foreach($this->form->getFieldset('mapdecorstyle') as $field): ?>
                        <div class="control-group">
                        <?php 
                            ?>
                            <div class="control-label">
                            <?php 
                                echo $field->label;
                            ?>
                            </div>
                            <div class="controls">
                            <?php 
                                echo $field->input;
                            ?>
                            </div>
                            <?php 
                        ?>
                        </div>
                    <?php endforeach; ?>
                
            </fieldset>
        </div>
        <div class="tab-pane" id="tab5">
            <?php echo JHtml::_('sliders.start', 'mapmap-slider-mapcontrols'); ?>

            <?php echo JHtml::_('sliders.panel', JText::_('COM_ZHGOOGLEMAP_MAP_MAPDECOR'), 'map-controls');?>
                <fieldset class="adminform">
                    
                        <?php foreach($this->form->getFieldset('mapdecor') as $field): ?>
                            <div class="control-group">
                            <?php 
                                ?>
                                <div class="control-label">
                                <?php 
                                    echo $field->label;
                                ?>
                                </div>
                                <div class="controls">
                                <?php 
                                    echo $field->input;
                                ?>
                                </div>
                                <?php 
                            ?>
                            </div>
                        <?php endforeach; ?>
                    
                </fieldset>
            <?php echo JHtml::_('sliders.panel', JText::_('COM_ZHGOOGLEMAP_MAP_GEOFINDCONTROL'), 'map-findcontrol');?>
            <fieldset class="adminform">
            
                <?php foreach($this->form->getFieldset('mapcontrolgeofind') as $field): ?>
                    <div class="control-group">
                    <?php 
                        ?>
                        <div class="control-label">
                        <?php 
                            echo $field->label;
                        ?>
                        </div>
                        <div class="controls">
                        <?php 
                            echo $field->input;
                        ?>
                        </div>
                        <?php 
                    ?>
                    </div>
                <?php endforeach; ?>
            
            </fieldset>

            <?php echo JHtml::_('sliders.panel', JText::_('COM_ZHGOOGLEMAP_MAP_MAPPOSITION'), 'control-positions');?>
            <fieldset class="adminform">
            
                <?php foreach($this->form->getFieldset('positions') as $field): ?>
                    <div class="control-group">
                    <?php 
                        ?>
                        <div class="control-label">
                        <?php 
                            echo $field->label;
                        ?>
                        </div>
                        <div class="controls">
                        <?php 
                            echo $field->input;
                        ?>
                        </div>
                        <?php 
                    ?>
                    </div>
                <?php endforeach; ?>
            
            </fieldset>
            <?php echo JHtml::_('sliders.end'); ?>
        </div>
        <div class="tab-pane" id="tab6">
            <fieldset class="adminform">
                
                    <?php foreach($this->form->getFieldset('mapmarker') as $field): ?>
                        <div class="control-group">
                        <?php 
                                ?>
                                <div class="control-label">
                                <?php 
                                    echo $field->label;
                                ?>
                                </div>
                                <div class="controls">
                                <?php 
                                    echo $field->input;
                                ?>
                                </div>
                                <?php 
                        ?>
                        </div>
                    <?php endforeach; ?>
                
            </fieldset>
        </div>
        <div class="tab-pane" id="tab7">
            <fieldset class="adminform">
                
                    <?php foreach($this->form->getFieldset('mapmarkerlist') as $field): ?>
                        <div class="control-group">
                        <?php 
                            ?>
                            <div class="control-label">
                            <?php 
                                echo $field->label;
                            ?>
                            </div>
                            <div class="controls">
                            <?php 
                                echo $field->input;
                            ?>
                            </div>
                            <?php 
                        ?>
                        </div>
                    <?php endforeach; ?>
                
            </fieldset>
        </div>
        <div class="tab-pane" id="tab8">
            
            <fieldset class="adminform">
                
                    <?php foreach($this->form->getFieldset('mapmarkergroup') as $field): ?>
                        <div class="control-group">
                        <?php 
                            ?>
                            <div class="control-label">
                            <?php 
                                echo $field->label;
                            ?>
                            </div>
                            <div class="controls">
                            <?php 
                                echo $field->input;
                            ?>
                            </div>
                            <?php 
                        ?>
                        </div>
                    <?php endforeach; ?>
                
            </fieldset>
        </div>
        <div class="tab-pane" id="tab9">
            
            <fieldset class="adminform">
                
                    <?php foreach($this->form->getFieldset('maproute') as $field): ?>
                        <div class="control-group">
                        <?php 
                            ?>
                            <div class="control-label">
                            <?php 
                                echo $field->label;
                            ?>
                            </div>
                            <div class="controls">
                            <?php 
                                echo $field->input;
                            ?>
                            </div>
                            <?php 
                        ?>
                        </div>
                    <?php endforeach; ?>
                
            </fieldset>
        </div>
        <div class="tab-pane" id="tab10">
            
            <fieldset class="adminform">
                
                    <?php foreach($this->form->getFieldset('mapplaces') as $field): ?>
                        <div class="control-group">
                        <?php 
                            ?>
                            <div class="control-label">
                            <?php 
                                echo $field->label;
                            ?>
                            </div>
                            <div class="controls">
                            <?php 
                                echo $field->input;
                            ?>
                            </div>
                            <?php 
                        ?>
                        </div>
                    <?php endforeach; ?>
                
            </fieldset>
        </div>

        <div class="tab-pane" id="tab12">
            
            <fieldset class="adminform">
                
                    <?php foreach($this->form->getFieldset('mapadvanced') as $field): ?>
                        <div class="control-group">
                        <?php 
                        if ($field->id == 'jform_streetviewstyleid')
                        {
                            ?>
                            <div class="control-label">
                            <?php 
                                echo $field->label;
                            ?>
                            </div>
                            <div class="controls">
                            <?php 
                                array_unshift($this->mapStreetViewList, JHTML::_('select.option', '0', JText::_( 'COM_ZHGOOGLEMAP_MAP_DETAIL_STREETVIEW_STYLE_DEFAULT'), 'value', 'text')); 
                                echo JHTML::_( 'select.genericlist', $this->mapStreetViewList, 'jform[streetviewstyleid]',  'class="inputbox required" size="1"', 'value', 'text', (int)$this->item->streetviewstyleid, 'jform_streetviewstyleid');
                                //echo $field->label;
                                //echo $field->input;
                            ?>
                            </div>
                            <?php 
                        }
                        else if ($field->id == 'jform_override_id')
                        {
                            ?>
                            <div class="control-label">
                            <?php 
                                echo $field->label;
                            ?>
                            </div>
                            <div class="controls">
                            <?php 
                                array_unshift($this->mapOverrideList, JHTML::_('select.option', '0', JText::_( 'COM_ZHGOOGLEMAP_MAP_DETAIL_OVERRIDE_DEFAULT'), 'value', 'text')); 
                                echo JHTML::_( 'select.genericlist', $this->mapOverrideList, 'jform[override_id]',  'class="inputbox required span5" size="1"', 'value', 'text', (int)$this->item->override_id, 'jform_override_id');
                                //echo $field->label;
                                //echo $field->input;
                            ?>
                            </div>
                            <?php 
                        }
                        else if ($field->id == 'jform_hoverinfobubble')
                        {
                            ?>
                            <div class="control-label">
                            <?php 
                                echo $field->label;
                            ?>
                            </div>
                            <div class="controls">
                            <?php 
                                array_unshift($this->infobubbleStyleList, JHTML::_('select.option', '', JText::_( 'COM_ZHGOOGLEMAP_MAP_DETAIL_INFOBUBBLESTYLE_DEFAULT'), 'value', 'text')); 
                                echo JHTML::_( 'select.genericlist', $this->infobubbleStyleList, 'jform[hoverinfobubble]',  'class="inputbox" size="1"', 'value', 'text', (int)$this->item->hoverinfobubble, 'jform_hoverinfobubble');
                            ?>
                            </div>
                            <?php 
                        }                        
                        else
                        {
                            ?>
                            <div class="control-label">
                            <?php 
                                echo $field->label;
                            ?>
                            </div>
                            <div class="controls">
                            <?php 
                                echo $field->input;
                            ?>
                            </div>
                            <?php 
                        }
                        ?>
                        </div>
                    <?php endforeach; ?>
                
            </fieldset>
        </div>
        <div class="tab-pane" id="tab13">
            
            <fieldset class="adminform">
                
                    <?php foreach($this->form->getFieldset('mapgeolocation') as $field): ?>
                        <div class="control-group">
                        <?php 
                            ?>
                            <div class="control-label">
                            <?php 
                                echo $field->label;
                            ?>
                            </div>
                            <div class="controls">
                            <?php 
                                echo $field->input;
                            ?>
                            </div>
                            <?php 
                        ?>
                        </div>
                    <?php endforeach; ?>
                
            </fieldset>
        </div>
        <div class="tab-pane" id="tab14">
            <fieldset class="adminform">
                
                    <?php foreach($this->form->getFieldset('integration') as $field): ?>
                        <div class="control-group">
                        <?php 
                            ?>
                            <div class="control-label">
                            <?php 
                                echo $field->label;
                            ?>
                            </div>
                            <div class="controls">
                            <?php 
                                echo $field->input;
                            ?>
                            </div>
                            <?php 
                        ?>
                        </div>
                    <?php endforeach; ?>
                
            </fieldset>
        </div>

        <?php echo $this->loadTemplate('params'); ?>

    </div>

<div>
    <input type="hidden" name="task" value="mapmap.edit" />
    <?php echo JHtml::_('form.token'); ?>
</div>


</div>

</form>