<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
code
        {mso-style-priority:99;
        font-family:"Courier New";}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.comment-copy
        {mso-style-name:comment-copy;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;}
span.EmailStyle22
        {mso-style-type:personal-reply;
        font-family:"Courier New";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'>Does anyone have any suggestion or a tip or anything. I can’t believe I’m doing something so farfetched that no one here can give me a pointer.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'>Miguel<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> openlayers-users-bounces@lists.osgeo.org [mailto:openlayers-users-bounces@lists.osgeo.org] <b>On Behalf Of </b>Juan Abreu<br><b>Sent:</b> Saturday, August 31, 2013 4:48 AM<br><b>To:</b> openlayers-users@lists.osgeo.org<br><b>Subject:</b> [OpenLayers-Users] change tms layer does not change map view<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal><span style='font-family:"Calibri","sans-serif"'>I have a TMS layer that I'm using as my map, i have set it up so that users can change the map however changing the layer does not update the map view until i hit the zoom in button or the zoom out button. how can i refresh the map view to show the newly added layer? here is a quick code sample. i tried layer.redraw() without any solution. does someone have any other ideas.<span class=comment-copy>on a desperate  i just try setting the map div html to "" and it finally updated the layer. is this the proper way to do this?</span><br><br>[code sample below]<o:p></o:p></span></p><pre><code>function initMAP() {<o:p></o:p></code></pre><pre><code>    var mapBounds = new OpenLayers.Bounds(bounds[0], bounds[1], bounds[2], bounds[3]);<o:p></o:p></code></pre><pre><code>    var mapMinZoom = 0;<o:p></o:p></code></pre><pre><code>    var mapMaxZoom = 3;<o:p></o:p></code></pre><pre><code><o:p> </o:p></code></pre><pre><code>    // avoid pink tiles<o:p></o:p></code></pre><pre><code>    OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;<o:p></o:p></code></pre><pre><code>    OpenLayers.Util.onImageLoadErrorColor = "transparent";<o:p></o:p></code></pre><pre><code><o:p> </o:p></code></pre><pre><code><o:p> </o:p></code></pre><pre><code><o:p> </o:p></code></pre><pre><code><o:p> </o:p></code></pre><pre><code>    var options = {<o:p></o:p></code></pre><pre><code>        theme: null,<o:p></o:p></code></pre><pre><code>        controls: [<o:p></o:p></code></pre><pre><code><o:p> </o:p></code></pre><pre><code>        new OpenLayers.Control.Navigation({<o:p></o:p></code></pre><pre><code>            dragPanOptions: {<o:p></o:p></code></pre><pre><code>                //     enableKinetic: true<o:p></o:p></code></pre><pre><code>            }<o:p></o:p></code></pre><pre><code>        }),<o:p></o:p></code></pre><pre><code>        new OpenLayers.Control.Attribution(),<o:p></o:p></code></pre><pre><code>        new OpenLayers.Control.Zoom()<o:p></o:p></code></pre><pre><code>        ],<o:p></o:p></code></pre><pre><code><o:p> </o:p></code></pre><pre><code>        maxExtent: new OpenLayers.Bounds(bounds[0], bounds[1], bounds[2], bounds[3]),<o:p></o:p></code></pre><pre><code>        maxResolution: 4,<o:p></o:p></code></pre><pre><code>        numZoomLevels: 3<o:p></o:p></code></pre><pre><code><o:p> </o:p></code></pre><pre><code>    };<o:p></o:p></code></pre><pre><code><o:p> </o:p></code></pre><pre><code><o:p> </o:p></code></pre><pre><code>    map = new OpenLayers.Map('map', options);<o:p></o:p></code></pre><pre><code><o:p> </o:p></code></pre><pre><code>      layer = new OpenLayers.Layer.TMS("TMS", "<a href="http://mymapserver.com/MAP2/">http://mymapserver.com/MAP2/</a>", { 'type': 'png', 'getURL': get_my_url });<o:p></o:p></code></pre><pre><code><o:p> </o:p></code></pre><pre><code><o:p> </o:p></code></pre><pre><code>      map.addLayer(layer);<o:p></o:p></code></pre><pre><code>      layer.redraw({ force: true });<o:p></o:p></code></pre><pre><code><o:p> </o:p></code></pre><pre><code>      map.zoomToExtent(mapBounds);<o:p></o:p></code></pre><pre><code><o:p> </o:p></code></pre><pre><code>    new OpenLayers.Control.Attribution(),<o:p></o:p></code></pre><pre><code>    new OpenLayers.Control.Zoom()<o:p></o:p></code></pre><pre><code><o:p> </o:p></code></pre><pre><code>}</code><br><br><br><o:p></o:p></pre><pre><o:p> </o:p></pre><p class=MsoNormal><span style='font-family:"Calibri","sans-serif"'><o:p> </o:p></span></p></div></div></body></html>