改变空间导航模式,可以弹出窗口显示title和thumbnail
This commit is contained in:
parent
7ef35af725
commit
b6e4f41039
|
@ -263,7 +263,7 @@ class DataController extends Zend_Controller_Action
|
|||
}
|
||||
/*
|
||||
* 时间浏览方式
|
||||
* todo:实现xml的缓存
|
||||
* todo:实现xml的缓存,基于时间的缓存(每天)?基于元数据修改的缓存,每次导入后都重新生成一次。
|
||||
*/
|
||||
function timelineAction()
|
||||
{
|
||||
|
@ -303,7 +303,7 @@ class DataController extends Zend_Controller_Action
|
|||
$id = (int)$this->_request->getParam('id');
|
||||
$where='';
|
||||
if (!empty($id)) { $where=' where id='.$id; }
|
||||
$sql='select id,west,south,north,east,title from metadata'.$where;
|
||||
$sql='select id,uuid,west,south,north,east,title from metadata'.$where;
|
||||
$state=$db->query($sql);
|
||||
$rows=$state->fetchAll();
|
||||
$geomd=new GeoMetaData();
|
||||
|
@ -315,6 +315,8 @@ class DataController extends Zend_Controller_Action
|
|||
$feature=new Geofeature();
|
||||
$feature->id=$row['id'];
|
||||
$feature->addProperties('title',$row['title']);
|
||||
$feature->addProperties('uuid',$row['uuid']);
|
||||
$feature->addProperties('id',$row['id']);
|
||||
$feature->geometry=$box;
|
||||
$geomd->addFeature($feature);
|
||||
}
|
||||
|
|
|
@ -12,15 +12,16 @@
|
|||
$this->headScript()->appendFile('/js/OpenLayers.js');
|
||||
$this->headLink()->appendStylesheet('/js/theme/default/style.css');
|
||||
?>
|
||||
<script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAACD-MqkkoOm60o_dvwdcKVhRBSKpgcP88GYi6r2Of16IkMX_4YhSBQsywCi4J2_fh4nBuWmK7gyRjLg'></script>
|
||||
<!-- <script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAACD-MqkkoOm60o_dvwdcKVhRBSKpgcP88GYi6r2Of16IkMX_4YhSBQsywCi4J2_fh4nBuWmK7gyRjLg'></script> -->
|
||||
<script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAACD-MqkkoOm60o_dvwdcKVhThiRESR0xRCe9JKd36EL3glTk0OxTsRzifkUWmTTrYWaE7dY1lYUlGxA'></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>
|
||||
<div id='map' style="clear:left;height:500px;border:1px;"></div>
|
||||
<script type="text/javascript">
|
||||
var map;
|
||||
var map,selectedFeature;
|
||||
|
||||
map = new OpenLayers.Map('map');
|
||||
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
||||
|
@ -30,32 +31,54 @@
|
|||
{type: G_PHYSICAL_MAP}
|
||||
);
|
||||
var gmap = new OpenLayers.Layer.Google(
|
||||
"Google Streets" // the default
|
||||
"Google Streets", // the default
|
||||
{numZoomLevels: 20}
|
||||
);
|
||||
var ghyb = new OpenLayers.Layer.Google(
|
||||
"Google Hybrid",
|
||||
{type: G_HYBRID_MAP}
|
||||
{type: G_HYBRID_MAP, numZoomLevels: 20}
|
||||
);
|
||||
var gsat = new OpenLayers.Layer.Google(
|
||||
"Google Satellite",
|
||||
{type: G_SATELLITE_MAP}
|
||||
{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=/data/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);
|
||||
map.addControl(sf);
|
||||
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>
|
||||
|
|
Loading…
Reference in New Issue