Exemplo n.º 1
0
 /**
  * Encode a feature group.
  *
  * @param GeoJson $geoJson The layer group.
  * @param Encoder $encoder The builder.
  *
  * @return bool
  */
 public function encodeGeoJson(GeoJson $geoJson, Encoder $encoder)
 {
     $buffer = sprintf('%s = L.geoJson(%s, %s);', $encoder->encodeReference($geoJson), $encoder->encodeValue($geoJson->getInitializationData()), $encoder->encodeValue($geoJson->getOptions()));
     foreach ($geoJson->getLayers() as $layer) {
         $buffer .= "\n" . sprintf('%s.addLayer(%s);', $encoder->encodeReference($geoJson), $encoder->encodeReference($layer));
     }
     return $buffer;
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function encode(Encoder $encoder, $flags = null)
 {
     $name = $this->encodeName();
     $buffer = sprintf('%s = L.tileLayer.provider(\'' . $name . '\', %s)' . $encoder->close($flags), $encoder->encodeReference($this), $encoder->encodeValue(array('app_id' => $this->getAppId(), 'app_code' => $this->getAppCode())));
     $buffer .= $this->encodeMethodCalls($this->getMethodCalls(), $encoder, $flags);
     return $buffer;
 }
Exemplo n.º 3
0
 /**
  * Encode an control.
  *
  * @param string          $name    Control name.
  * @param AbstractControl $control The control object.
  * @param Encoder         $encoder Javascript encoder.
  * @param null            $flags   Encoder flags.
  *
  * @return string
  */
 protected function encodeSimpleControl($name, AbstractControl $control, Encoder $encoder, $flags = null)
 {
     $buffer = sprintf('%s = L.%s(%s)%s', $encoder->encodeReference($control), $name, $encoder->encodeValue($control->getOptions()), $encoder->close($flags));
     $buffer .= $this->encodeMethodCalls($control->getMethodCalls(), $encoder, $flags);
     return $buffer;
 }
Exemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function encode(Encoder $encoder, $flags = null)
 {
     $template = '%s(%s, %s, %s)%s';
     $buffer = '';
     if ($this->getCustomLayer()) {
         $ref = $encoder->encodeReference($this->getCustomLayer());
     } else {
         $template = $encoder->encodeReference($this) . ' = ' . $template;
         $ref = 'null';
     }
     $buffer .= sprintf($template, strtolower(static::getType()), $encoder->encodeValue($this->getUrl()), $encoder->encodeArray($this->getOptions(), JSON_FORCE_OBJECT), $ref, $encoder->close($flags));
     $buffer .= $this->encodeMethodCalls($this->getMethodCalls(), $encoder, $flags);
     return $buffer;
 }
Exemplo n.º 5
0
 /**
  * Get layer information, so that label is used.
  *
  * @param Layer[] $layers  The layers.
  * @param Encoder $encoder The encoder.
  *
  * @return array
  */
 private function encodeLayersInformation($layers, Encoder $encoder)
 {
     $prepared = '';
     foreach ($layers as $layer) {
         if ($prepared) {
             $prepared .= ', ';
         }
         $prepared .= sprintf('%s: %s', $encoder->encodeValue($layer->getLabel()), $encoder->encodeReference($layer));
     }
     return '{' . $prepared . '}';
 }
Exemplo n.º 6
0
 /**
  * Encode a vector.
  *
  * @param string  $type    The type name.
  * @param Vector  $vector  The vector.
  * @param Encoder $builder The builder.
  *
  * @return string
  */
 private function doVectorEncode($type, Vector $vector, Encoder $builder)
 {
     return sprintf('%s = L.%s(%s, %s);', $builder->encodeReference($vector), $type, $builder->encodeArray($vector->getLatLngs()), $builder->encodeValue($vector->getOptions()));
 }