[Talk-de] OpenLayers-Frage: Projektionssystem für Punkt?
Johannes Huesing
johannes at huesing.name
Mo Feb 14 21:33:21 UTC 2011
Ich weiß nicht, wie weit OpenLayers hier OT ist. In diesem Minimalbeispiel
erscheint der fünfzackige Stern nicht in dem anfänglichen Kartenausschnitt,
sondern am OSM-Südpol:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 100%;
height: 80%;
border: 0px;
padding: 0px;
position: absolute;
}
body {
border: 0px;
margin: 0px;
padding: 0px;
height: 100%;
}
</style>
<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
<script src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js"></script>
<script type="text/javascript">
<!--
// complex map object
var map;
// Start position for the map (hardcoded here for simplicity,
// but maybe you want to get from URL params)
var lat = 48.49345;
var lon = 8.71229;
var zoom = 14;
function init(){
map = new OpenLayers.Map('map',
{ maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
numZoomLevels: 19,
maxResolution: 156543.0399,
units: 'm',
projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:4326")
});
// var layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");
var layerTah = new OpenLayers.Layer.OSM.Osmarender("Tiles at Home");
map.addLayer(layerTah);
// Experimental layer
/*
* Blue style
*/
var layer_style = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']);
layer_style.fillOpacity = 0.8;
var style_blue = OpenLayers.Util.extend({}, layer_style);
style_blue.strokeColor = "blue";
style_blue.fillColor = "blue";
style_blue.graphicName = "star";
style_blue.pointRadius = 10;
style_blue.strokeWidth = 3;
style_blue.rotation = 45;
style_blue.strokeLinecap = "butt";
var point = new OpenLayers.Geometry.Point(8.718685,48.475637);
var vectorLayer = new OpenLayers.Layer.Vector("Glyphs",
{projection: map.displayProjection});
var feature = new OpenLayers.Feature.Vector(
point,null, style_blue);
vectorLayer.addFeatures(feature);
map.addLayer(vectorLayer);
map.addControl(new OpenLayers.Control.LayerSwitcher());
var lonLat = new OpenLayers.LonLat(lon, lat).transform(map.displayProjection, map.projection);
if (!map.getCenter()) map.setCenter (lonLat, zoom);
}
// -->
</script>
</head>
<body onload="init()">
<div id="map"></div>
</body>
</html>
--
Johannes Hüsing There is something fascinating about science.
One gets such wholesale returns of conjecture
mailto:johannes at huesing.name from such a trifling investment of fact.
http://derwisch.wikidot.com (Mark Twain, "Life on the Mississippi")
Mehr Informationen über die Mailingliste Talk-de