[OpenLayers-Users] Own map layer in different projection
Olivier Terral
olivier at geomatic.ch
Wed Jun 27 07:23:23 PDT 2012
Hi dalori,
For your cache I don't know what is the problem but for your marker I think you just inverted the lon/lat value.
Le 27 juin 2012 à 11:18, dalori a écrit :
> Yes I have. :-)
>
> <!DOCTYPE HTML>
> <html>
> <head>
> <title>Rectangular tiles</title>
> <style type="text/css">
> html, body, #map {
> width: 100%;
> height: 100%;
> margin: 0;
> }
> </style>
> <script src="http://www.openlayers.org/api/OpenLayers.js"></script>
> <script>
> function get_my_url(bounds) {
> var res = this.map.getResolution();
> var x = Math.round((bounds.left - this.maxExtent.left) / (res *
> this.tileSize.w));
> var y = Math.round((this.maxExtent.top - bounds.top) / (res *
> this.tileSize.h));
> var z = this.map.getZoom();
>
> // tiles are named like 0001 instead of simply 1
> x = "000" + x;
> x = x.substring(4, 0);
> y = "000" + y;
> y = y.substring(4, 0);
>
> var path = z + "/" + x + "/tile_" + y + "." + this.type;
> var url = this.url;
> if( url instanceof Array) {
> url = this.selectUrl(path, url);
> }
> return url + path;
> }
>
> var map, point, markers;
>
> function init() {
> point = new OpenLayers.LonLat(54.167258, -131.662903);
> map = new OpenLayers.Map("map", {
> tileSize : new OpenLayers.Size(512, 512)
> });
> map.addLayer(new OpenLayers.Layer.TMS("Name",
> "http://www.bananenhand.de/background/level", {
> 'type' : 'jpg',
> 'getURL' : get_my_url
> }));
> map.setCenter(point, 2);
>
> markers = new OpenLayers.Layer.Markers("Markers");
> map.addLayer(markers);
> markers.addMarker(new OpenLayers.Marker(point));
> }
> </script>
> </head>
> <body onload="init();">
> <div id="map"></div>
> </body>
> </html>
>
> View this message in context: Re: Own map layer in different projection
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
Olivier Terral
GEOMATIC Ingénierie SA
Société du groupe Ringier
Chemin des Croisettes 26
1066 Epalinges
www.geomatic.ch
www.thevirtualcity.ch
Tél:: +41 (21) 651 30 00
Fax: +41 (21) 651 30 09
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120627/4fe6c18f/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PastedGraphic-1.gif
Type: image/gif
Size: 5116 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120627/4fe6c18f/attachment-0001.gif>
More information about the Users
mailing list