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

Untitled

By: a guest on Jun 16th, 2012  |  syntax: JavaScript  |  size: 1.68 KB  |  hits: 23  |  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. /**
  3.  * OpenLayers Views Vector Layer Handler
  4.  */
  5. (function($) {
  6.  
  7.     Drupal.openlayers.layer.geofile_hybrid = function(title, map, options) {
  8.  
  9.     options.projection = 'EPSG:' + options.projection;
  10.     options.styleMap = Drupal.openlayers.getStyleMap(map, options.drupalID);
  11.  
  12.     var layer = new OpenLayers.Layer.Vector(title, options);
  13.  
  14.     for (var i=0; i<options.layers.length; i++) {
  15.       var layer_embbed = options.layers[i];
  16.       var url = layer_embbed['url'];
  17.       var formatOptions = layer_embbed['formatOptions'];
  18.       var handler = layer_embbed['layer_handler'];
  19.  
  20.       formatOptions.internalProjection = new OpenLayers.Projection('EPSG:' + map.projection);
  21.       formatOptions.externalProjection = new OpenLayers.Projection(options.projection);
  22.  
  23.         (OpenLayers.Request.GET({
  24.             url: url,
  25.             callback: function(response) {
  26.                 if (handler == 'kml') {
  27.                     //console.log("Reading KML...");
  28.                     var format = new OpenLayers.Format.KML(formatOptions);
  29.                 }
  30.                 if (handler == 'gml') {
  31.                     //console.log("Reading GPX...");
  32.                     var format = new OpenLayers.Format.GPX(formatOptions);
  33.                 }
  34.                 if (handler == 'pointtrack') {
  35.                     var format = new OpenLayers.Format.PointTrack(formatOptions);
  36.                 }
  37.  
  38.                 var features = format.read(response.responseText);
  39.  
  40.                 if (features) {
  41.                     layer.addFeatures(features);
  42.                 }
  43.  
  44.             }
  45.         }))(handler);
  46.  
  47.  
  48.     }
  49.  
  50.     return layer;
  51.  
  52. };
  53.  
  54.     function MyFeatures() {
  55.  
  56.  
  57.     }
  58.  
  59. })(jQuery);