[OpenLayers-Users] Problems embedding OpenLayers in a Blog

jamesmikedupont at googlemail.com jamesmikedupont at googlemail.com
Wed Dec 23 14:37:53 EST 2009


It would be possible to produce json files in the archive, read to load.

That would not be a big security risk, they are parsed and the data is public.

So, yes basically it would be like data tiles being selected and
loaded instead on png tiles.
That would be optimal, because we could do things :

1. we could check some version control system if there is any newer
version of the file checked in so that we could get updates.
2. we could load the files on demand.

It seems that this is a good way to go for now, I will read up more into it.

The other problem with using archive.org, is that even if I host my
html page there, it will get split out to one of the many http servers
and I get an absolute address.

That means that between those servers, it is a different domain, or
maybe i understood this wrong.

I will look into this after I finish some other work, thank you very
much for your advice. It is a new subject for me, and I hope that my
N00bness is not too annoying.

mike


On Wed, Dec 23, 2009 at 7:52 PM, Adam Ratcliffe <adam at prema.co.nz> wrote:
> Images are not subject to the same-origin policy that applies to data loaded
> via XHR which is why the map tiles load fine.
>
> One way to circumvent the browser's same-origin policy when loading data
> from another domain is by dynamically inserting a script tag in the DOM and
> using it to load the data as JSON, this technique is described in more
> detail here: http://ajaxpatterns.org/On-Demand_Javascript
>
> I haven't used this technique with OpenLayers, presumably you would need to
> implement a custom protocol to integrate with the Vector layer.
>
> Cheers
> Adam
>
> On 24/12/2009, at 6:17 AM, jamesmikedupont at googlemail.com wrote:
>
>> Ahh,
>> it seems that the tiles are being loaded, but no data. That would
>> explain something.
>> Of course loading the tiles based on the current scrolling position
>> would not be a security issue.
>>
>> Ok, well I will have to spend some more time to read about this, can
>> you please explain on thing :
>>
>> what is the difference between :
>>
>>
>> new OpenLayers.Layer.GML("OSM", "file.osm", {format:
>> OpenLayers.Format.OSM});
>>
>> and what I was trying to do that did not work :
>>
>> new OpenLayers.Layer.Vector("Lines", {
>>                   strategies: [new OpenLayers.Strategy.Fixed()],
>>                    minZoomLevel: 1,
>>                    maxZoomLevel: 6 ,
>>                    numZoomLevels: 5,
>>                   protocol: new OpenLayers.Protocol.HTTP({
>>                    url: "test-embed_files/testway.xml",
>>                    format: new OpenLayers.Format.OSM(),
>>                   })
>>               });
>>
>> Thanks,
>> mike
>>
>>
>> On Wed, Dec 23, 2009 at 5:56 PM, jamesmikedupont at googlemail.com
>> <jamesmikedupont at googlemail.com> wrote:
>>>
>>> I am looking at this example,
>>>
>>> http://trac.openlayers.org/browser/trunk/openlayers/examples/osm-layer.html
>>>
>>> It is using GML instead of OSM, and it is also loading from the
>>> openstreetmap.org domain.
>>>
>>> How can this example work if you cannot load map data from another
>>> domain?
>>>
>>> mike
>>>
>>> On Wed, Dec 23, 2009 at 5:16 PM, jamesmikedupont at googlemail.com
>>> <jamesmikedupont at googlemail.com> wrote:
>>>>
>>>> Yes exactly,
>>>> but if I host the page on archive.org then I can access the data on
>>>> the same domain.
>>>> I had a misconception about this whole thing, obviously mashups are
>>>> going to create a lot more server sided traffic.
>>>> mike
>>>>
>>>> On Wed, Dec 23, 2009 at 4:29 PM, Marc Jansen <jansen at terrestris.de>
>>>> wrote:
>>>>>
>>>>> Hi Mike,
>>>>>
>>>>> as for OpenLayers, it shouldn't be a problem to get it hosted nearly
>>>>> everywhere since it is only JavaScript. Obviously you cannot use any
>>>>> datasource, though. Maybe you can set up a proxy that handles the
>>>>> requests,
>>>>> but I'd doubt that it is possible for your current
>>>>> *.blogspot.com-adress.
>>>>>
>>>>> Regards,
>>>>> Marc
>>>>>
>>>>>
>>>>>
>>>>> jamesmikedupont at googlemail.com wrote:
>>>>>>
>>>>>> Thanks for your advice. That is interesting.
>>>>>> I never did anything like this, and I feed pretty stupid right now!
>>>>>>
>>>>>> But it will be possible to host the webpages on archive.org as well
>>>>>> and work without the blog itself. It just would be nice to separate
>>>>>> the display and the data storage. That effectively reduces the usage
>>>>>> of openlayers to people who have control of domains, right? It will
>>>>>> not be possible to people to just create maps with any data they want
>>>>>> without a server to proxy the data.
>>>>>>
>>>>>> Now, this example, it displays an openstreetmap map
>>>>>> http://osmopenlayers.blogspot.com/2009/12/test-of-osm-server.html
>>>>>>
>>>>>> but the fetch to :
>>>>>> http://www.openstreetmap.org/api/0.6/way/24315294/full
>>>>>> that fails, or never returns.
>>>>>>
>>>>>> But the same one to use open layer to load the data from osm fails :
>>>>>> http://osmopenlayers.blogspot.com/2009/12/get-osm-data-directly.html
>>>>>>
>>>>>> It calles get on this url
>>>>>> http://www.openstreetmap.org/api/0.6/way/24315294
>>>>>> in the request  XMLHttpRequest.js (line 200)
>>>>>>
>>>>>> the other thing is that I dont get any error message about security
>>>>>> problems
>>>>>>
>>>>>> I found this document here:
>>>>>> http://docs.openlayers.org/library/request.html
>>>>>>
>>>>>> So, realistically it is not possible to host open layers on a blog?
>>>>>>
>>>>>>
>>>>>> mike
>>>>>>
>>>>>> On Wed, Dec 23, 2009 at 1:37 PM, Marc Jansen <jansen at terrestris.de>
>>>>>> wrote:
>>>>>>
>>>>>>>
>>>>>>> Hi Mike,
>>>>>>>
>>>>>>> I am pretty sure that you aren't allowed to acces datasources via
>>>>>>> XHR/AJAX
>>>>>>> from other servers than the one the original page is served from.
>>>>>>>
>>>>>>> see: http://en.wikipedia.org/wiki/Same_origin_policy
>>>>>>>
>>>>>>> Just a quick guess, though.
>>>>>>>
>>>>>>> regards,
>>>>>>> Marc
>>>>>>>
>>>>>>>
>>>>>>> jamesmikedupont at googlemail.com wrote:
>>>>>>>
>>>>>>>>
>>>>>>>> Hi there,
>>>>>>>> I have attempted to embed openlayers in a blog post,
>>>>>>>> and am failing! Any help would be appreciated.
>>>>>>>>
>>>>>>>> using osm data hosted OSM data on archive.org
>>>>>>>> http://osmopenlayers.blogspot.com/2009/12/test-embed.html
>>>>>>>>
>>>>>>>> here is get a octet bytestream because archive org does not say the
>>>>>>>> right filetype.
>>>>>>>>
>>>>>>>> http://ia341335.us.archive.org/2/items/ZCTA_NJ/zip_07003.poly.osm this
>>>>>>>> returns a 206 partial content and fails.
>>>>>>>>
>>>>>>>> in a pastebin file that is delivered as text:
>>>>>>>> http://osmopenlayers.blogspot.com/2009/12/hosting-on-pastebin.html
>>>>>>>> Date    Wed, 23 Dec 2009 10:15:43 GMT
>>>>>>>> Server  Apache/1.3.33 (Debian GNU/Linux) mod_python/2.7.10
>>>>>>>> Python/2.3.4
>>>>>>>> PHP/4.3.10-22 mod_perl/1.29
>>>>>>>> X-Powered-By    PHP/4.3.10-22
>>>>>>>> Content-Disposition     attachment; filename="f28514ba0.txt"
>>>>>>>> Keep-Alive      timeout=15, max=100
>>>>>>>> Connection      Keep-Alive
>>>>>>>> Transfer-Encoding       chunked
>>>>>>>> Content-Type    text/plain; charset=iso-8859-1
>>>>>>>>
>>>>>>>> So the problem might be the attachment...
>>>>>>>>
>>>>>>>> and that data from osm directly again on pastebin,
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> http://osmopenlayers.blogspot.com/2009/12/osm-data-from-xml-output-on-pastebin.html
>>>>>>>> data is here :http://pastebin.com/pastebin.php?dl=f290d5ea6 it
>>>>>>>> returns a
>>>>>>>> 200 ok.
>>>>>>>> It returns an : text/plain; charset=iso-8859-1 but does not render.
>>>>>>>> But there is still nothing there
>>>>>>>>
>>>>>>>> from osm directly
>>>>>>>> http://osmopenlayers.blogspot.com/2009/12/get-osm-data-directly.html
>>>>>>>> firebug says :no element found
>>>>>>>>
>>>>>>>> And my last try was to put the code from osm on the page directly,
>>>>>>>> also not rendering but the xml is loading.
>>>>>>>> http://osmopenlayers.blogspot.com/2009/12/test-of-osm-server.html
>>>>>>>>
>>>>>>>> but nothing is working
>>>>>>>>
>>>>>>>> would appreciate any tips and help
>>>>>>>> thanks
>>>>>>>> mike
>>>>>>>> _______________________________________________
>>>>>>>> Users mailing list
>>>>>>>> Users at openlayers.org
>>>>>>>> http://openlayers.org/mailman/listinfo/users
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>
>>>>>
>>>>
>>>
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>
>



More information about the Users mailing list