[OpenLayers-Users] Best option for visualizing JSON
Lehtonen, Mika
mika at digikartta.net
Thu Jan 8 11:48:58 EST 2009
Solved.
I added params: {random: Math.random()} to my request and now my
application works also in IE7. Some caching problem? Known issue?
- mika -
Lehtonen, Mika kirjoitti:
> Hi again,
> actually I might have been barking the wrong tree. This is what seem not
> to be working in IE7.
>
> function selectAll() {
> req = OpenLayers.Request.issue({
> method: 'GET', url:'http://mydomain/my.php',
> headers:{"Content-Type":
> "application/x-www-form-urlencoded"},
> callback: json
> });
> }
>
> It works at the start, but the second attempt in IE7 won't return
> anything. So that's why the newly inserted row won't update my map. Is
> there something wrong with that request?
>
> - mika -
>
> Lehtonen, Mika kirjoitti:
>
>> Thanks Christopher,
>> for your answer. However, beacuse there's not so many points and I have
>> to put this together quickly and because this is just a temporary
>> solution, I ended up adding points onto a vector layer one by one. So
>> here's the function that does that:
>>
>> function json(req) {
>> g = new OpenLayers.Format.JSON();
>> vastaus = g.read(req.responseText);
>> vlayer.destroyFeatures();
>> for (i in vastaus) {
>> piste = new OpenLayers.Geometry.Point(vastaus[i].x, vastaus[i].y);
>> spot = new OpenLayers.Feature.Vector(piste,{id: vastaus[i].id});
>> vlayer.addFeatures(spot);
>> }
>> // vlayer.redraw(true);
>> }
>>
>> Behind this, is an OpenLayers.Request that requests the json from
>> database using php-script for that. I also have a function which adds
>> points to the database. This all works fine in FF3, but not in IE7. If I
>> add a point in IE, it won't appear until I restart the browser. Even
>> reloading the page won't help. Still if, after I have added the point in
>> IE, I reload the page in FF3, the newly added point appears in it.
>> Any idea what's wrong?
>>
>> - mika -
>>
>> Christopher Schmidt kirjoitti:
>>
>>
>>> On Wed, Jan 07, 2009 at 11:28:37PM +0200, Lehtonen, Mika wrote:
>>>
>>>
>>>
>>>> Hi,
>>>> I have some JSON data produced from an "ordinary" database. Basically
>>>> it's an array having objects that include x-, y- and some attribute values.
>>>>
>>>> What would be the best way to render these x-, y-values as points or
>>>> markers in Openlayers. Should I use Marker or Vector or what layer? Any
>>>> Examples?
>>>>
>>>>
>>>>
>>> I'd recommend turning the data into GeoJSON on the server, then using a
>>> Vector Layer with the HTTP Protocol and the GeoJSON format
>>> (alternatively, a GML Layer with a GeoJSON format). If you really can't
>>> do that, then you could write a custom subclass o the JSON format,
>>> basing it of something like the GeoJSON format, and follow either of the
>>> above options with your custom format.
>>>
>>> Regards,
>>>
>>>
>>>
>> _______________________________________________
>> 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