[OpenLayers-Users] Proxyhost-access control-allow-origin

Nicholas Efremov-Kendall n.e.kendall at gmail.com
Thu Apr 14 15:57:07 EDT 2011


Hi All,

I'm trying to do a flickr mashup following the examples in the OpenLayers
book ch11. I'm getting an access-control-allow-origin error when using the
ProxyHost example script provided on the OpenLayers site. I've double
checked and I'm pretty sure my url's are properly spelled. Any suggestions?

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'
});
 var google_map = new OpenLayers.Layer.Google(
'Google Layer',
{}
);
map.addLayer(google_map);
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);
OpenLayers.ProxyHost = '/cgi-bin/proxy.cgi?url=';
var vector_style = new OpenLayers.Style({
'fillColor': '#669933',
'fillOpacity': .8,
'fontColor': '#f0f0f0',
'fontFamily': 'arial, sans-serif',
'fontSize': '.9em',
'fontWeight': 'bold',
'label': '${num_points}',
'pointRadius': '${point_radius}',
'strokeColor': '#aaee77',
'strokeWidth': 3
},
{
context: {
num_points: function(feature){ return feature.
attributes.count; },
point_radius: function(feature){
return 9 + (feature.attributes.count)
}
}
});
var vector_style_map = new OpenLayers.StyleMap({
'default': vector_style
});
var select_feature_control = new OpenLayers.Control.SelectFeature(
vector_layer,
{}
)
map.addControl(select_feature_control);
select_feature_control.activate();
vector_layer.styleMap = vector_style_map;
var vector_style_select = new OpenLayers.Style({
'fillColor': '#cdcdcd',
'fillOpacity': .9,
'fontColor': '#232323',
'strokeColor': '#ffffff'
})
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);
  if( ! map.getCenter() ){
  if(vector_layer){
  vector_layer.events.register('loadend', vector_layer,
function(){map.zoomToExtent(vector_layer.getDataExtent())});
 }
map.setCenter(null, null);};}

function on_select_feature(event){
var info_div = document.getElementById('photo_info_wrapper');
info_div.innerHTML = '';
var cluster = event.feature.cluster;
for(var i=0; i<cluster.length; i++){
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){
var info_div = document.getElementById('photo_info_wrapper');
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/20110414/0c24521e/attachment.html


More information about the Users mailing list