/** * 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; }