Project

General

Profile

« Previous | Next » 

Revision 5c47f51c

Added by Andreas Kohlbecker almost 7 years ago

  • ID 5c47f51c0e90cbdf0b7e4bee3a3d308cf366d824
  • Parent c6c196ff

#6609 using openlayers 2.14-dev, solving some problems

  • test and debug modificatinos are included, needs clean up

View differences:

modules/cdm_dataportal/cdm_dataportal.module
148 148

  
149 149
  function _add_js_openlayers() {
150 150

  
151
    $openlayers = '/js/map/OpenLayers-2.13.1/OpenLayers.js';
151
    // $openlayers = '/js/map/OpenLayers-2.13.1/OpenLayers.js';
152
    $openlayers = '/js/map/OpenLayers-2.14-dev/OpenLayers.js';
152 153
    $proj4js = '/js/map/proj4js-1.1.0/proj4js-compressed.js';
153 154

  
154 155
    if(variable_get('cdm_js_devel_mode', FALSE)){
modules/cdm_dataportal/includes/maps.inc
156 156
      if(str_beginsWith($name, 'g')){
157 157
        if( isset($map_settings['openlayers']['google_maps_api_key']) && strlen($map_settings['openlayers']['google_maps_api_key']) == 39) {
158 158
          // google layer detected
159
          drupal_add_js("https://maps.googleapis.com/maps/api/js?key=" . $map_settings['openlayers']['google_maps_api_key'] . "&callback=initMap",
159
          //drupal_add_js("https://maps.googleapis.com/maps/api/js?key=" . $map_settings['openlayers']['google_maps_api_key'],
160 160
          //drupal_add_js("https://maps.google.com/maps/api/js?callback=initMap&key=" . $map_settings['openlayers']['google_maps_api_key'],
161
          drupal_add_js("http://maps.google.com/maps/api/js?v=3&key=" . $map_settings['openlayers']['google_maps_api_key'],
161 162
          array(
162 163
            'type' => 'external',
163 164
            'defer' => true
164 165
            ));
165 166

  
166 167
          //drupal_add_js("http://maps.google.com/maps/api/js?callback=initMap&key=" . $map_settings['openlayers']['google_maps_api_key'], 'external');
167
          //drupal_add_js("http://maps.google.com/maps/api/js?v=3&sensor=false", 'external');
168 168
        } else {
169 169
          drupal_set_message('A Google Maps layer is configured but the API key is either missing or invalid. 
170 170
          Please set your Google Maps API key in the '  . l('Geo & Map Settings', 'admin/config/cdm_dataportal/settings/geo') .'.', 'warning');
modules/cdm_dataportal/js/map/OpenLayers-2.14-dev/examples/google.html
1
<!DOCTYPE html>
2
<html>
3
    <head>
4
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
6
    <meta name="apple-mobile-web-app-capable" content="yes">
7
        <title>OpenLayers 2 Google (v3) Layer Example</title>
8
        <link rel="stylesheet" href="../../OpenLayers-2.13.1/theme/default/style.css" type="text/css">
9
        <link rel="stylesheet" href="style.css" type="text/css">
10
        <script src="http://maps.google.com/maps/api/js?v=3&amp;sensor=false"></script>
11
        <script src="../OpenLayers.js"></script>
12
        <script src="google.js"></script>
13
    </head>
14
    <body onload="init()">
15
        <h1 id="title">Google (v3) Layer Example</h1>
16
        <div id="tags">
17
            Google, api key, apikey, light
18
        </div>
19
        <p id="shortdesc">
20
            Demonstrate use the Google Maps v3 API.
21
        </p>
22
        <div id="map" class="smallmap"></div>
23
        <div id="docs">
24
            <p><input id="animate" type="checkbox" checked="checked">Animated
25
                zoom (if supported by GMaps on your device)</input></p>
26
            <p>
27
                Google is encouraging the use of keys for Google Maps APIs as
28
                described here: <a href="https://developers.google.com/maps/documentation/javascript/get-api-key">https://developers.google.com/maps/documentation/javascript/get-api-key</a>.
29
                Once you have included the Google Maps script in your html,
30
                refer to the
31
                <a href="google.js" target="_blank">google.js source</a>
32
                to see how to use Google Maps as layer in OpenLayers.
33
            </p>
34
        </div>
35
    </body>
36
</html>
modules/cdm_dataportal/js/map/OpenLayers-2.14-dev/examples/google.js
1
var map;
2

  
3
function init() {
4
    map = new OpenLayers.Map('map', {
5
        projection: 'EPSG:900913',
6
        layers: [
7
            new OpenLayers.Layer.Google(
8
                "Google Physical",
9
                {type: google.maps.MapTypeId.TERRAIN,
10
                    projection: 'EPSG:900913'
11
                }
12
            ),
13
            new OpenLayers.Layer.Google(
14
                "Google Streets", // the default
15
                {numZoomLevels: 20}
16
            ),
17
            new OpenLayers.Layer.Google(
18
                "Google Hybrid",
19
                {type: google.maps.MapTypeId.HYBRID, numZoomLevels: 20}
20
            ),
21
            new OpenLayers.Layer.Google(
22
                "Google Satellite",
23
                {type: google.maps.MapTypeId.SATELLITE, numZoomLevels: 22}
24
            )
25
        ],
26
        center: new OpenLayers.LonLat(10.2, 48.9)
27
            // Google.v3 uses web mercator as projection, so we have to
28
            // transform our coordinates
29
            .transform('EPSG:4326', 'EPSG:900913'),
30
        zoom: 5
31
    });
32
    map.addControl(new OpenLayers.Control.LayerSwitcher());
33
    
34
    // add behavior to html
35
    var animate = document.getElementById("animate");
36
    animate.onclick = function() {
37
        for (var i=map.layers.length-1; i>=0; --i) {
38
            // map.layers[i].animationEnabled = this.checked;
39
        }
40
    };
41
}
modules/cdm_dataportal/js/map/OpenLayers-2.14-dev/examples/style.css
1
/**
2
 * CSS Reset
3
 * From Blueprint reset.css
4
 * http://blueprintcss.googlecode.com
5
 */
6
html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, code, del, dfn, em, img, q, dl, dt, dd, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {margin:0;padding:0;border:0;font-weight:inherit;font-style:inherit;font-size:100%;font-family:inherit;vertical-align:baseline;}
7
body {line-height:1.5;}
8
table {border-collapse:separate;border-spacing:0;}
9
caption, th, td {text-align:left;font-weight:normal;}
10
table, td, th {vertical-align:middle;}
11
blockquote:before, blockquote:after, q:before, q:after {content:"";}
12
blockquote, q {quotes:"" "";}
13
a img {border:none;}
14

  
15
/**
16
 * Basic Typography
17
 */
18
body {
19
    font-family: "Lucida Grande", Verdana, Geneva, Lucida, Arial, Helvetica, sans-serif;
20
    font-size: 80%;
21
    color: #222;
22
    background: #fff;
23
    margin: 1em 1.5em;
24
}
25
pre, code {
26
    margin: 1.5em 0;
27
    white-space: pre;
28
}
29
pre, code {
30
    font: 1em 'andale mono', 'lucida console', monospace;
31
    line-height:1.5;
32
}
33
a[href] {
34
    color: #436976;
35
    background-color: transparent;
36
}
37
h1, h2, h3, h4, h5, h6 {
38
    color: #003a6b;
39
    background-color: transparent;
40
    font: 100% 'Lucida Grande', Verdana, Geneva, Lucida, Arial, Helvetica, sans-serif;
41
    margin: 0;
42
    padding-top: 0.5em;
43
}
44
h1 {
45
    font-size: 130%;
46
    margin-bottom: 0.5em;
47
    border-bottom: 1px solid #fcb100;
48
}
49
h2 {
50
    font-size: 120%;
51
    margin-bottom: 0.5em;
52
    border-bottom: 1px solid #aaa;
53
}
54
h3 {
55
    font-size: 110%;
56
    margin-bottom: 0.5em;
57
    text-decoration: underline;
58
}
59
h4 {
60
    font-size: 100%;
61
    font-weight: bold;
62
}
63
h5 {
64
    font-size: 100%;
65
    font-weight: bold;
66
}
67
h6 {
68
    font-size: 80%;
69
    font-weight: bold;
70
}
71

  
72
.olControlAttribution {
73
    bottom: 5px;
74
}
75

  
76
/**
77
 * Map Examples Specific
78
 */
79
.smallmap {
80
    width: 512px;
81
    height: 256px;
82
    border: 1px solid #ccc;
83
}
84
#tags {
85
    display: none;
86
}
87

  
88
#docs p {
89
    margin-bottom: 0.5em;
90
}
91
/* mobile specific */
92
@media only screen and (max-width: 600px) {
93
    body {
94
        height           : 100%;
95
        margin           : 0;
96
        padding          : 0;
97
        width            : 100%;
98
    }
99
    #map {
100
        background : #7391ad;
101
        width      : 100%;
102
    }
103
    #map {
104
        border : 0;
105
        height : 250px;
106
    }
107
    #title {
108
        font-size   : 1.3em;
109
        line-height : 2em;
110
        text-indent : 1em;
111
        margin      : 0;
112
        padding     : 0;
113
    }
114
    #docs {
115
        bottom     : 0;
116
        padding    : 1em;
117
    }
118
    #shortdesc {
119
        color      : #aaa;
120
        font-size  : 0.8em;
121
        padding    : 1em;
122
        text-align : right;
123
    }
