A basic Script protocol for vector layers. Create a new instance with the OpenLayers.Protocol.Script constructor. A script protocol is used to get around the same origin policy. It works with services that return JSONP - that is, JSON wrapped in a client-specified callback. The protocol handles fetching and parsing of feature data and sends parsed features to the callback configured with the protocol. The protocol expects features serialized as GeoJSON by default, but can be configured to work with other formats by setting the format property.
OpenLayers.
|
A basic Script protocol for vector layers. |
Properties | |
url | {String} Service URL. |
params | {Object} Query string parameters to be appended to the URL. |
callback | {Object} Function to be called when the read operation completes. |
callbackTemplate | {String} Template for creating a unique callback function name for the registry. |
callbackKey | {String} The name of the query string parameter that the service recognizes as the callback identifier. |
callbackPrefix | {String} Where a service requires that the callback query string parameter value is prefixed by some string, this value may be set. |
scope | {Object} Optional ``this`` object for the callback. |
format | {OpenLayers.Format} Format for parsing features. |
srsInBBOX | {Boolean} Include the SRS identifier in BBOX query string parameter. |
Constructor | |
OpenLayers.
|
A class for giving layers generic Script protocol. |
Functions | |
read | Construct a request for reading new features. |
filterToParams | Optional method to translate an OpenLayers.Filter object into an object that can be serialized as request query string provided. |
abort | Abort an ongoing request. |
destroy | Clean up the protocol. |
{Object} Function to be called when the read operation completes.
{String} The name of the query string parameter that the service recognizes as the callback identifier. Default is “callback”. This key is used to generate the URL for the script. For example setting callbackKey to “myCallback” would result in a URL like http://example.com/?myCallback=...
{String} Where a service requires that the callback query string parameter value is prefixed by some string, this value may be set. For example, setting callbackPrefix to “foo:” would result in a URL like http://example.com/?callback=foo:... Default is “”.
{OpenLayers.Format} Format for parsing features. Default is an OpenLayers.Format.GeoJSON format. If an alternative is provided, the format’s read method must take an object and return an array of features.
{Boolean} Include the SRS identifier in BBOX query string parameter. Setting this property has no effect if a custom filterToParams method is provided. Default is false. If true and the layer has a projection object set, any BBOX filter will be serialized with a fifth item identifying the projection. E.g. bbox=-1000,-1000,1000,1000,EPSG:900913
read: function( options )
Construct a request for reading new features.
options | {Object} Optional object for configuring the request. This object is modified and should not be reused. |
url | {String} Url for the request. |
params | {Object} Parameters to get serialized as a query string. |
filter | {OpenLayers.Filter} Filter to get serialized as a query string. |
{OpenLayers.Protocol.Response} A response object, whose “priv” property references the injected script. This object is also passed to the callback function when the request completes, its “features” property is then populated with the features received from the server.
Optional method to translate an OpenLayers.Filter object into an object that can be serialized as request query string provided. If a custom method is not provided, any filter will not be serialized.
filter | {OpenLayers.Filter} filter to convert. |
params | {Object} The parameters object. |
{Object} The resulting parameters object.
abort: function( response )
Abort an ongoing request. If no response is provided, all pending requests will be aborted.
response | {OpenLayers.Protocol.Response} The response object returned from a read request. |
Construct a request for reading new features.
read: function( options )
Abort an ongoing request.
abort: function( response )
Clean up the protocol.
destroy: function()