]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
made it lint, passes all unit tests t529
authorChristopher De Cairos <chris.decairos@gmail.com>
Wed, 18 May 2011 16:14:45 +0000 (12:14 -0400)
committerChristopher De Cairos <chris.decairos@gmail.com>
Wed, 18 May 2011 16:14:45 +0000 (12:14 -0400)
plugins/openmap/popcorn.openmap.js

index ed3740f9491638c68ec1420b8fdf99cbdc313985..7c51277e610b657b22ddf8cf9ff14420e5a77de9 100644 (file)
@@ -93,7 +93,7 @@
         options.type = options.type || "ROADMAP";
         if( options.type == "SATELLITE" ) {
           // add NASA WorldWind / LANDSAT map
-          map = new OpenLayers.Map( { div: newdiv, "maxResolution": .28125, tileSize: new OpenLayers.Size( 512, 512 ) } );
+          map = new OpenLayers.Map( { div: newdiv, "maxResolution": 0.28125, tileSize: new OpenLayers.Size( 512, 512 ) } );
           var worldwind = new OpenLayers.Layer.WorldWind( "LANDSAT", "http://worldwind25.arc.nasa.gov/tile/tile.aspx", 2.25, 4, { T: "105" } );
           map.addLayer( worldwind );
           displayProjection = new OpenLayers.Projection( "EPSG:4326" );
             // reset the location and zoom just in case the user played with the map
             map.setCenter( centerlonlat, options.zoom );
             if( options.markers ){
-              var layerStyle = OpenLayers.Util.extend( {} , OpenLayers.Feature.Vector.style[ 'default' ] );
-              pointLayer = new OpenLayers.Layer.Vector( "Point Layer", { style: layerStyle } );
-              map.addLayer( pointLayer );
-              for( var m = 0; m < options.markers.length; m++ ) {
-                var myMarker = options.markers[ m ];
-                if( myMarker.text ){
-                  if( !selectControl ){
-                    selectControl = new OpenLayers.Control.SelectFeature( pointLayer );
-                    map.addControl( selectControl );
-                    selectControl.activate();
-                    pointLayer.events.on( {
-                      "featureselected": function( clickInfo ) {
-                        clickedFeature = clickInfo.feature;
-                        if( !clickedFeature.attributes.text ){
-                          return;
-                        }
-                        popup = new OpenLayers.Popup.FramedCloud(
-                          "featurePopup",
-                          clickedFeature.geometry.getBounds().getCenterLonLat(),
-                          new OpenLayers.Size( 120, 250 ),
-                          clickedFeature.attributes.text,
-                          null,
-                          true,
-                          function( closeInfo ) {
-                            selectControl.unselect( this.feature );
-                          }
-                        );
-                        clickedFeature.popup = popup;
-                        popup.feature = clickedFeature;
-                        map.addPopup( popup );
-                      },
-                      "featureunselected": function( clickInfo ) {
-                        feature = clickInfo.feature;
-                        if ( feature.popup ) {
-                          popup.feature = null;
-                          map.removePopup( feature.popup );
-                          feature.popup.destroy();
-                          feature.popup = null;
-                        }
+              var layerStyle = OpenLayers.Util.extend( {} , OpenLayers.Feature.Vector.style[ 'default' ] ),
+                  featureSelected = function( clickInfo ) {
+                    clickedFeature = clickInfo.feature;
+                    if( !clickedFeature.attributes.text ){
+                      return;
+                    }
+                    popup = new OpenLayers.Popup.FramedCloud(
+                      "featurePopup",
+                      clickedFeature.geometry.getBounds().getCenterLonLat(),
+                      new OpenLayers.Size( 120, 250 ),
+                      clickedFeature.attributes.text,
+                      null,
+                      true,
+                      function( closeInfo ) {
+                        selectControl.unselect( this.feature );
                       }
-                    } );
-                  }
-                }
-                if( myMarker.location ){
-                  var geocodeThenPlotMarker = function( myMarker ){
+                    );
+                    clickedFeature.popup = popup;
+                    popup.feature = clickedFeature;
+                    map.addPopup( popup );
+                  }, 
+                  featureUnSelected = function( clickInfo ) {
+                    feature = clickInfo.feature;
+                    if ( feature.popup ) {
+                      popup.feature = null;
+                      map.removePopup( feature.popup );
+                      feature.popup.destroy();
+                      feature.popup = null;
+                    }
+                  },
+                  gcThenPlotMarker = function( myMarker ){
                     Popcorn.getJSONP(
                       "http://tinygeocoder.com/create-api.php?q=" + myMarker.location + "&callback=jsonp",
                       function( latlng ){
                       }
                     );
                   };
+              pointLayer = new OpenLayers.Layer.Vector( "Point Layer", { style: layerStyle } );
+              map.addLayer( pointLayer ); 
+              for( var m = 0; m < options.markers.length; m++ ) {
+                var myMarker = options.markers[ m ];
+                if( myMarker.text ){
+                  if( !selectControl ){
+                    selectControl = new OpenLayers.Control.SelectFeature( pointLayer );
+                    map.addControl( selectControl );
+                    selectControl.activate();
+                    pointLayer.events.on( {
+                      "featureselected": featureSelected,
+                      "featureunselected": featureUnSelected
+                    } );
+                  }
+                }
+                if( myMarker.location ){
+                  var geocodeThenPlotMarker = gcThenPlotMarker;
                   geocodeThenPlotMarker(myMarker);
                 } else {
                   var myPoint = new OpenLayers.Geometry.Point( myMarker.lng, myMarker.lat ).transform( displayProjection, projection ),