124
    #tags {
125
        display : none;
126
    }
127
}
128
@media only screen and (orientation: landscape) and (max-width: 600px) {
129
    #shortdesc {
130
       float: right;
131
       width: 25%;
132
    }
133
    #map {
134
        width: 70%;
135
    }
136
    #docs {
137
        font-size: 12px;
138
    }
139
}
140
body {
141
    -webkit-text-size-adjust: none;
142
}
143

  
modules/cdm_dataportal/js/map/openlayers_layers.js
155 155
            return  new OpenLayers.Layer.Google(
156 156
                      "Google Roadmap",
157 157
                      {
158
                          // rooad map is default
158
                          // road map is default
159 159
                          projection: window.CdmOpenLayers.projections.epsg_900913,
160 160
                          // Allow user to pan forever east/west
161 161
                          // Setting this to false only restricts panning if sphericalMercator is true.
......
171 171
                      "Google Satellite",
172 172
                      {
173 173
                        type: 'satellite',
174
                        //projection: window.CdmOpenLayers.projections.epsg_900913,
174
                        projection: window.CdmOpenLayers.projections.epsg_900913,
175 175
                        // Allow user to pan forever east/west
176 176
                        // Setting this to false only restricts panning if sphericalMercator is true.
177 177
                        wrapDateLine: false,
......
198 198
              "Google Terrain",
199 199
              {
200 200
                type: google.maps.MapTypeId.TERRAIN,
201
                // projection: window.CdmOpenLayers.projections.epsg_900913,
201
                //projection: window.CdmOpenLayers.projections.epsg_900913,
202 202
                // Allow user to pan forever east/west
203 203
                // Setting this to false only restricts panning if sphericalMercator is true.
204
                wrapDateLine: false,
204
                // wrapDateLine: false,
205
                //sphericalMercator: true,
205 206
                numZoomLevels: 22
206 207
              }
207 208
            );
modules/cdm_dataportal/js/map/openlayers_map.js
641 641

  
642 642
            if(layers.length > 0) {
643 643
              // calculate zoomBounds using the first layer
644
              if(mapResponseObj.bbox !== undefined){
644
              if(mapResponseObj.bbox !== undefined && mapResponseObj.bbox){
645 645
                // mapResponseObj.bbox are bounds for the projection of the specific layer
646 646
                var newBounds =  OpenLayers.Bounds.fromString( mapResponseObj.bbox );
647 647
                newBounds.transform(layers[0].projection, map.getProjectionObject());

Also available in: Unified diff