改变空间导航模式,可以弹出窗口显示title和thumbnail

This commit is contained in:
wlx 2009-12-18 13:23:28 +00:00
parent 7ef35af725
commit b6e4f41039
2 changed files with 39 additions and 14 deletions

View File

@ -263,7 +263,7 @@ class DataController extends Zend_Controller_Action
} }
/* /*
* 时间浏览方式 * 时间浏览方式
* todo:实现xml的缓存 * todo:实现xml的缓存,基于时间的缓存(每天)?基于元数据修改的缓存,每次导入后都重新生成一次。
*/ */
function timelineAction() function timelineAction()
{ {
@ -303,7 +303,7 @@ class DataController extends Zend_Controller_Action
$id = (int)$this->_request->getParam('id'); $id = (int)$this->_request->getParam('id');
$where=''; $where='';
if (!empty($id)) { $where=' where id='.$id; } 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); $state=$db->query($sql);
$rows=$state->fetchAll(); $rows=$state->fetchAll();
$geomd=new GeoMetaData(); $geomd=new GeoMetaData();
@ -315,6 +315,8 @@ class DataController extends Zend_Controller_Action
$feature=new Geofeature(); $feature=new Geofeature();
$feature->id=$row['id']; $feature->id=$row['id'];
$feature->addProperties('title',$row['title']); $feature->addProperties('title',$row['title']);
$feature->addProperties('uuid',$row['uuid']);
$feature->addProperties('id',$row['id']);
$feature->geometry=$box; $feature->geometry=$box;
$geomd->addFeature($feature); $geomd->addFeature($feature);
} }

View File

@ -12,15 +12,16 @@
$this->headScript()->appendFile('/js/OpenLayers.js'); $this->headScript()->appendFile('/js/OpenLayers.js');
$this->headLink()->appendStylesheet('/js/theme/default/style.css'); $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> <!-- <script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAACD-MqkkoOm60o_dvwdcKVhRBSKpgcP88GYi6r2Of16IkMX_4YhSBQsywCi4J2_fh4nBuWmK7gyRjLg'></script> -->
<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAACD-MqkkoOm60o_dvwdcKVhThiRESR0xRCe9JKd36EL3glTk0OxTsRzifkUWmTTrYWaE7dY1lYUlGxA'></script>
<div id='tools'> <div id='tools'>
<?= $this->partial('data/tools.phtml'); ?> <?= $this->partial('data/tools.phtml'); ?>
</div> </div>
<div id='leftnav'> <div id='leftnav'>
</div> </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"> <script type="text/javascript">
var map; var map,selectedFeature;
map = new OpenLayers.Map('map'); map = new OpenLayers.Map('map');
map.addControl(new OpenLayers.Control.LayerSwitcher()); map.addControl(new OpenLayers.Control.LayerSwitcher());
@ -30,32 +31,54 @@
{type: G_PHYSICAL_MAP} {type: G_PHYSICAL_MAP}
); );
var gmap = new OpenLayers.Layer.Google( var gmap = new OpenLayers.Layer.Google(
"Google Streets" // the default "Google Streets", // the default
{numZoomLevels: 20}
); );
var ghyb = new OpenLayers.Layer.Google( var ghyb = new OpenLayers.Layer.Google(
"Google Hybrid", "Google Hybrid",
{type: G_HYBRID_MAP} {type: G_HYBRID_MAP, numZoomLevels: 20}
); );
var gsat = new OpenLayers.Layer.Google( var gsat = new OpenLayers.Layer.Google(
"Google Satellite", "Google Satellite",
{type: G_SATELLITE_MAP} {type: G_SATELLITE_MAP, numZoomLevels: 20}
); );
var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS", var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'} ); "http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'} );
map.addLayers([ol_wms,gphy, gmap, ghyb, gsat]); map.addLayers([ol_wms,gphy, gmap, ghyb, gsat]);
map.setCenter(new OpenLayers.LonLat(102, 36), 4); 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}); var ajax=new OpenLayers.Ajax.Request('/data/json<?php echo $this->params; ?>',{method:'get',onSuccess:featureresult});
function featureresult(response){ function featureresult(response){
var feature1= eval('(' + response.responseText + ')'); var feature1= eval('(' + response.responseText + ')');
//alert(feature1.type); //alert(feature1.type);
var geojson_format = new OpenLayers.Format.GeoJSON(); var geojson_format = new OpenLayers.Format.GeoJSON();
var vector_layer = new OpenLayers.Layer.Vector('metadata'); var vector_layer = new OpenLayers.Layer.Vector('metadata');
map.addLayer(vector_layer); map.addLayer(vector_layer);
vector_layer.addFeatures(geojson_format.read(feature1)); vector_layer.addFeatures(geojson_format.read(feature1));
var sf = new OpenLayers.Control.SelectFeature(vector_layer); var sf = new OpenLayers.Control.SelectFeature(vector_layer,{onSelect:onFeatureSelect,onUnselect:onFeatureUnselect});
map.addControl(sf); map.addControl(sf);
sf.activate(); sf.activate();
} }
</script> </script>