westdc-zf1/application/default/views/scripts/data/map.phtml

62 lines
2.5 KiB
PHTML
Executable File

<?php
$this->headTitle($this->config->title->site);
$this->headTitle($this->config->title->data);
$this->headTitle("空间浏览");
$this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/metadata.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/data">'.$this->config->title->data.'</a>');
$this->breadcrumb('<a href="/data/tag">空间浏览</a>');
if (!empty($this->codename)) $this->breadcrumb($this->codename);
$this->breadcrumb()->setSeparator(' > ');
$this->headScript()->appendFile('/js/OpenLayers.js');
$this->headLink()->appendStylesheet('/js/theme/default/style.css');
?>
<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAACD-MqkkoOm60o_dvwdcKVhRBSKpgcP88GYi6r2Of16IkMX_4YhSBQsywCi4J2_fh4nBuWmK7gyRjLg'></script>
<div id='tools'>
<?= $this->partial('data/tools.phtml'); ?>
</div>
<div id='leftnav'>
</div>
<div id='map' style="clear:left;height:400px;border:1px;"></div>
<script type="text/javascript">
var map;
map = new OpenLayers.Map('map');
map.addControl(new OpenLayers.Control.LayerSwitcher());
var gphy = new OpenLayers.Layer.Google(
"Google Physical",
{type: G_PHYSICAL_MAP}
);
var gmap = new OpenLayers.Layer.Google(
"Google Streets" // the default
);
var ghyb = new OpenLayers.Layer.Google(
"Google Hybrid",
{type: G_HYBRID_MAP}
);
var gsat = new OpenLayers.Layer.Google(
"Google Satellite",
{type: G_SATELLITE_MAP}
);
var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'} );
map.addLayers([ol_wms,gphy, gmap, ghyb, gsat]);
map.setCenter(new OpenLayers.LonLat(102, 36), 4);
var ajax=new OpenLayers.Ajax.Request('/data/json<?php echo $this->params; ?>',{method:'get',onSuccess:featureresult});
function featureresult(response){
var feature1= eval('(' + response.responseText + ')');
//alert(feature1.type);
var geojson_format = new OpenLayers.Format.GeoJSON();
var vector_layer = new OpenLayers.Layer.Vector('metadata');
map.addLayer(vector_layer);
vector_layer.addFeatures(geojson_format.read(feature1));
var sf = new OpenLayers.Control.SelectFeature(vector_layer);
map.addControl(sf);
sf.activate();
}
</script>