Skip to content

Commit

Permalink
added osm
Browse files Browse the repository at this point in the history
veenmeyer committed Dec 31, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent ee475f8 commit 619b56d
Showing 7 changed files with 244 additions and 23 deletions.
124 changes: 118 additions & 6 deletions administrator/helpers/osm.php
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ public static function installOsmMap()
}


public static function callOsmMap($zoom='13',$lat='53.26434271775887',$lon='7.5730027132448186')
public static function callOsmMap($zoom='',$lat='53.26434271775887',$lon='7.5730027132448186')
{
?>
<script type="text/javascript">
@@ -45,15 +45,16 @@ public static function callOsmMap($zoom='13',$lat='53.26434271775887',$lon='7.57
doubleClickZoom: false,
center: [<?php echo $lat;?>, <?php echo $lon;?>],
minZoom: 2,
maxZoom: 18,
zoom: <?php echo $zoom;?>,
layers: [myOsmDe],
scrollWheelZoom: false
});
var baseLayers = {
"OSM deutscher Style": myOsmDe
};
L.control.layers(baseLayers).addTo(map);
//var baseLayers = {
// "OSM deutscher Style": myOsmDe
// };
// L.control.layers(baseLayers).addTo(map);


var osmGeocoder = new L.Control.OSMGeocoder();
map.addControl(osmGeocoder);
@@ -207,6 +208,10 @@ public static function addEinsatzortMap($lat='53.26434271775887',$lon='7.5730027
popup = <?php echo $params->get('display_detail_popup','false');?>;
map.setView(new L.LatLng(lat,lon), <?php echo $params->get('detail_gmap_zoom_level','12');?>);

map.options.minZoom = <?php echo $params->get('detail_gmap_zoom_level','12');?>;
map.options.maxZoom = <?php echo $params->get('detail_gmap_zoom_level','12');?>;


var LeafIcon = L.Icon.extend({
options: {
iconSize: [15, 18],
@@ -282,6 +287,113 @@ public static function addPolygonMap($latlngs='[[0,0]]',$color='red')
return;
}

public static function addRightClickOsmMap()
{
?>
<script type="text/javascript">

map.on('contextmenu', function(e) {
//alert(e.target);
var marker = new L.marker(e.latlng,{draggable:'true'}).addTo(map);
var m = marker.getLatLng();
map.panTo(new L.LatLng(m.lat, m.lng));
document.getElementById("jform_start_lat").value=m.lat.toFixed(15);
document.getElementById("jform_start_lang").value=m.lat.toFixed(15);
});
map.on('zoomstart',function(e){
var currZoom = map.getZoom();
document.getElementById("jform_gmap_zoom_level").value=currZoom;
});

</script>
<?php
return;
}


public static function editPolygonMap($latlngs='[[0,0]]',$color='red')
{
$document = JFactory::getDocument();
$document->addStyleSheet('https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/0.4.2/leaflet.draw.css');
$document->addScript('https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/0.4.2/leaflet.draw.js');

?>
<script type="text/javascript">

var latlngs = <?php echo $latlngs;?>;
var polygon = L.polygon(latlngs, {color: '<?php echo $color;?>'}).addTo(map);

// Initialise the FeatureGroup to store editable layers
var editableLayers = new L.FeatureGroup();
map.addLayer(editableLayers);


var drawPluginOptions = {
position: 'topright',
draw: {
polygon: {
allowIntersection: true, // Restricts shapes to simple polygons
drawError: {
color: '#e1e100', // Color the shape will turn when intersects
message: '<strong>Oh snap!<strong> you can\'t draw that!' // Message that will show when intersect
},
shapeOptions: {
color: '#97009c'
}
},
// disable toolbar item by setting it to false
polyline: false,
circle: false, // Turns off this drawing tool
rectangle: false,
marker: false,
},
edit: {
featureGroup: editableLayers, //REQUIRED!!
remove: false
}
};

// Initialise the draw control and pass it the FeatureGroup of editable layers
var drawControl = new L.Control.Draw(drawPluginOptions);
map.addControl(drawControl);

var editableLayers = new L.FeatureGroup();
map.addLayer(editableLayers);

map.on('draw:created', function(e) {
var type = e.layerType,
layer = e.layer;

if (type === 'marker') {
layer.bindPopup('A popup!');
}

if (type === 'polygon') {
// structure the geojson object
var geojson = {};

// export the coordinates from the layer
coordinates = '';
latlngs = layer.getLatLngs()[0];

for (var i = 0; i < latlngs.length; i++) {
coordinates= coordinates+latlngs[i].lat+","+latlngs[i].lng+"|";
}

document.getElementById('jform_gmap_alarmarea').innerHTML = coordinates;

}


editableLayers.addLayer(layer);
});

</script>
<?php
return;
}




}
52 changes: 50 additions & 2 deletions administrator/views/gmapkonfiguration/tmpl/edit.php
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@
// no direct access
defined('_JEXEC') or die;

JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
JHtml::_('behavior.tooltip');
JHtml::_('behavior.formvalidation');
JHtml::_('behavior.keepalive');
@@ -92,8 +91,10 @@
<li><?php echo JText::_('COM_EINSATZKOMPONENTE_GMAP_2');?></li>
</ul>
</div>
<?php if ($this->params->get('gmap_action','0') == '1') : ?>
<input class='btn btn-warning' type='button' onclick='clearMap();return false;' value='<?php echo JText::_('COM_EINSATZKOMPONENTE_GMAP_KOORDINATEN_LOESCHEN');?>'/>
<input class='btn btn-warning' type='button' onclick='resetarea()' value='<?php echo JText::_('COM_EINSATZKOMPONENTE_GMAP_KOORDINATENLISTE_ZUUECKSETZEN');?>'/>
<?php endif;?>
<!-- Button to trigger modal -->
<a href="#myModal" role="button" class="btn" data-toggle="modal"><?php echo JText::_('COM_EINSATZKOMPONENTE_GMAP_4');?></a>

@@ -126,7 +127,19 @@
</div>
</div>
</div>
<?php if ($this->params->get('gmap_action','0') == '1') : ?>
<div id="map" style="width: 810px; height: 400px"><?php echo JText::_('COM_EINSATZKOMPONENTE_GMAP_7');?></div>
<?php endif;?>

<?php if ($this->params->get('gmap_action','0') == '2') : ?>
<div id="map_canvas" style="width: 810px; height: 400px"><?php echo JText::_('COM_EINSATZKOMPONENTE_GMAP_7');?></div>
<?php OsmHelper::installOsmMap();?>
<?php OsmHelper::callOsmMap($this->gmap_config->gmap_zoom_level,$this->gmap_config->start_lat,$this->gmap_config->start_lang); ?>
<?php OsmHelper::addRightClickOsmMap(); ?>
<?php OsmHelper::editPolygonMap($this->einsatzgebiet,'blue'); ?>
<?php endif;?>


<input type="hidden" name="gmap_latitude" id="gmap_latitude" value="<?php echo $gmap_latitude; ?>" size="30"/>
<input type="hidden" name="gmap_longitude" id="gmap_longitude" value="<?php echo $gmap_longitude; ?>" size="30"/>

@@ -155,9 +168,40 @@
</div>
</form>

<script type="text/javascript">

</script>



























<!-- ############ GoogleMaps ############# -->

<?php if ($this->params->get('gmap_action','0') == '1') { ?>

<?php // Einsatzgebiet für GMap-Karte vorbereiten
$area = substr($this->item->gmap_alarmarea, -1);
if ($area =="|")
@@ -189,7 +233,8 @@

?>

<!--Javascript für Gmap-Karte-->

<!--Javascript für Gmap-Karte-->

<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?key=<?php echo $this->params->get ('gmapkey','') ;?>"></script>

@@ -488,3 +533,6 @@ function resetarea() {
// Onload handler to fire off the app.
google.maps.event.addDomListener(window, 'load', buildMap);
</script>

<?php } ?>

21 changes: 21 additions & 0 deletions administrator/views/gmapkonfiguration/view.html.php
Original file line number Diff line number Diff line change
@@ -11,6 +11,9 @@
defined('_JEXEC') or die;

jimport('joomla.application.component.view');
JLoader::import('helpers.einsatzkomponente', JPATH_SITE.'/administrator/components/com_einsatzkomponente');
JLoader::import('helpers.osm', JPATH_SITE.'/administrator/components/com_einsatzkomponente');


/**
* View to edit
@@ -21,6 +24,8 @@ class EinsatzkomponenteViewGmapkonfiguration extends JViewLegacy
protected $item;
protected $form;
protected $params;
protected $gmap_config;
protected $einsatzgebiet;

/**
* Display the view
@@ -32,6 +37,22 @@ public function display($tpl = null)
$this->form = $this->get('Form');
$this->params = JComponentHelper::getParams('com_einsatzkomponente');

$this->gmap_config = EinsatzkomponenteHelper::load_gmap_config(); // GMap-Config aus helper laden

$alarmareas1 = $this->gmap_config->gmap_alarmarea; // Einsatzgebiet ---->
$alarmareas = explode('|', $alarmareas1);
$this->einsatzgebiet='[';
for($i = 0; $i < count($alarmareas)-1; $i++)
{
$areas = explode(',', $alarmareas[$i]);
$this->einsatzgebiet=$this->einsatzgebiet.'['.$areas[0].','.$areas[1].'],';
}
$areas = explode(',', $alarmareas[0]);
//$this->einsatzgebiet=$this->einsatzgebiet.'['.$areas[0].','.$areas[1].'],';
$this->einsatzgebiet=substr($this->einsatzgebiet,0,strlen($this->einsatzgebiet)-1);
$this->einsatzgebiet=$this->einsatzgebiet.']';


// Check for errors.
if (count($errors = $this->get('Errors'))) {
throw new Exception(implode("\n", $errors));
4 changes: 2 additions & 2 deletions einsatzkomponente.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.2.0" method="upgrade">
<name>com_einsatzkomponente</name>
<creationDate>2018-12-30</creationDate>
<creationDate>2018-12-31</creationDate>
<copyright>Copyright (C) 2018 by Ralf Meyer. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later</license>
<author>Ralf Meyer</author>
<authorEmail>[email protected]</authorEmail>
<authorUrl>https://einsatzkomponente.de</authorUrl>
<version>3.21.3_beta</version>
<version>3.21.4_beta</version>

<description>
<![CDATA[
24 changes: 19 additions & 5 deletions site/views/einsatzbericht/tmpl/detail_layout_2.php
Original file line number Diff line number Diff line change
@@ -65,16 +65,30 @@
<?php if( $this->item->gmap_report_latitude != '0' ) : ?>
<?php if( $this->params->get('display_detail_map_for_only_user','0') == '1' || $user->id ) :?>
<?php if ($this->params->get('gmap_action','0')=='1') : ?>
<td style="float:right;">
<td style="float:right;width:50%;" class="eiko_top_td_detail_2">
<div id="map-canvas" style="min-width:350px;width:100%;border:solid #000 1px;height:<?php echo $this->params->get('detail_map_height','250px');?>"></div>
<div id="distance_direct" title ="Die Angabe kann vom tats&auml;chlichen Streckenverlauf abweichen, da diese Angabe automatisch von Google Maps errechnet wurde !"></div>
</td>
<?php endif;?>
<?php if ($this->params->get('gmap_action','0')=='2') : ?>
<td style="float:right;">
<body onLoad="drawmap();">
<div id="map" style="min-width:350px;width:100%;border:solid #000 1px;height:<?php echo $this->params->get('detail_map_height','250px');?>;"></div>
<div class="hide"><p>Dieser Teil der Seite erfordert die JavaScript Unterstützung Ihres Browsers!</p></div>
<td style="float:right;width:50%;" class="eiko_top_td_detail_2">
<div id="map_canvas" class="eiko_einsatzkarte_2" style="width:300px;height:<?php echo $this->params->get('detail_map_height','250px');?>;"></div>
<noscript>Dieser Teil der Seite erfordert die JavaScript Unterstützung Ihres Browsers!</noscript>

<?php OsmHelper::installOsmMap();?>
<?php OsmHelper::callOsmMap($this->gmap_config->gmap_zoom_level,$this->gmap_config->start_lat,$this->gmap_config->start_lang); ?>

<?php if ($this->params->get('display_detail_einsatz_marker','1')) :?>
<?php OsmHelper::addEinsatzortMap($this->item->gmap_report_latitude,$this->item->gmap_report_longitude,$this->item->summary,$this->einsatzlogo->icon,$this->item->id);?>
<?php endif;?>

<?php if ($this->params->get('display_detail_organisationen','1')) :?>
<?php OsmHelper::addOrganisationenMap($this->organisationen);?>
<?php endif;?>
<?php if ($this->params->get('display_detail_einsatzgebiet','1')) :?>
<?php OsmHelper::addPolygonMap($this->einsatzgebiet,'blue');?>
<?php endif;?>

</td>
<?php endif;?>
<?php else:?>
24 changes: 18 additions & 6 deletions site/views/einsatzbericht/tmpl/detail_layout_3.php
Original file line number Diff line number Diff line change
@@ -65,8 +65,8 @@

<div style=" text-align:center;">
<div>
<a href="<?php echo $this->item->image;?>" rel="highslide[<?php echo $this->item->id; ?>]" class="highslide" onClick="return hs.expand(this, { captionText: '<?php echo $this->item->einsatzart;?> am <?php echo date("d.m.Y - H:i", strtotime($this->item->date1)).' Uhr'; ?><br/><?php echo $this->images[$i]->comment;?>' });" alt ="<?php echo $this->item->einsatzart;?>">
<img class="img-rounded" src="<?php echo $this->item->image;?>" alt="<?php echo $this->item->einsatzart;?>" title="<?php echo $this->item->einsatzart;?>" alt ="<?php echo $this->item->einsatzart;?>" style="max-width:600px;"/>
<a href="<?php echo JURI::Root().$this->item->image;?>" rel="highslide[<?php echo $this->item->id; ?>]" class="highslide" onClick="return hs.expand(this, { captionText: '<?php echo $this->einsatzlogo->title;?> am <?php echo date("d.m.Y - H:i", strtotime($this->item->date1)).' Uhr'; ?>' });" alt ="<?php echo $this->einsatzlogo->title;?>">
<img class="eiko_img-rounded_2 eiko_detail_image_2" src="<?php echo JURI::Root().$this->item->image;?>" alt="<?php echo $this->einsatzlogo->title;?>" title="<?php echo $this->einsatzlogo->title;?>" alt ="<?php echo $this->einsatzlogo->title;?>"/>
</a>
</div>
</div>
@@ -132,11 +132,23 @@
<?php if ($this->params->get('gmap_action','0')=='2') : ?>
<div class="distance100">&nbsp;</div>
<h3>Einsatzort</h3>
<body onLoad="drawmap();"></body>
<!--<div id="descriptionToggle" onClick="toggleInfo()">Informationen zur Karte anzeigen</div>
<div id="description" class="">Einsatzkarte</div>-->
<div id="map" style="width:100%; height:<?php echo $this->params->get('detail_map_height','250px');?>;"></div>
<div id="map_canvas" class="eiko_einsatzkarte_2" style="height:<?php echo $this->params->get('detail_map_height','250px');?>;"></div>
<noscript>Dieser Teil der Seite erfordert die JavaScript Unterstützung Ihres Browsers!</noscript>

<?php OsmHelper::installOsmMap();?>
<?php OsmHelper::callOsmMap($this->gmap_config->gmap_zoom_level,$this->gmap_config->start_lat,$this->gmap_config->start_lang); ?>

<?php if ($this->params->get('display_detail_einsatz_marker','1')) :?>
<?php OsmHelper::addEinsatzortMap($this->item->gmap_report_latitude,$this->item->gmap_report_longitude,$this->item->summary,$this->einsatzlogo->icon,$this->item->id);?>
<?php endif;?>

<?php if ($this->params->get('display_detail_organisationen','1')) :?>
<?php OsmHelper::addOrganisationenMap($this->organisationen);?>
<?php endif;?>
<?php if ($this->params->get('display_detail_einsatzgebiet','1')) :?>
<?php OsmHelper::addPolygonMap($this->einsatzgebiet,'blue');?>
<?php endif;?>

<?php endif;?>
<?php else:?>
<?php echo '<span style="padding:5px;" class="label label-info">( Bitte melden Sie sich an, um den Einsatzort auf einer Karte zu sehen. )</span><br/><br/>';?>
18 changes: 16 additions & 2 deletions site/views/einsatzbericht/tmpl/detail_layout_4.php
Original file line number Diff line number Diff line change
@@ -325,9 +325,23 @@
</div>
<?php endif;?>
<?php if ($this->params->get('gmap_action','0') == '2') :?>
<body onLoad="drawmap();">
<div id="map" class="eiko_einsatzkarte_2" style="height:<?php echo $this->params->get('detail_map_height','250px');?>;"></div>
<div id="map_canvas" class="eiko_einsatzkarte_2" style="height:<?php echo $this->params->get('detail_map_height','250px');?>;"></div>
<noscript>Dieser Teil der Seite erfordert die JavaScript Unterstützung Ihres Browsers!</noscript>

<?php OsmHelper::installOsmMap();?>
<?php OsmHelper::callOsmMap($this->gmap_config->gmap_zoom_level,$this->gmap_config->start_lat,$this->gmap_config->start_lang); ?>

<?php if ($this->params->get('display_detail_einsatz_marker','1')) :?>
<?php OsmHelper::addEinsatzortMap($this->item->gmap_report_latitude,$this->item->gmap_report_longitude,$this->item->summary,$this->einsatzlogo->icon,$this->item->id);?>
<?php endif;?>

<?php if ($this->params->get('display_detail_organisationen','1')) :?>
<?php OsmHelper::addOrganisationenMap($this->organisationen);?>
<?php endif;?>
<?php if ($this->params->get('display_detail_einsatzgebiet','1')) :?>
<?php OsmHelper::addPolygonMap($this->einsatzgebiet,'blue');?>
<?php endif;?>

<?php endif;?>
<?php if ($this->params->get('gmap_action','0')) : ?>
<?php if( $this->item->gmap ) : ?>

0 comments on commit 619b56d

Please sign in to comment.