GeoView : Some cleaning. Some corrections with googlev3 crosshair.
Resizing now ok with a new crosshair implementation for googlev3. svn: r15705
This commit is contained in:
parent
864c79e446
commit
b2886e3dad
@ -320,36 +320,50 @@ Mapstraction: {
|
|||||||
|
|
||||||
addCrosshair: function(Cross, crosshairSize, divid) {
|
addCrosshair: function(Cross, crosshairSize, divid) {
|
||||||
var map = this.maps[this.api];
|
var map = this.maps[this.api];
|
||||||
if ( map.init == true ) {
|
if ( map.init == true ) {
|
||||||
cross=document.getElementById("Googlev3_Control_CrossHair");
|
cross=document.getElementById("Googlev3_Control_CrossHair");
|
||||||
cross.style.visibility = 'visible';
|
cross.style.visibility = 'visible';
|
||||||
return map.crosshair;
|
return map.crosshair;
|
||||||
};
|
};
|
||||||
var container = map.getDiv();
|
var container = map.getDiv();
|
||||||
|
map.divid=divid;
|
||||||
|
// Create a div to hold the control.
|
||||||
|
var controlDiv = document.createElement('DIV');
|
||||||
|
controlDiv.style.padding = '0px';
|
||||||
|
controlDiv.style.width='100%';
|
||||||
|
controlDiv.style.height='100%';
|
||||||
|
var controlUI = document.createElement('DIV');
|
||||||
|
controlUI.style.padding = '0px';
|
||||||
|
controlUI.style.width='100%';
|
||||||
|
controlUI.style.height='100%';
|
||||||
|
controlDiv.appendChild(controlUI);
|
||||||
|
// Create a crosshair.
|
||||||
var crosshair=document.createElement("img");
|
var crosshair=document.createElement("img");
|
||||||
crosshair.id = "Googlev3_Control_CrossHair";
|
crosshair.id = "Googlev3_Control_CrossHair";
|
||||||
crosshair.src=Cross;
|
crosshair.src=Cross;
|
||||||
crosshair.style.width=crosshairSize+'px';
|
crosshair.style.width=crosshairSize+'px';
|
||||||
crosshair.style.height=crosshairSize+'px';
|
crosshair.style.height=crosshairSize+'px';
|
||||||
crosshair.style.border='0';
|
crosshair.style.border='0';
|
||||||
crosshair.style.position='fixed';
|
crosshair.style.position='fixed';
|
||||||
this.X = (parseInt(container.offsetWidth) / 2)+8-(crosshairSize / 2) + 'px';
|
olbox=document.getElementById(divid);
|
||||||
this.Y = (parseInt(container.offsetHeight) / 2)+8-(crosshairSize / 2) + 'px';
|
crosshair.style.margin=-(crosshairSize / 2) + 'px';
|
||||||
crosshair.style.top=this.Y;
|
crosshair.style.top='50%';
|
||||||
crosshair.style.left=this.X;
|
crosshair.style.left='50%';
|
||||||
|
crosshair.style.visibility = 'visible';
|
||||||
crosshair.style.zIndex='1500';
|
crosshair.style.zIndex='1500';
|
||||||
container.appendChild(crosshair);
|
controlUI.appendChild(crosshair);
|
||||||
|
container.appendChild(controlDiv);
|
||||||
map.crosshair=crosshair;
|
map.crosshair=crosshair;
|
||||||
map.init = true;
|
map.init = true;
|
||||||
return crosshair;
|
return controlDiv;
|
||||||
},
|
},
|
||||||
|
|
||||||
removeCrosshair: function(element) {
|
removeCrosshair: function(element) {
|
||||||
var map = this.maps[this.api];
|
var map = this.maps[this.api];
|
||||||
if ( map.init == true ) {
|
if ( map.init == true ) {
|
||||||
cross=document.getElementById('Googlev3_Control_CrossHair');
|
cross=document.getElementById('Googlev3_Control_CrossHair');
|
||||||
cross.style.visibility = 'hidden';
|
cross.style.visibility = 'hidden';
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
mousePosition: function(element) {
|
mousePosition: function(element) {
|
||||||
|
@ -362,52 +362,50 @@ mxn.register('openlayers', {
|
|||||||
|
|
||||||
addCrosshair: function(Cross, crosshairSize, divid) {
|
addCrosshair: function(Cross, crosshairSize, divid) {
|
||||||
var map = this.maps[this.api];
|
var map = this.maps[this.api];
|
||||||
if ( map.init == true ) {
|
if ( map.init == true ) {
|
||||||
cross=document.getElementById('OpenLayers_Control_CrossHair');
|
cross=document.getElementById('OpenLayers_Control_CrossHair');
|
||||||
cross.style.visibility = 'visible';
|
cross.style.visibility = 'visible';
|
||||||
return map.centerIcon
|
return map.centerIcon
|
||||||
};
|
};
|
||||||
var centerIcon = document.createElement('div');
|
var centerIcon = document.createElement('div');
|
||||||
centerIcon.style.width='100%';
|
centerIcon.style.width='100%';
|
||||||
centerIcon.style.height='100%';
|
centerIcon.style.height='100%';
|
||||||
centerIcon.style.zIndex ='1500';
|
centerIcon.style.zIndex ='1500';
|
||||||
var imgLocation=OpenLayers.Util.getImagesLocation();
|
var imgLocation=OpenLayers.Util.getImagesLocation();
|
||||||
var sz=new OpenLayers.Size(crosshairSize,crosshairSize);
|
var sz=new OpenLayers.Size(crosshairSize,crosshairSize);
|
||||||
var img=Cross;
|
var img=Cross;
|
||||||
function crosshairResize() {
|
function crosshairResize() {
|
||||||
//var olbox = document.getElementById("geo-map");
|
var olbox = document.getElementById(divid);
|
||||||
var olbox = document.getElementById(divid);
|
this.X = (parseInt(olbox.offsetWidth) / 2)-(crosshairSize / 2) + 'px';
|
||||||
this.X = (parseInt(olbox.offsetWidth) / 2)-(crosshairSize / 2) + 'px';
|
this.Y = (parseInt(olbox.offsetHeight) / 2)-(crosshairSize / 2) + 'px';
|
||||||
this.Y = (parseInt(olbox.offsetHeight) / 2)-(crosshairSize / 2) + 'px';
|
cross=document.getElementById('OpenLayers_Control_CrossHair');
|
||||||
cross=document.getElementById('OpenLayers_Control_CrossHair');
|
cross.style.top=this.Y;
|
||||||
cross.style.top=this.Y;
|
cross.style.left=this.X;
|
||||||
cross.style.left=this.X;
|
};
|
||||||
};
|
var olbox = document.getElementById(divid);
|
||||||
var olbox = document.getElementById("geo-map");
|
map.CrossHair=OpenLayers.Util.createAlphaImageDiv(
|
||||||
var olbox = document.getElementById(divid);
|
"OpenLayers_Control_CrossHair",null,sz,img,"absolute");
|
||||||
map.CrossHair=OpenLayers.Util.createAlphaImageDiv(
|
map.CrossHair.style.zIndex ='1500';
|
||||||
"OpenLayers_Control_CrossHair",null,sz,img,"absolute");
|
olbox.addEventListener("load",crosshairResize,true);
|
||||||
map.CrossHair.style.zIndex ='1500';
|
OpenLayers.Element.addClass(map.CrossHair,"CrossHair");
|
||||||
olbox.addEventListener("load",crosshairResize,true);
|
OpenLayers.Control.Crosshair = OpenLayers.Class.create();
|
||||||
OpenLayers.Element.addClass(map.CrossHair,"CrossHair");
|
centerIcon.id = "mapCenter";
|
||||||
OpenLayers.Control.Crosshair = OpenLayers.Class.create();
|
viewport=document.getElementById('OpenLayers.Map_2_OpenLayers_ViewPort')
|
||||||
centerIcon.id = "mapCenter";
|
viewport.appendChild(centerIcon);
|
||||||
viewport=document.getElementById('OpenLayers.Map_2_OpenLayers_ViewPort')
|
centerIcon.appendChild(map.CrossHair);
|
||||||
viewport.appendChild(centerIcon);
|
crosshairResize();
|
||||||
centerIcon.appendChild(map.CrossHair);
|
map.init=true;
|
||||||
crosshairResize();
|
map.centerIcon=centerIcon
|
||||||
map.init=true;
|
return centerIcon
|
||||||
map.centerIcon=centerIcon
|
|
||||||
return centerIcon
|
|
||||||
},
|
},
|
||||||
|
|
||||||
removeCrosshair: function(crosshair) {
|
removeCrosshair: function(crosshair) {
|
||||||
var map = this.maps[this.api];
|
var map = this.maps[this.api];
|
||||||
if ( map.init == true ) {
|
if ( map.init == true ) {
|
||||||
cross=document.getElementById('OpenLayers_Control_CrossHair');
|
cross=document.getElementById('OpenLayers_Control_CrossHair');
|
||||||
cross.style.visibility = 'hidden';
|
cross.style.visibility = 'hidden';
|
||||||
};
|
};
|
||||||
return 0;
|
return 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
mousePosition: function(element) {
|
mousePosition: function(element) {
|
||||||
|
@ -194,7 +194,7 @@ _HTMLHEADER = '''\
|
|||||||
|
|
||||||
_JAVASCRIPT = '''\
|
_JAVASCRIPT = '''\
|
||||||
<script>
|
<script>
|
||||||
var gmarkers = []; var min = 0; var zoom = 0; var uzoom = 0;
|
var gmarkers = []; var min = 0; var zoom = 0; var uzoom = 0; var ucross = 0;
|
||||||
var pos = 0; var mapstraction;
|
var pos = 0; var mapstraction;
|
||||||
var regrep = new RegExp(\"default\",\"g\");
|
var regrep = new RegExp(\"default\",\"g\");
|
||||||
var current_map; var ulat; var ulon; var default_icon;
|
var current_map; var ulat; var ulon; var default_icon;
|
||||||
@ -255,7 +255,7 @@ _JAVASCRIPT = '''\
|
|||||||
var DivId='geo-map';
|
var DivId='geo-map';
|
||||||
function addcrosshair(state,Cross,DivId) {
|
function addcrosshair(state,Cross,DivId) {
|
||||||
if ( state == 0 ) {
|
if ( state == 0 ) {
|
||||||
if (crossh) mapstraction.removeCrosshair(crossh);
|
if (crossh != null) mapstraction.removeCrosshair(crossh);
|
||||||
} else {
|
} else {
|
||||||
crossh = mapstraction.addCrosshair(Cross,crosshairsSize,DivId);
|
crossh = mapstraction.addCrosshair(Cross,crosshairsSize,DivId);
|
||||||
};
|
};
|
||||||
@ -268,7 +268,7 @@ _HTMLTRAILER = '''\
|
|||||||
savezoomandposition(mapstraction);
|
savezoomandposition(mapstraction);
|
||||||
mapstraction.enableScrollWheelZoom();
|
mapstraction.enableScrollWheelZoom();
|
||||||
window.onresize=function() {
|
window.onresize=function() {
|
||||||
winheight=window.innerHeight-15;
|
winheight=window.innerHeight-16;
|
||||||
winwidth='100%';
|
winwidth='100%';
|
||||||
mapstraction.resizeTo(winwidth,winheight+'px');
|
mapstraction.resizeTo(winwidth,winheight+'px');
|
||||||
setcenterandzoom(mapstraction,uzoom,ulat,ulon);
|
setcenterandzoom(mapstraction,uzoom,ulat,ulon);
|
||||||
@ -547,6 +547,7 @@ class GeoView(HtmlView):
|
|||||||
Do we have a crosshair ?
|
Do we have a crosshair ?
|
||||||
"""
|
"""
|
||||||
if self.javascript_ready:
|
if self.javascript_ready:
|
||||||
|
_LOG.debug("crosshair : %d" % self._config.get("preferences.crosshair") )
|
||||||
self.renderer.execute_script("javascript:addcrosshair('%d','%s','geo-map')"
|
self.renderer.execute_script("javascript:addcrosshair('%d','%s','geo-map')"
|
||||||
% (self._config.get("preferences.crosshair"), self.crosspath)
|
% (self._config.get("preferences.crosshair"), self.crosspath)
|
||||||
)
|
)
|
||||||
@ -803,6 +804,7 @@ class GeoView(HtmlView):
|
|||||||
url += '&zoom=%d' % int(self.realzoom)
|
url += '&zoom=%d' % int(self.realzoom)
|
||||||
url += '&lat=%s' % str(self.reallatitude)
|
url += '&lat=%s' % str(self.reallatitude)
|
||||||
url += '&lon=%s' % str(self.reallongitude)
|
url += '&lon=%s' % str(self.reallongitude)
|
||||||
|
url += '&cross=%s' % int(self._config.get("preferences.crosshair"))
|
||||||
self._openurl(url)
|
self._openurl(url)
|
||||||
self._create_pages_selection(cpage, int(maxp))
|
self._create_pages_selection(cpage, int(maxp))
|
||||||
self._savezoomandposition()
|
self._savezoomandposition()
|
||||||
@ -860,6 +862,7 @@ class GeoView(HtmlView):
|
|||||||
url += '&zoom=%d' % int(self.realzoom)
|
url += '&zoom=%d' % int(self.realzoom)
|
||||||
url += '&lat=%s' % str(self.reallatitude)
|
url += '&lat=%s' % str(self.reallatitude)
|
||||||
url += '&lon=%s' % str(self.reallongitude)
|
url += '&lon=%s' % str(self.reallongitude)
|
||||||
|
url += '&cross=%s' % int(self._config.get("preferences.crosshair"))
|
||||||
self._openurl(url)
|
self._openurl(url)
|
||||||
(current, maxp ) = self.pages[1].get_label().split('/', 1)
|
(current, maxp ) = self.pages[1].get_label().split('/', 1)
|
||||||
self._create_pages_selection(entry[2], int(maxp))
|
self._create_pages_selection(entry[2], int(maxp))
|
||||||
@ -1050,14 +1053,16 @@ class GeoView(HtmlView):
|
|||||||
url += '&zoom=%d' % int(self.realzoom)
|
url += '&zoom=%d' % int(self.realzoom)
|
||||||
url += '&lat=%s' % str(self.reallatitude)
|
url += '&lat=%s' % str(self.reallatitude)
|
||||||
url += '&lon=%s' % str(self.reallongitude)
|
url += '&lon=%s' % str(self.reallongitude)
|
||||||
#self.renderer.execute_script(
|
url += '&cross=%s' % int(self._config.get("preferences.crosshair"))
|
||||||
# "javascript:swapmap('%s')" % usedmap )
|
|
||||||
self._openurl(url)
|
self._openurl(url)
|
||||||
self._savezoomandposition()
|
self._savezoomandposition()
|
||||||
if self.displaytype != "places":
|
if self.displaytype != "places":
|
||||||
# Need to wait the page is loaded to set the markers.
|
# Need to wait the page is loaded to set the markers and crosshair.
|
||||||
gobject.timeout_add(1500, self._set_markers_and_crosshair_on_page,
|
gobject.timeout_add(1500, self._set_markers_and_crosshair_on_page,
|
||||||
self.last_year)
|
self.last_year)
|
||||||
|
else:
|
||||||
|
# Need to wait the page is loaded to set the crosshair.
|
||||||
|
gobject.timeout_add(1500, self.config_crosshair , False, False, False, False)
|
||||||
|
|
||||||
def _set_markers_and_crosshair_on_page(self, widget):
|
def _set_markers_and_crosshair_on_page(self, widget):
|
||||||
"""
|
"""
|
||||||
@ -1078,10 +1083,7 @@ class GeoView(HtmlView):
|
|||||||
elif year != "no":
|
elif year != "no":
|
||||||
self.last_selected_year = year
|
self.last_selected_year = year
|
||||||
self._call_js_selectmarkers(year)
|
self._call_js_selectmarkers(year)
|
||||||
if self.javascript_ready:
|
self.config_crosshair(False, False, False, False)
|
||||||
self.renderer.execute_script("javascript:addcrosshair('%d','%s','geo-map')" %
|
|
||||||
(self._config.get("preferences.crosshair"),
|
|
||||||
self.crosspath))
|
|
||||||
|
|
||||||
def _call_js_selectmarkers(self, year):
|
def _call_js_selectmarkers(self, year):
|
||||||
"""
|
"""
|
||||||
@ -1697,7 +1699,6 @@ class GeoView(HtmlView):
|
|||||||
self.yearint,
|
self.yearint,
|
||||||
self.maxyear)
|
self.maxyear)
|
||||||
self.years.show()
|
self.years.show()
|
||||||
_LOG.debug("window.height = %d" % (self.height - self.header_size) )
|
|
||||||
self.mapview.write(
|
self.mapview.write(
|
||||||
'<div id="geo-map" style="' +
|
'<div id="geo-map" style="' +
|
||||||
'height: %dpx; width: %s; " ></div>\n'
|
'height: %dpx; width: %s; " ></div>\n'
|
||||||
@ -1708,15 +1709,13 @@ class GeoView(HtmlView):
|
|||||||
' if (args.lat) ulat=parseFloat(args.lat);\n' +
|
' if (args.lat) ulat=parseFloat(args.lat);\n' +
|
||||||
' if (args.lon) ulon=parseFloat(args.lon);\n' +
|
' if (args.lon) ulon=parseFloat(args.lon);\n' +
|
||||||
' if (args.zoom) uzoom=parseInt(args.zoom);\n' +
|
' if (args.zoom) uzoom=parseInt(args.zoom);\n' +
|
||||||
|
' if (args.cross) ucross=parseInt(args.cross);\n' +
|
||||||
' mapstraction = new mxn.Mapstraction' +
|
' mapstraction = new mxn.Mapstraction' +
|
||||||
"('geo-map',current_map);\n" +
|
"('geo-map',current_map);\n" +
|
||||||
' mapstraction.addControls(' +
|
' mapstraction.addControls(' +
|
||||||
"{ pan: true, zoom: 'small', " +
|
"{ pan: true, zoom: 'small', " +
|
||||||
'scale: true, map_type: true });\n' +
|
'scale: true, map_type: true });\n' +
|
||||||
"addcrosshair('%d', '%s', 'geo-map');"
|
"addcrosshair(ucross, '%s', 'geo-map');" % self.crosspath
|
||||||
% (self._config.get("preferences.crosshair"),
|
|
||||||
self.crosspath)
|
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def _create_needed_javascript(self):
|
def _create_needed_javascript(self):
|
||||||
@ -1891,6 +1890,7 @@ class GeoView(HtmlView):
|
|||||||
url += '&zoom=%d' % int(self.realzoom)
|
url += '&zoom=%d' % int(self.realzoom)
|
||||||
url += '&lat=%s' % str(self.reallatitude)
|
url += '&lat=%s' % str(self.reallatitude)
|
||||||
url += '&lon=%s' % str(self.reallongitude)
|
url += '&lon=%s' % str(self.reallongitude)
|
||||||
|
url += '&cross=%s' % int(self._config.get("preferences.crosshair"))
|
||||||
self._openurl(url)
|
self._openurl(url)
|
||||||
self.placebox.set_model(self.plist)
|
self.placebox.set_model(self.plist)
|
||||||
self.placebox.thaw_child_notify()
|
self.placebox.thaw_child_notify()
|
||||||
|
Loading…
Reference in New Issue
Block a user