コード例 #1
0
 protected function setUp()
 {
     $this->mockFrontEnd = $this->getMock('tslib_fe', array('dummy'), array(), '', FALSE);
     $GLOBALS['TSFE'] = $this->mockFrontEnd;
     $this->mapPointWithCoordinates = $this->getMock('tx_oelib_Interface_MapPoint');
     $this->mapPointWithCoordinates->expects(self::any())->method('hasGeoCoordinates')->will(self::returnValue(TRUE));
     $this->mapPointWithCoordinates->expects(self::any())->method('getGeoCoordinates')->will(self::returnValue(array('latitude' => 1.2, 'longitude' => 3.4)));
     $this->subject = new Tx_Oelib_ViewHelpers_GoogleMapsViewHelper();
 }
コード例 #2
0
 /**
  * Creates the JavaScript for the info window of $mapPoint.
  *
  * @param tx_oelib_Interface_MapPoint $mapPoint
  *        the map point for which to create the info window
  * @param string $markerVariableName
  *        valid name of the marker JavaScript variable, must not be empty
  * @param int $index
  *        the zero-based index of the map marker, must be >= 0
  *
  * @return string
  *         JavaScript code for the info window, will be empty if $mapPoint
  *         does not have info window content
  */
 protected function createInfoWindowJavaScript(tx_oelib_Interface_MapPoint $mapPoint, $markerVariableName, $index)
 {
     if (!$mapPoint->hasInfoWindowContent()) {
         return '';
     }
     $infoWindowVariableName = 'infoWindow_' . $index;
     $escapedInfoWindowContent = str_replace(array('\\', '"', LF, CR), array('\\\\', '\\"', '\\n', '\\r'), $mapPoint->getInfoWindowContent());
     return 'var ' . $infoWindowVariableName . ' = new google.maps.InfoWindow({content: "' . $escapedInfoWindowContent . '"});' . LF . 'google.maps.event.addListener(' . $markerVariableName . ', "click", function() {' . LF . '  ' . $infoWindowVariableName . '.open(map, ' . $markerVariableName . ');' . LF . '});' . LF;
 }