[OpenLayers-Users] ProxyHost Issues: xampp, py 2.7, cross domain requests

Nicholas Efremov-Kendall n.e.kendall at gmail.com
Tue Apr 19 11:35:39 EDT 2011


Hi everyone,

I realize this is more of a server-side/noob question, but it directly
relates to OL functionality so I thought it would be good to ask here. I'm
trying to dynamically grab flickr feeds and dump them into a map following
the example in the OL book. I'm stumped as to how to tailor the OL proxy.cgi
script on my local xampp installation. I have python2.7 installed, so I've
changed the first line of the proxy.cgi to "#! C:/Python27/python.exe -u"
following the example of someone on one of the Mapserver lists. This at
least let's me redirect to the OL home page following the examples in the
FAQ section (localhost/cgi-bin/proxy.cgi), meaning the script is in the
right place and works. However, I'm still getting denied on the cross-domain
request so, it has to be an error in my code, my guess would be that it's
the URL that I'm providing to the javascript in the proxy host declaration.
Any help would be greatly appreciated

var map, layer;
function init_geoflik(){
map = new OpenLayers.Map ("map",
{controls:[
    new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.LayerSwitcher(),
new OpenLayers.Control.Attribution(),
new OpenLayers.Control.ScaleLine()],
   sphericalMercator: true,
   maxExtent: new
OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
   maxResolution: 156543.0399,
   numZoomLevels: 19,
   units: 'm'
});
// Google Layer as Background
var google_map = new OpenLayers.Layer.Google(
'Google Layer',
{}
);
map.addLayer(google_map);
//static fliker data
var vector_layer = new OpenLayers.Layer.Vector('Flickr Data',
{
projection: new OpenLayers.Projection('EPSG:4326'),
protocol: new OpenLayers.Protocol.HTTP({
url: 'http://api.flickr.com/services/feeds/geo/', params: {'format':'kml',
'tags':'graphitti'}, format: new OpenLayers.Format.KML({extractAttributes:
true, extractStyles: true})}), strategies: [new OpenLayers.Strategy.Fixed(),
new OpenLayers.Strategy.Cluster]});
map.addLayer(vector_layer);
//Specify modified proxyhost from OpenLayers
OpenLayers.ProxyHost = '/cgi-bin/proxy.cgi?url=';

// interaction controls
//Add a select feature control
var select_feature_control = new OpenLayers.Control.SelectFeature(
vector_layer,
{}
)
map.addControl(select_feature_control);
select_feature_control.activate();
//Add the style map to the vector layer
vector_layer.styleMap = vector_style_map;
var vector_style_select = new OpenLayers.Style({
'fillColor': '#cdcdcd',
'fillOpacity': .9,
'fontColor': '#232323',
'strokeColor': '#ffffff'
})
//Create a style map object and set the 'default' intent to the
var vector_style_map = new OpenLayers.StyleMap({
'default': vector_style,
'select': vector_style_select
});
//
vector_layer.events.register('featureselected', this, on_select_feature);
vector_layer.events.register('featureunselected', this,
on_unselect_feature);
//center map on data loaded
  if( ! map.getCenter() ){
  if(vector_layer){
  vector_layer.events.register('loadend', vector_layer,
function(){map.zoomToExtent(vector_layer.getDataExtent())});
  }
map.setCenter(null, null);
};

//end of fn bracket
}
function on_select_feature(event){
//Store a reference to the element
var info_div = document.getElementById('photo_info_wrapper');
info_div.innerHTML = '';
//Store the clusters
var cluster = event.feature.cluster;
//Loop through the cluster features
for(var i=0; i<cluster.length; i++){
//Update the div with the info of the photos
info_div.innerHTML += "<strong>"
+ cluster[i].attributes.name
+ "</strong><br />"
+ "<img src='" + cluster[i].style.externalGraphic + "'/>"
+ cluster[i].attributes.Snippet
+ "<br /><hr />";
}
}
function on_unselect_feature(event){
//Store a reference to the element
var info_div = document.getElementById('photo_info_wrapper');
//Clear out the div
info_div.innerHTML = '';
}



-- 

Dept. of Anthropology
Washington University in St. Louis
Campus Box 1114
St. Louis, MO, 63130
(917) 370-3489
nefremov at wustl.edu <nefremov at artsci.wustl.edu>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110419/e8a4b391/attachment.html


More information about the Users mailing list