Hello Arnd,<br><br>Thank you it works!<br><br>As for your question: <font color="#0000ff" face="Arial" size="2"><span>by the way, does your styleMap work
for the kml layer, if you set extractStyles to true?<br></span></font><br>I did not bother looking into it now, at first glance it does not. But, I will surely update you when I get to that in a week or so.<br><br>Thank you again. I will update you soon.<br>
<br>Regards.<br>Andres D.P.<br><br><br><div class="gmail_quote">On Fri, Jul 8, 2011 at 1:58 AM, Arnd Wippermann <span dir="ltr"><<a href="mailto:arnd.wippermann@web.de">arnd.wippermann@web.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<u></u>
<div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial" size="2"><span>Hi,</span></font></div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial" size="2"><span></span></font> </div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial" size="2"><span>register "loadend" for your layer:</span></font></div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial" size="2"><span></span></font> </div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial" size="2">MyKML
.events.register("loadend", MyKML , function (e) {<br>
map.zoomToExtent(MyKML .getDataExtent());<br>});<br></font></div>
<div><span></span><font color="#0000ff" face="Arial" size="2"><span>by the way, does your styleMap work
for the kml layer, if you set extractStyles to true?</span></font></div>
<div><font color="#0000ff" face="Arial" size="2"><span></span></font> </div>
<div><font face="Arial"><font color="#0000ff"><font size="2">Arnd</font></font></font></div>
<div><font face="Arial"><font color="#0000ff"><font size="2"><span></span></font></font></font><br> </div>
<div dir="ltr" align="left" lang="de">
<hr>
<font face="Tahoma" size="2"><b>Von:</b> <a href="mailto:openlayers-users-bounces@lists.osgeo.org" target="_blank">openlayers-users-bounces@lists.osgeo.org</a>
[mailto:<a href="mailto:openlayers-users-bounces@lists.osgeo.org" target="_blank">openlayers-users-bounces@lists.osgeo.org</a>] <b>Im Auftrag von </b>Andres
Deparis<br><b>Gesendet:</b> Donnerstag, 7. Juli 2011 08:31<br><b>An:</b>
<a href="mailto:openlayers-users@lists.osgeo.org" target="_blank">openlayers-users@lists.osgeo.org</a><br><b>Betreff:</b> [OpenLayers-Users] Zooming
to center of a KML layer after loadingit - request for
assistance<br></font><br></div><div><div></div><div class="h5">
<div></div>Hello everyone,<br><br>I am trying to be able to zoom or Pan (zooming
first) to the center of the data from my kml file that I load periodically. But,
in my case, I can load the data (which consist of one point at this moment) and
then of course to be able to center to that point. I have searched and found out
that perhaps my method does not work because I am zooming into the data but not
waiting for the data to be fully loaded.<br><br>Below is my piece of code. Thank
you in advance for the advice.<br><br>Andres D.P<br><br>var map;<br><br>function
init() {<br> <br><br> map
= new OpenLayers.Map({<br> div:
"map",<br> //projection: new
OpenLayers.Projection("EPSG:900913"),<br>
units: "m",<br> maxResolution:
156543.0339,<br> maxExtent: new
OpenLayers.Bounds(<br>
119.715815, -0.771406, 97.637881
,7.640186<br> )<br>,panDuration:
250 });<br><br> styleMap = new
OpenLayers.StyleMap({'default':{<br>
//label : "${th}",<br>
label :
"MYdog",<br>
fontColor:
"${fontColor}",<br>
fontSize:
"16px",<br>
labelAlign:
"${labelAlign}",<br>
pointRadius:
2,<br>
labelXOffset :
0,<br>
labelYOffset :
20<br>
}});<br><br> var osm = new
OpenLayers.Layer.OSM();<br> //var
vlayer = new OpenLayers.Layer.Vector( "Editable" );<br>
var MyKML = new OpenLayers.Layer.GML("KML", "dog.kml",
<br>
{<br>
projection: new
OpenLayers.Projection("EPSG:4326"),<br>
//displayProjection: new OpenLayers.Projection("EPSG:900913"),
<br><br>
format: OpenLayers.Format.KML,
<br>
formatOptions:
{<br>
extractStyles: true,
<br>
extractAttributes:
true,<br>
maxDepth:
1<br>
},<br>
styleMap:
styleMap<br>
});<br>
<br> map.addLayers([osm, MyKML]);<br> map.addControl(new
OpenLayers.Control.PanZoomBar());<br> map.addControl(new
OpenLayers.Control.Navigation({dragPanOptions: {enableKinetic:
true}}));<br> map.addControl(new
OpenLayers.Control.LayerSwitcher()); <br>
<br>// map.addControl(new
OpenLayers.Control.MouseToolbar());<br>// map.addControl(new
OpenLayers.Control.Navigation());<br>// map.addControl(new
OpenLayers.Control.LayerSwitcher());<br>// map.addControl(new
OpenLayers.Control.PanZoom());<br>// map.addControl(new
OpenLayers.Control.EditingToolbar();<br>//
map.addControl(OpenLayers.Control.EditingToolbar(vlayer));<br>
<br><br> map.setCenter(new
OpenLayers.LonLat(101.587411, 3.021547).transform(new
OpenLayers.Projection ("EPSG:4326"),<br>map.getProjectionObject()<br>), <br>15);
<br><br> <br>//map.zoomToExtent( MyKML.GetExtent()
);<br><br>window.setInterval(raingaugeRefreshData, 10000,
MyKML);<br><br><br>}<br><br>function
raingaugeRefreshData(layer)<br>{<br>//setting loaded to false unloads the
layer//<br><br>
<br>
layer.loaded =
false;<br>
//setting visibility to true forces a reload of the
layer//<br>
layer.setVisibility(true);<br>
//the refresh will force it to get the new KML
data//<br>
layer.setUrl('MyDOG.kml?_salt='+Math.random());<br>
//- <3 from Thqr -//<br>
map.zoomToExtent( MyKML.maxExtent );<br>
<br>
<br>
<br>}<br><br> <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br></div></div></div>
</blockquote></div><br>