function addMarker($pLat, $pLon, $pIcon, $pTitle, $pTitleLink, $pCaption, $pMaxContent, $pIsLine)
 {
     $this->mMarkerCount++;
     $this->mOutput .= "<Placemark>\n<name>";
     $this->mOutput .= $pTitle ? $pTitle : "point {$this->mMarkerCount}";
     $this->mOutput .= "</name>";
     $this->mOutput .= "<Style><Icon><href>";
     $this->mOutput .= $pIcon ? $this->mIcons[$pIcon] : $this->mIcon;
     $this->mOutput .= "</href></Icon></Style>\n";
     $this->mOutput .= "<Point><coordinates>{$pLon}, {$pLat}, 0</coordinates></Point>\n";
     if (is_string($pCaption) && $pCaption) {
         $this->mOutput .= '<description><![CDATA[' . GoogleMaps::fixBlockDirection(GoogleMaps::fixTidy($pCaption), $this->mLanguage->isRTL()) . ']]></description>';
     } elseif (is_array($pCaption)) {
         // TODO tabs and max content
     }
     $this->mOutput .= "</Placemark>\n";
 }
Esempio n. 2
0
 /**
  * Creates a new marker on the google map.
  *
  * @param $pLat numeric - the latitude for the marker
  * @param $pLon numeric - the longitude of the marker
  * @param $pIcon string - the identifier of the icon to use
  * @param $pTitle string - the title for the marker
  * @param $pCaption string - the caption for the marker
  * @param $pColor string - the color of the polyline (really just used to know if we're in
  *   a polyline or not and should draw markers without captions)
  * @param $pTabs [string] - array of tabs for the marker formatted as javascript for constructing
  *   GInfoWindowTab objects
  *
  * @return string - the javascript for adding the tabs to the map
  **/
 function addMarker($pLat, $pLon, $pIcon, $pTitle, $pTitleLink, $pCaption, $pMaxContent, $pIsLine)
 {
     $title = GoogleMaps::fixStringDirection($pTitle, $this->mLanguage->isRTL());
     if (is_string($pCaption)) {
         $captionNoNewlines = preg_replace('/[\\r\\n]+/', ' ', $pCaption);
     }
     $options = array();
     // choose the appropriate icon for the marker
     $options['icon'] = $pIcon ? "mapIcons['{$pIcon}']" : "GME_DEFAULT_ICON";
     $options['clickable'] = $title || (is_string($pCaption) ? $captionNoNewlines : count($pCaption)) ? "true" : "false";
     if (!($pIsLine && $options['clickable'] == "false")) {
         $this->mOutput .= " marker = new GMarker(new GLatLng({$pLat}, {$pLon}), { ";
         if ($title) {
             $this->mOutput .= " 'title': '" . addslashes($title) . "', ";
         }
         $this->mOutput .= " 'icon': {$options['icon']}, ";
         $this->mOutput .= " 'clickable': {$options['clickable']} ";
         $this->mOutput .= "});";
     }
     if ($pMaxContent) {
         $this->mOutput .= " marker.maxContent = '" . addslashes($pMaxContent) . "';";
     }
     if (is_string($pCaption)) {
         // if there's a caption, set it
         $this->mOutput .= " marker.caption = '';";
         if ($title) {
             $this->mOutput .= " marker.title = '" . addslashes($title) . "';";
             $this->mOutput .= " marker.title_link = '" . addslashes($pTitleLink) . "';";
         }
         if ($captionNoNewlines) {
             $this->mOutput .= " marker.caption += '" . addslashes(GoogleMaps::fixBlockDirection(GoogleMaps::fixTidy($captionNoNewlines), $this->mLanguage->isRTL())) . "';";
         }
         // if there's tabs add them to the marker
     } elseif (is_array($pCaption) && count($pCaption)) {
         // dump the tabs from the previous marker
         $tabs = array();
         foreach ($pCaption as $t) {
             $tabs[] = "new GInfoWindowTab('" . addslashes(GoogleMaps::fixStringDirection($t['title'], $this->mLanguage->isRTL())) . "', '" . addslashes(preg_replace('/[\\r\\n]+/', ' ', GoogleMaps::fixBlockDirection(GoogleMaps::fixTidy($t['gm-caption']), $this->mLanguage->isRTL()))) . "')";
         }
         $this->mOutput .= " marker.tabs = [ " . implode(',', $tabs) . " ]; ";
     }
     // add the marker to the map
     $this->mOutput .= " map.addOverlay(marker);";
 }