Hauptmenü

Anzeige Position

Begonnen von Masterfunk, 13 Januar 2017, 15:40:08

Vorheriges Thema - Nächstes Thema

Masterfunk

Ich versuche immer noch meine Position via Google Maps in Tablet-UI anzuzeigen.

Auf fhem Seite habe ich folgende sub:

sub ShowGoogleMapsPosition($$$$) {
my ($zoom,$width,$height,$Resident) = @_;
$zoom='12' unless $zoom;
$width='740' unless $width;
$height='470' unless $height;
$lat= ReadingsVal ($Resident, "locationLat", "0");
$lng= ReadingsVal ($Resident, "locationLong", "0");

  my $htmlcode = "";

  $htmlcode .= "<script src='https://maps.googleapis.com/maps/api/js?v=3.exp'></script>";
  $htmlcode .= "<script>";
  $htmlcode .= "function initialize() {  ";
  $htmlcode .= "var myLatlng = new google.maps.LatLng(".$lat.",".$lng.");;  ";
  $htmlcode .= "var mapOptions = {    ";
  $htmlcode .= "  zoom: ".$zoom.",    ";
  $htmlcode .= "  center: myLatlng  ";
  $htmlcode .= "};;  ";
  $htmlcode .= "var map = new google.maps.Map(document.getElementById('map'), mapOptions);;  ";
  $htmlcode .= "var marker = new google.maps.Marker({ ";
  $htmlcode .= "  position: myLatlng, ";
  $htmlcode .= "  title: 'Detlef', ";
  $htmlcode .= "});; ";
  $htmlcode .= "marker.setMap(map);; ";
  $htmlcode .= "} ";
  $htmlcode .= "google.maps.event.addDomListener(window, 'load', initialize);;    ";
  $htmlcode .= "</script>    ";
  $htmlcode .= "<div id='map' style='width:".$width."px;;height:".$height."px;;'></div>";

fhem "setreading MapLocation_Detlef ftuilink ".$htmlcode;

  return $htmlcode;
}


Wie bekomme ich es jetzt hin, den "$htmlcode" in eine Datei zu schreiben (z.B. Detlef_Map.html) um diese dann via iframe in fhem einzubinden?

Gruß Detlef

redlav

Hallo,

anstatt in eine Datei schreibst du den $htmlcode in einen Dummy und verwendest diesen in einem Label.

<div data-type="label" data-device="deindummy" data-get="STATE" class="top-space"></div>

So hatte ich es für die Wetterwarnung, bevor es das widget gab.

Gruß Norbert

Masterfunk

Den Ansatz hatte ich schon probiert, geht nicht.

Gruß Detlef