Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 16th, 2012  |  syntax: JavaScript  |  size: 1.94 KB  |  hits: 30  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /**
  2.  * OpenLayers Views Vector Layer Handler
  3.  */
  4.     (function($) {
  5.  
  6.         Drupal.openlayers.layer.geofile_hybrid = function(title, map, options) {
  7.  
  8.             options.projection = 'EPSG:' + options.projection;
  9.             options.styleMap = Drupal.openlayers.getStyleMap(map, options.drupalID);
  10.  
  11.             var layer = new OpenLayers.Layer.Vector(title, options);
  12.  
  13.             for (var i=0; i<options.layers.length; i++) {
  14.                 var layer_embbed = options.layers[i];
  15.                 var url = layer_embbed['url'];
  16.                 var formatOptions = layer_embbed['formatOptions'];
  17.                 var handler = layer_embbed['layer_handler'];
  18.  
  19.                 formatOptions.internalProjection = new OpenLayers.Projection('EPSG:' + map.projection);
  20.                 formatOptions.externalProjection = new OpenLayers.Projection(options.projection);
  21.  
  22.                 (function(handler, formatOptions) {
  23.                     OpenLayers.Request.GET({
  24.                         url: url,
  25.                         callback: function(response) {
  26.                             if (handler == 'kml') {
  27.                                 var format = new OpenLayers.Format.KML(formatOptions);
  28.                             }
  29.                             if (handler == 'gml') {
  30.                                 var format = new OpenLayers.Format.GPX(formatOptions);
  31.                             }
  32.                             if (handler == 'pointtrack') {
  33.                                 var format = new OpenLayers.Format.PointTrack(formatOptions);
  34.                             }
  35.  
  36.                             var features = format.read(response.responseText);
  37.  
  38.                             if (features) {
  39.                                 layer.addFeatures(features);
  40.                             }
  41.  
  42.                         }
  43.                     })
  44.                 })(handler)
  45.  
  46.  
  47.             }
  48.  
  49.             return layer;
  50.  
  51.         };
  52.  
  53.     })(jQuery);