-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
jhbriese
wants to merge
13
commits into
abrain:develop
Choose a base branch
from
jhbriese:develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4aa6001
Merge pull request #2 from abrain/develop
jhbriese 05ea58c
Einsatzorte können mittels Google Maps API dargestellt werden.
jhbriese b53409e
Fehlende Felder in den Tests ergänzt
jhbriese 1eae76f
GoogleMaps integration: Refactoring: JavaScript so weit es geht aus d…
jhbriese abff043
Merge pull request #3 from abrain/develop
jhbriese 43f3878
Merge branch 'develop' of github.com:abrain/einsatzverwaltung into de…
jhbriese 9e871c2
Aufräumen
jhbriese 1548271
Merge commit '5403d5d25c2bf188f4436827232fc8832dc3919e' into develop
jhbriese a4129e1
Einige Probleme nach merge (Fehlende Zeilen) behoben und Anregungen v…
jhbriese 7db9342
Merge branch 'develop' into develop
jhbriese dce2881
Code Climate improvements
jhbriese 1933af4
Typo in den Settings Googel --> Google
jhbriese 0c22b7d
Merge branch 'develop' of https://github.com/abrain/einsatzverwaltung…
jhbriese File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Einsatzorte können mittels Google Maps API dargestellt werden.
In den Einstellungen kann dies (de)aktiviert werden. Zusätzliches Feld mit Koordinate, welche via Button bestimmt wird. Im Admin kann der Marker verschoben werden.
- Loading branch information
commit 05ea58cd23c046b5e2d32adcab73fd31d596da02
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,11 @@ class Admin | |
*/ | ||
private $core; | ||
|
||
/** | ||
* @var Options | ||
*/ | ||
private $options; | ||
|
||
/** | ||
* @var Utilities | ||
*/ | ||
|
@@ -23,11 +28,13 @@ class Admin | |
* Constructor | ||
* | ||
* @param Core $core | ||
* @param Options $options | ||
* @param Utilities $utilities | ||
*/ | ||
public function __construct($core, $utilities) | ||
public function __construct($core, $options, $utilities) | ||
{ | ||
$this->core = $core; | ||
$this->options = $options; | ||
$this->utilities = $utilities; | ||
$this->addHooks(); | ||
} | ||
|
@@ -124,6 +131,8 @@ public function enqueueEditScripts($hook) | |
array(), | ||
Core::VERSION | ||
); | ||
|
||
wp_enqueue_script( 'einsatzvw_GoogleMap' ); | ||
} | ||
|
||
/** | ||
|
@@ -167,10 +176,11 @@ public function displayMetaBoxEinsatzdetails($post) | |
$einsatzort = $report->getLocation(); | ||
$einsatzleiter = $report->getIncidentCommander(); | ||
$mannschaftsstaerke = $report->getWorkforce(); | ||
$gmapslocation = $report->getGmapsLocation(); | ||
|
||
$names = Data::getEinsatzleiterNamen(); | ||
echo '<input type="hidden" id="einsatzleiter_used_values" value="' . implode(',', $names) . '" />'; | ||
echo '<table><tbody>'; | ||
echo '<table style="width: 100%;"><tbody>'; | ||
|
||
$this->echoInputText( | ||
'Einsatznummer', | ||
|
@@ -202,6 +212,11 @@ public function displayMetaBoxEinsatzdetails($post) | |
esc_attr($einsatzort) | ||
); | ||
|
||
if($this->options->isGMapActivate()) | ||
{ | ||
$this->echoGMap($gmapslocation); | ||
} | ||
|
||
$this->echoInputText( | ||
'Einsatzleiter', | ||
'einsatzverwaltung_einsatzleiter', | ||
|
@@ -236,6 +251,84 @@ private function echoInputText($label, $name, $value, $placeholder = '', $size = | |
echo '/></td></tr>'; | ||
} | ||
|
||
/** | ||
* Generiert eine Googlemaps Karte zur bestimmung der Koordinate | ||
*/ | ||
private function echoGMap($location) | ||
{ | ||
if($location != "") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wäre |
||
{ | ||
$latLon = explode(",",$location); | ||
} | ||
else | ||
{ | ||
$latLon = array("",""); | ||
} | ||
$DeflatLon = explode(",",$this->options->getGMapDefaultPos()); | ||
|
||
echo '<tr><td>'; | ||
echo '<label for="einsatzverwaltung_location">Koordinate</label>'; | ||
echo '</td><td style="width: 100%;">'; | ||
echo '<input type="text" id="einsatzverwaltung_location" name="einsatzverwaltung_location" value="' . $location . '" size="20" readonly/>'; | ||
echo '<a class="button" id="einsatzverwaltung_get_location"><i class="fa fa-map-marker"></i></a>'; | ||
echo '</td></tr>'; | ||
echo '<tr><td colspan="2">'; | ||
echo '<div id="map-canvas" style="height: 400px;"></div>'; | ||
echo '</td></tr>'; | ||
echo '<script>'; | ||
echo 'function initializeMap() {'; | ||
echo 'var defLat = "' . $DeflatLon[0] . '";'; | ||
echo 'var defLon = "' . $DeflatLon[1] . '";'; | ||
echo 'var latlon = new google.maps.LatLng(defLat, defLon);'; | ||
echo 'var mapOptions = {'; | ||
echo 'zoom: 13,'; | ||
echo 'center: latlon,'; | ||
echo 'scaleControl: true'; | ||
echo '};'; | ||
echo 'map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);'; | ||
echo 'var lat = "' . $latLon[0] . '";'; | ||
echo 'var lon = "' . $latLon[1] . '";'; | ||
echo 'if( lat != "" && lon != "" ) {'; | ||
echo 'setMarker( new google.maps.LatLng(lat, lon), map );'; | ||
echo '}'; | ||
echo 'var geocoder = new google.maps.Geocoder();'; | ||
echo 'document.getElementById("einsatzverwaltung_get_location").addEventListener("click", function() {'; | ||
echo 'var address = document.getElementById("einsatzverwaltung_einsatzort").value;'; | ||
echo 'if( address ) {'; | ||
echo 'geocodeAddress(geocoder, map, address);'; | ||
echo '} else {'; | ||
echo 'alert("Keine Addresse angegebenen: " + status);'; | ||
echo '}'; | ||
echo '});'; | ||
echo '}'; | ||
echo 'function setMarker( position, resultsMap ) {'; | ||
echo 'var marker = new google.maps.Marker({'; | ||
echo 'map: resultsMap,'; | ||
echo 'position: position,'; | ||
echo 'draggable: true,'; | ||
echo 'scaleControl:true'; | ||
echo '});'; | ||
echo 'resultsMap.setCenter(marker.getPosition());'; | ||
echo 'document.getElementById("einsatzverwaltung_location").value=marker.getPosition().toUrlValue();'; | ||
echo 'marker.addListener("drag", function(){'; | ||
echo 'document.getElementById("einsatzverwaltung_location").value=marker.getPosition().toUrlValue();'; | ||
echo '});'; | ||
echo '}'; | ||
echo 'function geocodeAddress(geocoder, resultsMap, address) {'; | ||
echo 'geocoder.geocode({"address": address}, function(results, status) {'; | ||
echo 'if (status === google.maps.GeocoderStatus.OK) {'; | ||
echo 'var location = results[0].geometry.location;'; | ||
echo 'setMarker( location, resultsMap);'; | ||
echo 'resultsMap.setZoom(16);'; | ||
echo '} else {'; | ||
echo 'alert("Konnte Position nicht ermitteln: " + status);'; | ||
echo '}'; | ||
echo '});'; | ||
echo '}'; | ||
echo 'google.maps.event.addDomListener(window, "load", initializeMap);'; | ||
echo '</script>'; | ||
} | ||
|
||
/** | ||
* Gibt eine Checkbox für die Metabox aus | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Google legt wert auf eine korrekte Schreibweise der Produkte:
Google Maps
anstattGooglemaps
, sowieso ist da ein Typo drin (dasg
fehlt beiGoogle
).