[OpenLayers-Users] OpenLayers.Projection(OpenLayers.Util.getElement(......).value) - jQuery problem

Noli Sicad nsicad at gmail.com
Fri Jun 24 20:23:06 EDT 2011


Hi,

I am having problem executing this updateFormats function (below)
which contains (OpenLayers.Util.getElement(......).value) in my jQuery
mobile OL. The updateFormats is demonstrated in vector formats, in
projection and out projection. My select controls are getting back
when I clicked it.

http://openlayers.org/dev/examples/vector-formats.html

It seems that the problem is probably in the
OpenLayers.Util.getElement(......) which a $.

In Util.js,

~~~~~~~~
OpenLayers.Util.isElement = function(o) {
    return !!(o && o.nodeType === 1);
};

/**
 * Maintain existing definition of $.
 */
if(typeof window.$  === "undefined") {
    window.$ = OpenLayers.Util.getElement;
}
~~~~~~~~

Is this intervening in jQuery? Could I delete this? What would be the
solution inorder that updateFormats will be executed properly?

Thanks in advance.

Regards, Noli

~~~~~~~~~~~~~~~~~~~~~~~

This updateFormats in jQuery.


#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$(function() {

  function updateFormats() {

              alert("updated!");

			var in_options = {
                'internalProjection': map.baseLayer.projection,
                'externalProjection': new
OpenLayers.Projection(OpenLayers.Util.getElement("inproj").value)


            };
            alert(in_options);
            var out_options = {
                'internalProjection': map.baseLayer.projection,
                'externalProjection': new
OpenLayers.Projection(OpenLayers.Util.getElement("outproj").value)
            };
            var gmlOptions = {
                featureType: "feature",
                featureNS: "http://example.com/feature"
            };
            var gmlOptionsIn = OpenLayers.Util.extend(
                OpenLayers.Util.extend({}, gmlOptions),
                in_options
            );
            var gmlOptionsOut = OpenLayers.Util.extend(
                OpenLayers.Util.extend({}, gmlOptions),
                out_options
            );

            var kmlOptionsIn = OpenLayers.Util.extend(
                {extractStyles: true}, in_options);
            formats = {
              'in': {
                wkt: new OpenLayers.Format.WKT(in_options),
                geojson: new OpenLayers.Format.GeoJSON(in_options),
                gml2: new OpenLayers.Format.GML.v2(gmlOptionsIn),
                gml3: new OpenLayers.Format.GML.v3(gmlOptionsIn),
                kml: new OpenLayers.Format.KML(kmlOptionsIn)
              },
              'out': {
                wkt: new OpenLayers.Format.WKT(out_options),
                geojson: new OpenLayers.Format.GeoJSON(out_options),
                gml2: new OpenLayers.Format.GML.v2(gmlOptionsOut),
                gml3: new OpenLayers.Format.GML.v3(gmlOptionsOut),
                kml: new OpenLayers.Format.KML(out_options)
              }
            };
          }
		
         $('#inproj, #outproj').change(updateFormats);
      }); // for the function


More information about the Users mailing list