<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Non-knockout code that shows same behavior:<div><br></div><div><div><span class="Apple-tab-span" style="white-space:pre">    </span>var map = new OpenLayers.Map('My-OpenLayers-Map');</div><div><span class="Apple-tab-span" style="white-space:pre">   </span>if (!_epsg4326) {</div><div><span class="Apple-tab-span" style="white-space:pre">            </span>_epsg4326 = new OpenLayers.Projection("EPSG:4326");</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}<span class="Apple-tab-span" style="white-space:pre">   </span></div><div><span class="Apple-tab-span" style="white-space:pre">     </span></div><div><span class="Apple-tab-span" style="white-space:pre">     </span>var arrayOSM = ["http://otile1.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.jpg",</div><div><span class="Apple-tab-span" style="white-space:pre">                              </span>"http://otile2.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.jpg",</div><div><span class="Apple-tab-span" style="white-space:pre">                              </span>"http://otile3.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.jpg",</div><div><span class="Apple-tab-span" style="white-space:pre">                              </span>"http://otile4.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.jpg"];</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">    </span>var baseOSM = new OpenLayers.Layer.OSM("osm", arrayOSM);</div><div><span class="Apple-tab-span" style="white-space:pre">   </span></div><div><span class="Apple-tab-span" style="white-space:pre">     </span>var baseWMS = new OpenLayers.Layer.WMS("wms","http://vmap0.tiles.osgeo.org/wms/vmap0",{layers: "basic"});</div><div><br></div><div><br></div><div><div><span class="Apple-tab-span" style="white-space: pre;">       </span>map.addLayer(baseOSM);</div><div><br></div><div><span class="Apple-tab-span" style="white-space: pre;">    </span>map.addLayer(baseWMS);</div><div><br></div><div><span class="Apple-tab-span" style="white-space: pre;">    </span>map.addControl(new OpenLayers.Control.LayerSwitcher());</div><div><br></div><div><span class="Apple-tab-span" style="white-space: pre;">   </span>map.setCenter(</div><div><span class="Apple-tab-span" style="white-space: pre;">             </span>new OpenLayers.LonLat(-121.4668,45.7153).transform(</div><div><span class="Apple-tab-span" style="white-space: pre;">                        </span>_epsg4326, map.getProjectionObject()), 14</div><div><span class="Apple-tab-span" style="white-space: pre;">  </span>);</div></div><div><br></div><div><br></div></div><div><br><br><div><hr id="stopSpelling">From: jbyook@hotmail.com<br>To: openlayers-users@lists.osgeo.org<br>Date: Thu, 1 Oct 2015 13:53:46 -0400<br>Subject: [OpenLayers-Users] setCenter takes different coordinates/projection for WMS & OSM?<br><br>

<style><!--
.ExternalClass .ecxhmmessage P {
padding:0px;
}

.ExternalClass body.ecxhmmessage {
font-size:12pt;
font-family:Calibri;
}

--></style>
<div dir="ltr">Hi all,<div>I'm trying to create a map with multiple layers, and initialize it by setting its center.</div><div><br></div><div>Code is:</div><div><br></div><div>//javascript + knockout.js</div><div>self.initialize = function() {</div><div>      self.epsg4326(new OpenLayers.Projection("EPSG:4326"));  //self.epsg4326 declared as an observable elsewhere</div><div><br></div><div>      self.map = new OpenLayers.Map('Little basic map');</div><div><br></div><div><div>      self.map.addLayer(new OpenLayers.Layer.OSM("osm",["http://otile1.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.jpg",</div><div><span class="ecxApple-tab-span" style="white-space:pre;">                                                                                                     </span>  "http://otile2.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.jpg",</div><div><span class="ecxApple-tab-span" style="white-space:pre;">                                                                                                      </span>  "http://otile3.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.jpg",</div><div><span class="ecxApple-tab-span" style="white-space:pre;">                                                                                                      </span>  "http://otile4.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.jpg"]));</div><div><span class="ecxApple-tab-span" style="white-space:pre;">                           </span></div><div>      self.map.addLayer(new OpenLayers.Layer.WMS("wms","http://vmap0.tiles.osgeo.org/wms/vmap0",{layers: "basic"}));</div><div><span class="ecxApple-tab-span" style="white-space:pre;">                         </span></div><div>      self.map.addControl(new OpenLayers.Control.LayerSwitcher());</div></div><div><br></div><div>      self.map.setCenter(new OpenLayers.LonLat(-105.0000,37.2500).transform(self.epsg4326(), self.getProjection()), 9);</div><div>      //alternatively:</div><div>      //<span style="font-size:12pt;">self.map.setCenter(new OpenLayers.LonLat(-105.0000,37.2500), 9);</span></div><div>}</div><div><br></div><div>With the transform, the osm layer is displayed correctly. Centered above Southern Colorado in North America. But, the wms layer is just blank. No "broken link" tile icons, even.</div><div><br></div><div>On the other hand, if I use LonLat without transforming it, the osm map starts out centered around 0,0: somewhere in the Gulf of Guinea. The wms layer works, however. It now starts out centered over Southern Colorado.</div><div><br></div><div>I have similar problems with other Layer types, like Google (which behaves like OSM) & ArcGIS93Rest (which behaves like WMS).</div><div><br></div><div>I've looked at the OpenLayers (2) documentation for Layer.OSM, WMS etc, but it doesn't shed any light on this.</div><div><br></div><div>Has anyone run into a similar problem, or can see what I'm doing wrong?</div><div><br></div><div>Thanks,</div><div><br></div><div>John</div>                                     </div>
<br>_______________________________________________
Users mailing list
Users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users</div></div>                                          </div></body>
</html>