GeoView : Update mapstraction to version 215.
Switch between maps works. svn: r12928
This commit is contained in:
parent
57456a3fdf
commit
1c41b04d3d
@ -692,21 +692,27 @@ class GeoView(HtmlView):
|
||||
Ask to the browser to change the current map.
|
||||
"""
|
||||
self.renderer.execute_script(
|
||||
"javascript:mapstraction.swap(map,'"+usedmap+"')")
|
||||
"javascript:mapstraction.swap('"+usedmap+"','"+usedmap+"')")
|
||||
|
||||
def _alternate_map(self):
|
||||
"""
|
||||
return the alternate name of the map provider.
|
||||
"""
|
||||
if Config.get(Config.GEOVIEW_GOOGLEMAPS):
|
||||
alternate_map = "google"
|
||||
elif Config.get(Config.GEOVIEW_OPENLAYERS):
|
||||
alternate_map = "openlayers"
|
||||
elif Config.get(Config.GEOVIEW_YAHOO):
|
||||
alternate_map = "yahoo"
|
||||
elif Config.get(Config.GEOVIEW_MICROSOFT):
|
||||
alternate_map = "microsoft"
|
||||
return alternate_map
|
||||
|
||||
def ui_definition(self):
|
||||
"""
|
||||
Specifies the UIManager XML code that defines the menus and buttons
|
||||
associated with the interface.
|
||||
"""
|
||||
if Config.get(Config.GEOVIEW_GOOGLEMAPS):
|
||||
alternate_map = "GoogleMaps"
|
||||
elif Config.get(Config.GEOVIEW_OPENLAYERS):
|
||||
alternate_map = "OpenLayersMaps"
|
||||
elif Config.get(Config.GEOVIEW_YAHOO):
|
||||
alternate_map = "YahooMaps"
|
||||
elif Config.get(Config.GEOVIEW_MICROSOFT):
|
||||
alternate_map = "MicrosoftMaps"
|
||||
return '''<ui>
|
||||
<toolbar name="ToolBar">
|
||||
<placeholder name="CommonNavigation">
|
||||
@ -724,7 +730,7 @@ class GeoView(HtmlView):
|
||||
<toolitem action="AllPlacesMaps"/>
|
||||
</placeholder>
|
||||
</toolbar>
|
||||
</ui>''' % alternate_map
|
||||
</ui>''' % self._alternate_map()
|
||||
|
||||
def define_actions(self):
|
||||
"""
|
||||
@ -739,28 +745,28 @@ class GeoView(HtmlView):
|
||||
callback=self.select_openstreetmap_map,
|
||||
tip=_("Select OpenStreetMap Maps"))
|
||||
if Config.get(Config.GEOVIEW_GOOGLEMAPS):
|
||||
self._add_action('GoogleMaps', 'gramps-alternate-map',
|
||||
self._add_action('google', 'gramps-alternate-map',
|
||||
_('_Google Maps'),
|
||||
callback=self.select_google_map,
|
||||
tip=_("Select Google Maps."))
|
||||
elif Config.get(Config.GEOVIEW_OPENLAYERS):
|
||||
self._add_action('OpenLayersMaps', 'gramps-alternate-map',
|
||||
self._add_action('openlayers', 'gramps-alternate-map',
|
||||
_('_OpenLayers Maps'),
|
||||
callback=self.select_openlayers_map,
|
||||
tip=_("Select OpenLayers Maps."))
|
||||
elif Config.get(Config.GEOVIEW_YAHOO):
|
||||
self._add_action('YahooMaps', 'gramps-alternate-map',
|
||||
self._add_action('yahoo', 'gramps-alternate-map',
|
||||
_('_Yahoo! Maps'),
|
||||
callback=self.select_yahoo_map,
|
||||
tip=_("Select Yahoo Maps."))
|
||||
elif Config.get(Config.GEOVIEW_MICROSOFT):
|
||||
self._add_action('MicrosoftMaps', 'gramps-alternate-map',
|
||||
self._add_action('microsoft', 'gramps-alternate-map',
|
||||
_('_Microsoft Maps'),
|
||||
callback=self.select_microsoft_map,
|
||||
tip=_("Select Microsoft Maps"))
|
||||
self._add_action('AllPlacesMaps', gtk.STOCK_HOME, _('_All Places'),
|
||||
callback=self.all_places,
|
||||
tip=_("Attempt to view all places in the family tree."))
|
||||
callback=self.all_places,
|
||||
tip=_("Attempt to view all places in the family tree."))
|
||||
self._add_action('PersonMaps', 'gramps-person', _('_Person'),
|
||||
callback=self.person_places,
|
||||
tip=_("Attempt to view all the places where the selected people lived."))
|
||||
@ -988,28 +994,28 @@ class GeoView(HtmlView):
|
||||
self.mapview.write(" src=\"file://"+const.ROOT_DIR+"/")
|
||||
self.mapview.write("mapstraction/mapstraction.js\">\n")
|
||||
self.mapview.write(" </script>\n")
|
||||
if self.usedmap == "microsoft":
|
||||
self.mapview.write(" <script id=\"googleapiimport\" \n")
|
||||
self.mapview.write(" src=\"http://maps.google.com/")
|
||||
self.mapview.write("maps?file=api&v=2\"\n")
|
||||
self.mapview.write(" type=\"text/javascript\">\n")
|
||||
self.mapview.write(" </script>\n")
|
||||
alternatemap = self._alternate_map()
|
||||
if alternatemap == "microsoft":
|
||||
self.mapview.write(" <script type=\"text/javascript\"\n")
|
||||
self.mapview.write(" src=\"http://dev.virtualearth.net/")
|
||||
self.mapview.write("mapcontrol/mapcontrol.ashx?v=6\">\n")
|
||||
self.mapview.write(" </script>\n")
|
||||
elif self.usedmap == "yahoo":
|
||||
elif alternatemap == "yahoo":
|
||||
self.mapview.write(" <script type=\"text/javascript\"\n")
|
||||
self.mapview.write(" src=\"http://api.maps.yahoo.com/")
|
||||
self.mapview.write("ajaxymap?v=3.0&appid=MapstractionDemo\" ")
|
||||
self.mapview.write("type=\"text/javascript\">\n")
|
||||
self.mapview.write(" </script>\n")
|
||||
elif self.usedmap == "openlayers":
|
||||
elif alternatemap == "openlayers":
|
||||
self.mapview.write(" <script type=\"text/javascript\"\n")
|
||||
self.mapview.write(" src=\"http://openlayers.org/")
|
||||
self.mapview.write("api/OpenLayers.js\">\n")
|
||||
self.mapview.write(" </script>\n")
|
||||
else: # openstreetmap and google
|
||||
self.mapview.write(" <script id=\"googleapiimport\" \n")
|
||||
self.mapview.write(" src=\"http://maps.google.com/")
|
||||
self.mapview.write("maps?file=api&v=2\"\n")
|
||||
self.mapview.write(" type=\"text/javascript\">\n")
|
||||
self.mapview.write(" </script>\n")
|
||||
self.mapview.write(" <script>\n")
|
||||
self.mapview.write(" var gmarkers = [];\n")
|
||||
self.mapview.write(" var min = 0;\n")
|
||||
@ -1307,13 +1313,17 @@ class GeoView(HtmlView):
|
||||
This function create all markers for the specified person.
|
||||
"""
|
||||
margin = 10
|
||||
self.mapview.write(" <div id=\"map\" style=\"width: %dpx; " % \
|
||||
( self.width - margin*4 ))
|
||||
self.mapview.write("height: %dpx\"></div>\n" % ( self.height * 0.74 ))
|
||||
self.mapview.write(" <script type=\"text/javascript\">\n")
|
||||
self.mapview.write(" var mapstraction = new Mapstraction")
|
||||
self.mapview.write("('map','%s');\n" % self.usedmap)
|
||||
self.mapview.write(" mapstraction.addControls(")
|
||||
self.mapview.write("\n<div id=\"openstreetmap\" class=\"Mapstraction\"")
|
||||
self.mapview.write(" style=\"width: %dpx; " % (self.width - margin*4))
|
||||
self.mapview.write("height: %dpx\"></div>\n" % (self.height * 0.74))
|
||||
self.mapview.write("<div id=\"%s\" class=\"Mapstraction\"" % self._alternate_map())
|
||||
self.mapview.write(" style=\"display: none; ")
|
||||
self.mapview.write("width: %dpx; height: %dpx\"></div>\n" % \
|
||||
((self.width - margin*4), (self.height * 0.74 )))
|
||||
self.mapview.write("<script type=\"text/javascript\">\n")
|
||||
self.mapview.write(" var mapstraction = new Mapstraction")
|
||||
self.mapview.write("('openstreetmap','openstreetmap');\n")
|
||||
self.mapview.write(" mapstraction.addControls(")
|
||||
self.mapview.write("{ pan: true, zoom: 'large', ")
|
||||
self.mapview.write("overview: true, scale: true, map_type: true });\n")
|
||||
last = ""
|
||||
|
@ -2194,12 +2194,13 @@ Mapstraction.prototype.getCenter = function() {
|
||||
/**
|
||||
* setCenter sets the central point of the map
|
||||
* @param {LatLonPoint} point The point at which to center the map
|
||||
* @options {hash} optional parameters, such as {pan:true}
|
||||
*/
|
||||
Mapstraction.prototype.setCenter = function(point) {
|
||||
Mapstraction.prototype.setCenter = function(point, options) {
|
||||
if(this.loaded[this.api] === false) {
|
||||
var me = this;
|
||||
this.onload[this.api].push( function() {
|
||||
me.setCenter(point);
|
||||
me.setCenter(point, options);
|
||||
} );
|
||||
return;
|
||||
}
|
||||
@ -2215,14 +2216,16 @@ Mapstraction.prototype.setCenter = function(point) {
|
||||
break;
|
||||
case 'google':
|
||||
case 'openstreetmap':
|
||||
map.setCenter(point.toGoogle());
|
||||
break;
|
||||
if(options != null && options['pan']) { map.panTo(point.toGoogle()); }
|
||||
else { map.setCenter(point.toGoogle()); }
|
||||
break;
|
||||
case 'openlayers':
|
||||
map.setCenter(point.toOpenLayers());
|
||||
break;
|
||||
case 'microsoft':
|
||||
map.SetCenter(point.toMicrosoft());
|
||||
break;
|
||||
if(options != null && options['pan']) { map.PanToLatLong(point.toMicrosoft()); }
|
||||
else { map.SetCenter(point.toMicrosoft()); }
|
||||
break;
|
||||
case 'multimap':
|
||||
map.goToPosition(point.toMultiMap());
|
||||
break;
|
||||
@ -2463,7 +2466,7 @@ Mapstraction.prototype.visibleCenterAndZoom = function()
|
||||
|
||||
/**
|
||||
* Automatically sets center and zoom level to show all polylines
|
||||
* Takes into account radious of polyline
|
||||
* Takes into account radius of polyline
|
||||
* @param {Int} radius
|
||||
*/
|
||||
Mapstraction.prototype.polylineCenterAndZoom = function(radius)
|
||||
@ -2478,6 +2481,8 @@ Mapstraction.prototype.polylineCenterAndZoom = function(radius)
|
||||
return;
|
||||
}
|
||||
|
||||
radius = (radius == null) ? 0 : radius;
|
||||
|
||||
var lat_max = -90;
|
||||
var lat_min = 90;
|
||||
var lon_max = -180;
|
||||
@ -4546,6 +4551,48 @@ Marker.prototype.openBubble = function() {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* closeBubble closes the infoBubble
|
||||
*/
|
||||
Marker.prototype.closeBubble = function() {
|
||||
if(this.mapstraction.loaded[this.api] === false) {
|
||||
var my_marker = this;
|
||||
this.mapstraction.onload[this.api].push( function() {
|
||||
my_marker.closeBubble();
|
||||
} );
|
||||
return;
|
||||
}
|
||||
|
||||
if( this.api) {
|
||||
switch (this.api) {
|
||||
case 'yahoo':
|
||||
var ypin = this.proprietary_marker;
|
||||
ypin.closeSmartWindow();
|
||||
break;
|
||||
case 'google':
|
||||
case 'openstreetmap':
|
||||
var gpin = this.proprietary_marker;
|
||||
gpin.closeInfoWindow();
|
||||
break;
|
||||
case 'microsoft':
|
||||
// The following works with v6.2, but need to first update way Mapstraction adds MS markers
|
||||
var pin = this.proprietary_marker;
|
||||
this.map.HideInfoBox();
|
||||
break;
|
||||
case 'multimap':
|
||||
//closeInfoBox?
|
||||
break;
|
||||
case 'mapquest':
|
||||
// ???
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if(this.debug) {
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* hide the marker
|
||||
*/
|
||||
@ -4866,7 +4913,7 @@ Polyline.prototype.toMap24 = function() {
|
||||
var m24poly;
|
||||
var m24longs = "";
|
||||
var m24lats = "";
|
||||
for (var i=0; i<this.points.length; i++) {
|
||||
for (var i=0, length = this.points.length; i<length; i++) {
|
||||
if(i) {
|
||||
m24longs += "|";
|
||||
m24lats += "|";
|
||||
@ -4874,7 +4921,7 @@ Polyline.prototype.toMap24 = function() {
|
||||
m24longs += (this.points[i].lon*60);
|
||||
m24lats += (this.points[i].lat*60);
|
||||
}
|
||||
if (this.closed || this.gpoints[0].equals(this.gpoints[length-1])) {
|
||||
if (this.closed || this.points[0].equals(this.points[length-1])) {
|
||||
m24poly = new Map24.Polygon({
|
||||
Longitudes: m24longs,
|
||||
Latitudes: m24lats,
|
||||
@ -4934,7 +4981,7 @@ Polyline.prototype.toMultiMap = function() {
|
||||
* @returns a LineOverlay/PolygonOverlay
|
||||
*/
|
||||
Polyline.prototype.toMapQuest = function() {
|
||||
if (this.closed || this.points[0].equals(this.points[length-1])) {
|
||||
if (this.closed || this.points[0].equals(this.points[this.points.length-1])) {
|
||||
var mqpoly = new MQA.PolygonOverlay();
|
||||
mqpoly.setFillColor(this.color || "#E90000");
|
||||
mqpoly.setFillColorAlpha(this.opacity || 0.3);
|
||||
@ -5091,8 +5138,8 @@ Polyline.prototype.simplify = function(tolerance) {
|
||||
reduced[0] = this.points[0];
|
||||
|
||||
var markerPoint = 0;
|
||||
|
||||
for (var i = 1; i < this.points.length-1; i++)
|
||||
var length = this.points.length;
|
||||
for (var i = 1; i < length-1; i++)
|
||||
if (this.points[i].distance(this.points[markerPoint]) >= tolerance)
|
||||
{
|
||||
reduced[reduced.length] = this.points[i];
|
||||
@ -5211,40 +5258,40 @@ Mapstraction.prototype.enableScrollWheelZoom = function() {
|
||||
* Currently only implemented in Google
|
||||
* @param {object} polygon
|
||||
*/
|
||||
Mapstraction.prototype.addPolygon = function(polygon) {
|
||||
if(this.loaded[this.api] == false)
|
||||
{
|
||||
myself = this;
|
||||
this.onload[this.api].push(function()
|
||||
{
|
||||
myself.addPolygon(polygon);
|
||||
});
|
||||
return;
|
||||
}
|
||||
Mapstraction.prototype.addPolygon = function(polygon) {
|
||||
if(this.loaded[this.api] == false)
|
||||
{
|
||||
myself = this;
|
||||
this.onload[this.api].push(function()
|
||||
{
|
||||
myself.addPolygon(polygon);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
var map = this.maps[this.api];
|
||||
var map = this.maps[this.api];
|
||||
|
||||
switch (this.api)
|
||||
{
|
||||
case 'google':
|
||||
case 'openstreetmap':
|
||||
var gpoints = [];
|
||||
switch (this.api)
|
||||
{
|
||||
case 'google':
|
||||
case 'openstreetmap':
|
||||
var gpoints = [];
|
||||
|
||||
for (var i = 0; i < polygon.points.length; i++)
|
||||
gpoints.push(polygon.points[i].toGoogle());
|
||||
for (var i = 0; i < polygon.points.length; i++)
|
||||
gpoints.push(polygon.points[i].toGoogle());
|
||||
|
||||
gpolygon = new GPolygon(gpoints, polygon.color, 0, polygon.opacity, polygon.color, polygon.opacity);
|
||||
polygon.setChild(gpolygon);
|
||||
map.addOverlay(gpolygon);
|
||||
this.polylines.push(polygon);
|
||||
break;
|
||||
default:
|
||||
if(this.debug) {
|
||||
alert(api + ' not supported by Mapstration.addPolygon');
|
||||
}
|
||||
break;
|
||||
}
|
||||
};
|
||||
gpolygon = new GPolygon(gpoints, polygon.color, 0, polygon.opacity, polygon.color, polygon.opacity);
|
||||
polygon.setChild(gpolygon);
|
||||
map.addOverlay(gpolygon);
|
||||
this.polylines.push(polygon);
|
||||
break;
|
||||
default:
|
||||
if(this.debug) {
|
||||
alert(api + ' not supported by Mapstration.addPolygon');
|
||||
}
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
///////////////
|
||||
// Radius //
|
||||
|
Loading…
x
Reference in New Issue
Block a user