[OpenLayers-Users] Refresh map after updating chart elements

Jason Hawkins jfh at hbaspecto.com
Thu May 14 12:01:40 PDT 2015


 need to refresh an openlayers map after updating the size of pie charts in
a mapfile displayed on the map (on button click). I cannot refresh the
whole page or I lose the data. It works when I change the zoom level. I
have tried map.updateSize() (no effect), map.render() (TypeError "a" is not
defined), layer.redraw(). I am not sure if I am missing something
openlayers-related, or if it is an issue with my javascript. I have tested
a number of solutions, but can't seem to get any of the options working in
my case.

$(document).ready(function() {
    map = new OpenLayers.Map( 'map' ,
    { maxExtent: new OpenLayers.Bounds({{bounds.0}}, {{bounds.1}},
{{bounds.2}}, {{bounds.3}}),
    controls:[new OpenLayers.Control.Navigation(),
               new OpenLayers.Control.LayerSwitcher(),
               new OpenLayers.Control.PanZoomBar()],
     numZoomLevels:20
     }
     );
     var mpLayer = new OpenLayers.Layer.MapServer('Zones Layer', '{{
mapserverpath }}', {
                map:'{{mapFile}}',
                layers:'all',
                isBaseLayer: 'true'
                },{
                    singleTile: 'true'//                  ratio: 2.0
                }
            );

    map.addLayers([mpLayer]);
    //map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
    map.zoomToMaxExtent();

    map.events.register("click", map, qryDB );

    $(document).on('click', '#bttnMinus', function(){
        pieFact*=0.5;
        updatePieFact();
        mpLayer.redraw();
    });
    $(document).on('click', '#bttnPlus', function(){
        pieFact*=1.5;
        updatePieFact();
        mpLayer.redraw();
    });
    $(document).on('click', '#bttnReset', function(){
        pieFact=1.0;
        updatePieFact();
        mpLayer.redraw();
    });});
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20150514/ab3668f5/attachment-0001.html>


More information about the Users mailing list