Skip to content

Instantly share code, notes, and snippets.

@roy-bukapeta
Created September 22, 2016 04:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roy-bukapeta/318d7146813c8cf6c2cbbbe836b36660 to your computer and use it in GitHub Desktop.
Save roy-bukapeta/318d7146813c8cf6c2cbbbe836b36660 to your computer and use it in GitHub Desktop.
Function openlayer
public function ScriptOpenlayers(){
/***
* Script dasar openlayers
***/
$setView = explode(",", $this->options['setView']);
$view = $this->getView();
$view->registerJs("
var map".$this->id." = new ol.Map({
target: 'map".$this->id."',
layers: [
new ol.layer.Tile({
source: new ol.source.XYZ({
url: 'https://api.mapbox.com/styles/v1/mapbox/streets-v9/tiles/256/{z}/{x}/{y}?access_token=pk.eyJ1IjoiLWhhYmliLSIsImEiOiJjaWdjbmpsZzE0MXM3dmptM3NzN292NWVhIn0.AfZ7s3jnuqK-2nPzbfl7IA'
})
})
],
view: new ol.View({
projection: 'EPSG:4326',
center: [" . $setView[1] . ", " . $setView[0] . "],
zoom: " . $this->options['setZoom'] . ",
maxResolution: 0.703125
})
});
", \yii\web\View::POS_END);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment