Skip to content
Snippets Groups Projects
Commit 96a2af04 authored by webgeer's avatar webgeer
Browse files

This includes wms features which should be considered beta at this point. See...

This includes wms features which should be considered beta at this point.  See http://drupal.org/node/67291 for more information.
parent aa33f3ed
No related branches found
No related tags found
No related merge requests found
......@@ -70,6 +70,7 @@ function gmap_perm() {
* track - a file containing a series of points in .plt format to be
* inserted into the node.
* feeds - an associative array of rss feeds
* wmss - an associative array of WMS services
*
* Xmaps must be enabled for circle and polygon to work.
*
......@@ -142,8 +143,81 @@ function gmap_draw_map($gmap, $javascript='') {
function gmap_load_'.$gmap['id'].'() {
'.$gmap['id'].' = new GMap2($("'.$gmap['id'].'"));
'.$gmap['id'].'.setCenter(new GLatLng('.$gmap['center'].'), '.$gmap['zoom'].');
';
if (isset($gmap['wmss'])) {
$outtext.= '
// WMS layers ';
$outtext.= '
'.$gmap['id'].'.getMapTypes().length = 0;';
$ic=0;
foreach ($gmap['wmss'] as $item) {
$map_name = eregi_replace("[^a-z0-9_-]", "_", $item['name']);
(!isset($item['minresolution'])) ? $item['minresolution']='1': NULL;
(!isset($item['maxresolution'])) ? $item['maxresolution']='17': NULL;
(!isset($item['format'])) ? $item['format']='image/gif': NULL;
(!isset($item['merczoomlevel'])) ? $item['merczoomlevel']='5': NULL;
$outtext.= '
var ccol_'.$map_name.' = new GCopyrightCollection("'.$item['name'].'");
';
if(isset($item['copyrights'])){
foreach ($item['copyrights'] as $copyright) {
(!isset($copyright['bounds'])) ? $copyright['bounds']='-190,-90,180,90': NULL;
(!isset($copyright['minzoom'])) ? $copyright['minzoom']='1': NULL;
(!isset($copyright['text'])) ? $copyright['text']='': NULL;
$coords = explode(",", $copyright['bounds']);
$outtext.= '
var sw_'.$ic.' = new GLatLng('.$coords[0].','.$coords[1].',false);
var ne_'.$ic.' = new GLatLng('.$coords[2].','.$coords[3].',false);
var llb_'.$ic.' = new GLatLngBounds(sw_'.$ic.',ne_'.$ic.');
var cr_'.$ic.' = new GCopyright(1,llb_'.$ic.','.$copyright['minzoom'].',"'.$copyright['text'].'");
ccol_'.$map_name.'.addCopyright(cr_'.$ic.');
';
$ic++;
}
}
$outtext.= '
var t_'.$map_name.'= new GTileLayer(ccol_'.$map_name.','.$item['minresolution'].','.$item['maxresolution'].');
t_'.$map_name.'.myMercZoomLevel='.$item['merczoomlevel'].';
t_'.$map_name.'.myBaseURL=\''.$item['url'].'\';
t_'.$map_name.'.myLayers=\''.$item['layers'].'\';
t_'.$map_name.'.myFormat=\''.$item['format'].'\';
t_'.$map_name.'.getTileUrl=CustomGetTileUrl;
';
if(isset($item['overlaywith'])){
switch (strtolower($item['overlaywith'])) {
case 'map':
$outtext.= "var l_".$map_name."1=[G_NORMAL_MAP.getTileLayers()[0]]; \n ";
break;
case 'hybrid':
//We overlay with roads only, not with the satellite imagery
$outtext.= "var l_".$map_name."1=[G_HYBRID_MAP.getTileLayers()[1]]; \n ";
break;
case 'satellite':
$outtext.= "var l_".$map_name."1=[G_SATELLITE_MAP.getTileLayers()[0]]; \n ";
break;
default:
$outtext.= "var l_".$map_name."1=[]; \n ";
}
}
$outtext.= 'var l_'.$map_name.'2=[t_'.$map_name.'];
var l_'.$map_name.'=l_'.$map_name.'2.concat(l_'.$map_name.'1);
var m_'.$map_name.' = new GMapType(l_'.$map_name.', G_SATELLITE_MAP.getProjection(), "'.$item['name'].'", G_SATELLITE_MAP);
'.$gmap['id'].'.addMapType(m_'.$map_name.');
';
}
$outtext.= '
'.$gmap['id'].'.addMapType(G_NORMAL_MAP);
'.$gmap['id'].'.addMapType(G_SATELLITE_MAP);
'.$gmap['id'].'.addMapType(G_HYBRID_MAP);
';
}
$outtext.= $gmap['id'].'.setCenter(new GLatLng('.$gmap['center'].'), '.$gmap['zoom'].');
';
switch (strtolower($gmap['control'])) {
case 'small':
$outtext .='mycontrol=new GSmallMapControl();
......@@ -368,6 +442,7 @@ function gmap_draw_map($gmap, $javascript='') {
}
}
}
if (strlen($javascript)>0) {
$javascript=str_replace('{id}',$gmap['id'],$javascript);
$outtext .=$javascript;
......@@ -516,6 +591,23 @@ function gmap_parse_macro($instring,$ver=2) {
$gmap['feeds'][] = $tt;
break;
case 'wmss':
unset($ttt);
$ttt = explode('+',$t[1]);
for ($i =0; $i<count($ttt); $i++) {
unset($tt);
list($tt['name'],$tt['url'],$tt['format'],$tt['layers'],$tt['minresolution'],$tt['maxresolution'],$tt['copyrights'],$tt['overlaywith'],$tt['merczoomlevel'])=explode('::',$ttt[$i]);
$crr = explode('/',$tt['copyrights']);
unset($tt['copyrights']);
for ($k =0; $k<count($crr); $k++) {
unset($cr);
list($cr['minzoom'],$cr['bounds'],$cr['text'])=explode(':',$crr[$k]);
$tt['copyrights'][]=$cr;
}
$gmap['wmss'][]=$tt;
}
break;
case 'line1':
$tt['color']=GMAP_LINECOLOR1;
case 'line2':
......@@ -667,9 +759,18 @@ function _gmap_doheader(){
drupal_add_js('http://www.acme.com/javascript/Clusterer2.js');
}
}
if (file_exists('misc/gxmarker.2.js')){
drupal_add_js('misc/gxmarker.2.js');
if (GMAP_WMS){
if (file_exists('misc/wms-gs.js')) {
drupal_add_js('misc/wms-gs.js');
} elseif (file_exists('misc/wms236.js')) {
drupal_add_js('misc/wms236.js');
} elseif (file_exists('misc/wms-gs-1_0_0.js')) {
drupal_add_js('misc/wms-gs-1_0_0.js');
} else {
drupal_add_js('http://dist.codehaus.org/geoserver/gmaps-geoserver_scripts/wms-gs-1_0_0.js');
}
}
$gmap_initialized = TRUE;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment