Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Maps für Einsatzorte #114

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Einige Probleme nach merge (Fehlende Zeilen) behoben und Anregungen v…
…on sebastianroming implementiert
  • Loading branch information
jhbriese committed Oct 6, 2017
commit a4129e13e58ca26500b4640e05ca2ef81e7b1b48
2 changes: 1 addition & 1 deletion src/Frontend/ReportList.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ private function constructList($reports, $args)
$this->insertTableHeader();
}

if( $this->options->isGMapActivate() != "" && $this->showMap) {
if( $this->options->isGMapActivate() && $this->showMap) {
$latLon = explode(",", $this->options->getGMapDefaultPos() );
$mapstring = "<style>#map-canvas {height: 300px; margin-bottom: 30px; position: relative; overflow: hidden; transform: translateZ(0px); background-color: rgb(229, 227, 223);}</style>";
$mapstring .= "<div class='einsatzliste-map'>";
Expand Down
2 changes: 1 addition & 1 deletion src/Model/IncidentReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static function getMetaFields()
'label' => 'Einsatzort'
),
'einsatz_location' => array(
'label' => 'Goolemaps Position'
'label' => 'Google Maps Position'
),
'einsatz_einsatzleiter' => array(
'label' => 'Einsatzleiter'
Expand Down
2 changes: 1 addition & 1 deletion src/einsatzverwaltung-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ private function echoInputText($label, $name, $value, $placeholder = '', $size =
*/
private function echoGMap($location)
{
if($location != "")
if(!empty($location ))
{
$latLon = explode(",",$location);
}
Expand Down
16 changes: 16 additions & 0 deletions src/einsatzverwaltung-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ public function onDeactivation()
public function onInit()
{
$this->registerTypes();
$this->registerScripts();
$this->addRewriteRules();
if ($this->options->isFlushRewriteRules()) {
flush_rewrite_rules();
Expand Down Expand Up @@ -416,6 +417,21 @@ private function registerTypes()
));
}

/**
* Registriert externe Scripts
*/
private function registerScripts()
{
if( $this->options->isGMapActivate() ) {
/* Google Maps */
$protocal = is_ssl() ? 'https://' : 'http:https://';
$url = add_query_arg( array(
'key' => $this->options->getGMapAPI(),
), "{$protocal}maps.googleapis.com/maps/api/js");
wp_register_script( 'einsatzvw_GoogleMap', $url );
}
}

private function addRewriteRules()
{
global $wp_rewrite;
Expand Down
46 changes: 46 additions & 0 deletions src/einsatzverwaltung-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,19 @@ public function registerSettings()
'einsatzvw_list_ext_link',
array($this->utilities, 'sanitizeCheckbox')
);
register_setting(
'einsatzvw_settings',
'einsatzvw_gmap',
array($this->utilities, 'sanitizeCheckbox')
);
register_setting(
'einsatzvw_settings',
'einsatzvw_gmap_api'
);
register_setting(
'einsatzvw_settings',
'einsatzvw_gmap_default_pos'
);
register_setting(
'einsatzvw_settings',
'einsatzvw_list_annotations_color_off',
Expand Down Expand Up @@ -338,6 +351,13 @@ private function addSettingsFields()
self::EVW_SETTINGS_SLUG,
'einsatzvw_settings_einsatzberichte'
);
add_settings_field(
'einsatzvw_settings_gmap',
'Google Maps',
array($this, 'echoSettingsGmap'),
self::EVW_SETTINGS_SLUG,
'einsatzvw_settings_einsatzberichte'
);
add_settings_field(
'einsatzvw_settings_columns',
'Spalten der Einsatzliste',
Expand Down Expand Up @@ -575,6 +595,32 @@ public function echoSettingsExcerpt()
}


/**
* Gibt die Einstellmöglichkeiten für Google-Maps aus
*/
public function echoSettingsGmap()
{
$this->echoSettingsCheckbox(
'einsatzvw_gmap',
'Googel Maps aktivieren',
$this->options->isGMapActivate()
);
echo '<p>Googel Maps JavaScript API-Key:&nbsp;';
$this->echoSettingsInput(
'einsatzvw_gmap_api',
'Wie generiere ich einen <a href="https://developers.google.com/maps/documentation/javascript/get-api-key" target="_blank">API-Key</a>',
$this->options->getGMapAPI()
);
echo '<p>Standartposition der Karte:&nbsp;';
$this->echoSettingsInput(
'einsatzvw_gmap_default_pos',
'Als Lat,Lon: 53.523463,9.482329',
$this->options->getGMapDefaultPos()
);
}



/**
*
*/
Expand Down