/** * Renders the encoded polyline * * @param Ivory\GoogleMapBundle\Model\Overlays\EncodedPolyline $encodedPolyline * @param Ivory\GoogleMapBundle\Model\Map $map * @return string HTML output */ public function render(EncodedPolyline $encodedPolyline, Map $map) { $polylineOptions = $encodedPolyline->getOptions(); $polylineJSONOptions = sprintf('{"map":%s,"path":%s', $map->getJavascriptVariable(), $this->encodingHelper->renderDecodePath($encodedPolyline->getValue())); if (!empty($polylineOptions)) { $polylineJSONOptions .= ',' . substr(json_encode($polylineOptions), 1); } else { $polylineJSONOptions .= '}'; } return sprintf('var %s = new google.maps.Polyline(%s);' . PHP_EOL, $encodedPolyline->getJavascriptVariable(), $polylineJSONOptions); }
/** * Checks the render decode path method with special chars */ public function testRenderDecodePathWithSpecialChars() { $this->assertEquals(self::$encodingHelper->renderDecodePath('v"a\\lu\'e'), 'google.maps.geometry.encoding.decodePath("v\\"a\\\\lu\\\'e")'); }