84 lines
3.6 KiB
PHTML
Executable File
84 lines
3.6 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');
|
|
$this->headScript()->appendFile('http://maps.google.cn/maps?file=api&v=2&key='.$this->config->google->maps->api);
|
|
?>
|
|
<div id='tools'>
|
|
<?= $this->partial('data/tools.phtml'); ?>
|
|
</div>
|
|
<div id='leftnav'>
|
|
</div>
|
|
<div id='map' style="clear:left;height:500px;border:1px;"></div>
|
|
<script type="text/javascript">
|
|
var map,selectedFeature;
|
|
|
|
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
|
|
{numZoomLevels: 20}
|
|
);
|
|
var ghyb = new OpenLayers.Layer.Google(
|
|
"Google Hybrid",
|
|
{type: G_HYBRID_MAP, numZoomLevels: 20}
|
|
);
|
|
var gsat = new OpenLayers.Layer.Google(
|
|
"Google Satellite",
|
|
{type: G_SATELLITE_MAP, numZoomLevels: 20}
|
|
);
|
|
|
|
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);
|
|
|
|
function onPopupClose(evt) {
|
|
selectControl.unselect(selectedFeature);
|
|
}
|
|
function onFeatureSelect(feature) {
|
|
selectedFeature = feature;
|
|
popup = new OpenLayers.Popup.FramedCloud("chicken",
|
|
feature.geometry.getBounds().getCenterLonLat(),
|
|
null,
|
|
"<div style='font-size:.8em'><a href=/data/"+feature.attributes['uuid']+">"+ feature.attributes['title'] +"</a> | <a href=/data/map/id/"+feature.attributes['id']+"><img src=/images/map.gif></a><hr /><img src=/service/thumb/id/" + feature.attributes['id']+"/></div>",
|
|
null, false, onPopupClose);
|
|
feature.popup = popup;
|
|
map.addPopup(popup);
|
|
}
|
|
function onFeatureUnselect(feature) {
|
|
map.removePopup(feature.popup);
|
|
feature.popup.destroy();
|
|
feature.popup = null;
|
|
}
|
|
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,{onSelect:onFeatureSelect,onUnselect:onFeatureUnselect});
|
|
map.addControl(sf);
|
|
sf.activate();
|
|
}
|
|
|
|
|
|
</script>
|