Author: bibryam
Date: Mon Mar 29 15:16:55 2010
New Revision: 928804
URL:
http://svn.apache.org/viewvc?rev=928804&view=revLog:
If there is no map center and zoom level provided for google map, get these values from all the markers on the map. If there are no markers, use 0 for latitude and longitude.
Modified:
ofbiz/trunk/framework/common/webcommon/includes/geolocation.ftl
Modified: ofbiz/trunk/framework/common/webcommon/includes/geolocation.ftl
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/webcommon/includes/geolocation.ftl?rev=928804&r1=928803&r2=928804&view=diff==============================================================================
--- ofbiz/trunk/framework/common/webcommon/includes/geolocation.ftl (original)
+++ ofbiz/trunk/framework/common/webcommon/includes/geolocation.ftl Mon Mar 29 15:16:55 2010
@@ -31,7 +31,21 @@ under the License.
<#if geoChart.center?has_content>
map.setCenter(new GLatLng(${geoChart.center.lat?c}, ${geoChart.center.lon?c}), ${geoChart.center.zoom});
<#else>
- map.setCenter(new GLatLng(37.4419, -122.1419), 12);
+ <#if geoChart.points?has_content>
+ var latlng = [
+ <#list geoChart.points as point>
+ new GLatLng(${point.lat?c}, ${point.lon?c})<#if point_has_next>,</#if>
+ </#list>
+ ];
+ var latlngbounds = new GLatLngBounds();
+ for (var i = 0; i < latlng.length; i++) {
+ latlngbounds.extend(latlng[i]);
+ }
+ map.setCenter(latlngbounds.getCenter(), map.getBoundsZoomLevel(latlngbounds) - 1);//reduce bounds zoom level to see all markers
+ <#else>
+ //map.setCenter(new GLatLng(37.4419, -122.1419), 12);
+ map.setCenter(new GLatLng(0, 0), 1);
+ </#if>
</#if>
<#if geoChart.controlUI?has_content && geoChart.controlUI == "small">
map.addControl(new GSmallMapControl());