personalizar OpenLayers

7 messages Options
Embed this post
Permalink
Ahmed Rodriguez Pando

personalizar OpenLayers

Reply Threaded More More options
Print post
Permalink
Hola lista en [1] tengo un ejemplo de openlayers con OSM como mapa base. Hasta ahí todo muy bien. He intentado ya de varias formas pero ninguna satisfactoria en lograr cambiar las imágenes de la barra de zoom y demás que quedan a la derecha. Si alguien tiene alguna receta lo agradeceré

<head>
<title>OpenStreetMap</title>
<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
<script src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js"></script>
<style type="text/css">
#map {
width: 100%;
height: 80%;
border: 1px solid black;
}
.olPopupContent{}
.olLayerGeoRSSClose{}
.olLayerGeoRSSTitle{}
.olLayerGeoRSSDescription{}


</style>

<script type="text/javascript">
var lon = -82.34872;
var lat = 23.13815;
var zoom = 15;

var markers = new OpenLayers.Layer.Markers( "Markers" );
var size = new OpenLayers.Size(15,15);
var offset = new OpenLayers.Pixel(-(size.w/2), -(size.h/2));
var icon = new OpenLayers.Icon('Trust.png',size,offset);

var map;

function init() {
map = new OpenLayers.Map ("map", {
controls:[
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.Attribution(),
new OpenLayers.Control.Permalink(),
new OpenLayers.Control.ScaleLine(),
new OpenLayers.Control.PanZoomBar()
],
maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
projection: new OpenLayers.Projection("EPSG:4326"),
units: 'm',
numZoomLevels: 19,
maxResolution: 'auto'
} );

Mapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik", {opacity : 0.75});


hotels = new OpenLayers.Layer.GeoRSS( 'Hotels', 'hoteles.xml',{'icon':icon});
pb_wms = new OpenLayers.Layer.WMS( "edicficios", "http://sit.ohc.cu/cgi-bin/mapserv?map=/home/mapfile/habows.map",
{layers: "manzanas,areas_verdes,edificios", transparent: "true", format: "image/png", sld: "http://sit.ohc.cu/osm/pinta.sld"},
{isBaseLayer : 0}
);
map.addLayers([Mapnik, pb_wms, hotels]);

var lonLat = new OpenLayers.LonLat(lon, lat).transform(map.projection, map.getProjectionObject());
map.setCenter (lonLat, zoom);

}

</script>
</head>

<!-- body.onload is called once the page is loaded (call the 'init' function) -->
<body onload="init();">

<!-- define a DIV into which the map will appear. Make it take up the whole window -->

<div style="width:100%; height:100%" id="map"></div>
</body>

</html>

[1] http://sit.ohc.cu/ejemplos/GeoRSS/testosm_georss.htm


--
---------------------------------------------------------------------
Ahmed Rodríguez Pando
Lic. en Ciencias de la Computación.
---------------------------------------------------------------------

_______________________________________________
Spanish mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/spanish
michogar

Re: personalizar OpenLayers

Reply Threaded More More options
Print post
Permalink
Hola Ahmed,

me imagino que te refieres a los controles que están a la izquierda. Yo personalicé los controles descargándome OpenLayers y cambiando las imágenes en el tema por defecto (../OpenLayers-2.8/theme/default/img), ahí encontrarás las imágenes y puedes directamente sustituirlas. Seguramente existan otras maneras, pero en mi caso, que era todo para ayer, fue la mas rápida.

Firebug te ayudará mucho para estas cosillas.


Saludos.



El 19 de agosto de 2009 22:54, Ahmed Rodriguez Pando <[hidden email]> escribió:
Hola lista en [1] tengo un ejemplo de openlayers con OSM como mapa base. Hasta ahí todo muy bien. He intentado ya de varias formas pero ninguna satisfactoria en lograr cambiar las imágenes de la barra de zoom y demás que quedan a la derecha. Si alguien tiene alguna receta lo agradeceré

<head>
<title>OpenStreetMap</title>
<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
<script src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js"></script>
<style type="text/css">
#map {
width: 100%;
height: 80%;
border: 1px solid black;
}
.olPopupContent{}
.olLayerGeoRSSClose{}
.olLayerGeoRSSTitle{}
.olLayerGeoRSSDescription{}


</style>

<script type="text/javascript">
var lon = -82.34872;
var lat = 23.13815;
var zoom = 15;

var markers = new OpenLayers.Layer.Markers( "Markers" );
var size = new OpenLayers.Size(15,15);
var offset = new OpenLayers.Pixel(-(size.w/2), -(size.h/2));
var icon = new OpenLayers.Icon('Trust.png',size,offset);

var map;

function init() {
map = new OpenLayers.Map ("map", {
controls:[
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.Attribution(),
new OpenLayers.Control.Permalink(),
new OpenLayers.Control.ScaleLine(),
new OpenLayers.Control.PanZoomBar()
],
maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
projection: new OpenLayers.Projection("EPSG:4326"),
units: 'm',
numZoomLevels: 19,
maxResolution: 'auto'
} );

Mapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik", {opacity : 0.75});


hotels = new OpenLayers.Layer.GeoRSS( 'Hotels', 'hoteles.xml',{'icon':icon});
pb_wms = new OpenLayers.Layer.WMS( "edicficios", "http://sit.ohc.cu/cgi-bin/mapserv?map=/home/mapfile/habows.map",
{layers: "manzanas,areas_verdes,edificios", transparent: "true", format: "image/png", sld: "http://sit.ohc.cu/osm/pinta.sld"},
{isBaseLayer : 0}
);
map.addLayers([Mapnik, pb_wms, hotels]);

var lonLat = new OpenLayers.LonLat(lon, lat).transform(map.projection, map.getProjectionObject());
map.setCenter (lonLat, zoom);

}

</script>
</head>

<!-- body.onload is called once the page is loaded (call the 'init' function) -->
<body onload="init();">

<!-- define a DIV into which the map will appear. Make it take up the whole window -->

<div style="width:100%; height:100%" id="map"></div>
</body>

</html>

[1] http://sit.ohc.cu/ejemplos/GeoRSS/testosm_georss.htm


--
---------------------------------------------------------------------
Ahmed Rodríguez Pando
Lic. en Ciencias de la Computación.
---------------------------------------------------------------------

_______________________________________________
Spanish mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/spanish




--
# michogar
# Analista Programador SIG
# GNU/Linux Counter 462666
# http://www.openstreetmap.org/user/michogar

Una visión personal:
http://michogar.wordpress.com

El día a día:
http://twitter.com/michogar




_______________________________________________
Spanish mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/spanish
PB-2

Re: personalizar OpenLayers

Reply Threaded More More options
Print post
Permalink
En versiones anteriores de OL había un map.theme que se podía setear
pero al parecer no funciona más.

El 19 de agosto de 2009 17:42, Micho Gar<[hidden email]> escribió:

> Hola Ahmed,
>
> me imagino que te refieres a los controles que están a la izquierda. Yo
> personalicé los controles descargándome OpenLayers y cambiando las imágenes
> en el tema por defecto (../OpenLayers-2.8/theme/default/img), ahí
> encontrarás las imágenes y puedes directamente sustituirlas. Seguramente
> existan otras maneras, pero en mi caso, que era todo para ayer, fue la mas
> rápida.
>
> Firebug te ayudará mucho para estas cosillas.
>
>
> Saludos.
>
>
>
> El 19 de agosto de 2009 22:54, Ahmed Rodriguez Pando <[hidden email]>
> escribió:
>>
>> Hola lista en [1] tengo un ejemplo de openlayers con OSM como mapa base.
>> Hasta ahí todo muy bien. He intentado ya de varias formas pero ninguna
>> satisfactoria en lograr cambiar las imágenes de la barra de zoom y demás que
>> quedan a la derecha. Si alguien tiene alguna receta lo agradeceré
>>
>> <head>
>>     <title>OpenStreetMap</title>
>>     <script src="http://www.openlayers.org/api/OpenLayers.js"></script>
>>
>>
>>
>>     <script
>> src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js"></script>
>>
>>     <style type="text/css">
>>         #map {
>>             width: 100%;
>>             height: 80%;
>>
>>             border: 1px solid black;
>>         }
>>         .olPopupContent{}
>>         .olLayerGeoRSSClose{}
>>         .olLayerGeoRSSTitle{}
>>         .olLayerGeoRSSDescription{}
>>
>>
>>     </style>
>>
>>
>>
>>
>>     <script type="text/javascript">
>>         var lon = -82.34872;
>> var lat = 23.13815;
>> var zoom = 15;
>>
>>
>> var markers = new OpenLayers.Layer.Markers( "Markers" );
>>         var size = new OpenLayers.Size(15,15);
>>         var offset = new OpenLayers.Pixel(-(size.w/2), -(size.h/2));
>>         var icon = new OpenLayers.Icon('Trust.png',size,offset);
>>
>>
>>
>>
>>         var map;
>>
>>         function init() {
>>             map = new OpenLayers.Map ("map", {
>>                 controls:[
>>                     new OpenLayers.Control.Navigation(),
>>
>>
>>
>>                     new OpenLayers.Control.Attribution(),
>>                     new OpenLayers.Control.Permalink(),
>>                     new OpenLayers.Control.ScaleLine(),
>>                     new OpenLayers.Control.PanZoomBar()
>>
>>
>>
>>                     ],
>>                 maxExtent: new
>> OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
>>                 projection: new OpenLayers.Projection("EPSG:4326"),
>>                 units: 'm',
>>
>>
>>
>>                 numZoomLevels: 19,
>>                 maxResolution: 'auto'
>>             } );
>>
>>             Mapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik", {opacity :
>> 0.75});
>>
>>
>>
>>
>>
>>             hotels = new OpenLayers.Layer.GeoRSS( 'Hotels',
>> 'hoteles.xml',{'icon':icon});
>>             pb_wms = new OpenLayers.Layer.WMS( "edicficios",
>> "http://sit.ohc.cu/cgi-bin/mapserv?map=/home/mapfile/habows.map",
>>
>>
>>
>>             {layers: "manzanas,areas_verdes,edificios", transparent:
>> "true", format: "image/png", sld: "http://sit.ohc.cu/osm/pinta.sld"},
>>
>>
>>
>>                     {isBaseLayer : 0}
>>                   );
>>             map.addLayers([Mapnik, pb_wms, hotels]);
>>
>>             var lonLat = new OpenLayers.LonLat(lon,
>> lat).transform(map.projection, map.getProjectionObject());
>>
>>
>>
>>             map.setCenter (lonLat, zoom);
>>
>>         }
>>
>>     </script>
>>
>> </head>
>>
>> <!-- body.onload is called once the page is loaded (call the 'init'
>> function) -->
>>
>>
>>
>> <body onload="init();">
>>
>>     <!-- define a DIV into which the map will appear. Make it take up the
>> whole window -->
>>
>>
>>     <div style="width:100%; height:100%" id="map"></div>
>>
>> </body>
>>
>> </html>
>>
>> [1] http://sit.ohc.cu/ejemplos/GeoRSS/testosm_georss.htm
>>
>>
>> --
>> ---------------------------------------------------------------------
>> Ahmed Rodríguez Pando
>> Lic. en Ciencias de la Computación.
>> ---------------------------------------------------------------------
>>
>> _______________________________________________
>> Spanish mailing list
>> [hidden email]
>> http://lists.osgeo.org/mailman/listinfo/spanish
>>
>
>
>
> --
> # michogar
> # Analista Programador SIG
> # GNU/Linux Counter 462666
> # http://www.openstreetmap.org/user/michogar
>
> Una visión personal:
> http://michogar.wordpress.com
>
> El día a día:
> http://twitter.com/michogar
>
>
>
>
> _______________________________________________
> Spanish mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/spanish
>
>
_______________________________________________
Spanish mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/spanish
Ahmed Rodriguez Pando

Re: personalizar OpenLayers

Reply Threaded More More options
Print post
Permalink
si ya esto del theme funciona solo para algunas cosas por ejemplo en la documentación dicen que la forma de usar esto es decir theme:null y redefinir uno mismo todo el css que se quiera pero recuerden que también estoy usando el openlayers de OSM lo que he visto es que le están escribiendo al duro las imágenes y estilos de estos controles en el CSS no encontré lugar donde cambiar esto.

El 19 de agosto de 2009 17:48, PB <[hidden email]> escribió:
En versiones anteriores de OL había un map.theme que se podía setear
pero al parecer no funciona más.

El 19 de agosto de 2009 17:42, Micho Gar<[hidden email]> escribió:
> Hola Ahmed,
>
> me imagino que te refieres a los controles que están a la izquierda. Yo
> personalicé los controles descargándome OpenLayers y cambiando las imágenes
> en el tema por defecto (../OpenLayers-2.8/theme/default/img), ahí
> encontrarás las imágenes y puedes directamente sustituirlas. Seguramente
> existan otras maneras, pero en mi caso, que era todo para ayer, fue la mas
> rápida.
>
> Firebug te ayudará mucho para estas cosillas.
>
>
> Saludos.
>
>
>
> El 19 de agosto de 2009 22:54, Ahmed Rodriguez Pando <[hidden email]>
> escribió:
>>
>> Hola lista en [1] tengo un ejemplo de openlayers con OSM como mapa base.
>> Hasta ahí todo muy bien. He intentado ya de varias formas pero ninguna
>> satisfactoria en lograr cambiar las imágenes de la barra de zoom y demás que
>> quedan a la derecha. Si alguien tiene alguna receta lo agradeceré
>>
>> <head>
>>     <title>OpenStreetMap</title>
>>     <script src="http://www.openlayers.org/api/OpenLayers.js"></script>
>>
>>
>>
>>     <script
>> src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js"></script>
>>
>>     <style type="text/css">
>>         #map {
>>             width: 100%;
>>             height: 80%;
>>
>>             border: 1px solid black;
>>         }
>>         .olPopupContent{}
>>         .olLayerGeoRSSClose{}
>>         .olLayerGeoRSSTitle{}
>>         .olLayerGeoRSSDescription{}
>>
>>
>>     </style>
>>
>>
>>
>>
>>     <script type="text/javascript">
>>         var lon = -82.34872;
>>              var lat = 23.13815;
>>              var zoom = 15;
>>
>>
>>              var markers = new OpenLayers.Layer.Markers( "Markers" );
>>         var size = new OpenLayers.Size(15,15);
>>         var offset = new OpenLayers.Pixel(-(size.w/2), -(size.h/2));
>>         var icon = new OpenLayers.Icon('Trust.png',size,offset);
>>
>>
>>
>>
>>         var map;
>>
>>         function init() {
>>             map = new OpenLayers.Map ("map", {
>>                 controls:[
>>                     new OpenLayers.Control.Navigation(),
>>
>>
>>
>>                     new OpenLayers.Control.Attribution(),
>>                     new OpenLayers.Control.Permalink(),
>>                     new OpenLayers.Control.ScaleLine(),
>>                     new OpenLayers.Control.PanZoomBar()
>>
>>
>>
>>                     ],
>>                 maxExtent: new
>> OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
>>                 projection: new OpenLayers.Projection("EPSG:4326"),
>>                 units: 'm',
>>
>>
>>
>>                 numZoomLevels: 19,
>>                 maxResolution: 'auto'
>>             } );
>>
>>             Mapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik", {opacity :
>> 0.75});
>>
>>
>>
>>
>>
>>              hotels = new OpenLayers.Layer.GeoRSS( 'Hotels',
>> 'hoteles.xml',{'icon':icon});
>>              pb_wms = new OpenLayers.Layer.WMS( "edicficios",
>> "http://sit.ohc.cu/cgi-bin/mapserv?map=/home/mapfile/habows.map",
>>
>>
>>
>>                                              {layers: "manzanas,areas_verdes,edificios", transparent:
>> "true", format: "image/png", sld: "http://sit.ohc.cu/osm/pinta.sld"},
>>
>>
>>
>>                     {isBaseLayer : 0}
>>                      );
>>             map.addLayers([Mapnik, pb_wms, hotels]);
>>
>>             var lonLat = new OpenLayers.LonLat(lon,
>> lat).transform(map.projection, map.getProjectionObject());
>>
>>
>>
>>             map.setCenter (lonLat, zoom);
>>
>>         }
>>
>>     </script>
>>
>> </head>
>>
>> <!-- body.onload is called once the page is loaded (call the 'init'
>> function) -->
>>
>>
>>
>> <body onload="init();">
>>
>>     <!-- define a DIV into which the map will appear. Make it take up the
>> whole window -->
>>
>>
>>     <div style="width:100%; height:100%" id="map"></div>
>>
>> </body>
>>
>> </html>
>>
>> [1] http://sit.ohc.cu/ejemplos/GeoRSS/testosm_georss.htm
>>
>>
>> --
>> ---------------------------------------------------------------------
>> Ahmed Rodríguez Pando
>> Lic. en Ciencias de la Computación.
>> ---------------------------------------------------------------------
>>
>> _______________________________________________
>> Spanish mailing list
>> [hidden email]
>> http://lists.osgeo.org/mailman/listinfo/spanish
>>
>
>
>
> --
> # michogar
> # Analista Programador SIG
> # GNU/Linux Counter 462666
> # http://www.openstreetmap.org/user/michogar
>
> Una visión personal:
> http://michogar.wordpress.com
>
> El día a día:
> http://twitter.com/michogar
>
>
>
>
> _______________________________________________
> Spanish mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/spanish
>
>
_______________________________________________
Spanish mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/spanish



--
---------------------------------------------------------------------
Ahmed Rodríguez Pando
Lic. en Ciencias de la Computación.
---------------------------------------------------------------------

_______________________________________________
Spanish mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/spanish
Eduin Carrillo-2

Re: personalizar OpenLayers

Reply Threaded More More options
Print post
Permalink
In reply to this post by Ahmed Rodriguez Pando
Asigna el tema del mapa como null y luego crea tu propia hoja de
estilos a partir de la original de OpenLayers.


<style type="text/css" media="all">@import
"/ruta/al/ccs/personalizado/style.css";</style>

...

map = new OpenLayers.Map("mapa", {  theme: null } );


El archivo CSS original está en
http://www.openlayers.org/api/theme/default/style.css


Eduin Yesid Carrillo Vega
Ingeniero Civil, Esp. Sistemas de Información Geográfica
Bogotá D.C., Colombia
_______________________________________________
Spanish mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/spanish
Ahmed Rodriguez Pando

Re: personalizar OpenLayers

Reply Threaded More More options
Print post
Permalink
si ya esto hice pero a este control en particular no veo la manera de cambiar su CSS ya que aqui http://www.openlayers.org/api/theme/default/style.css ellos no lo hacen infiero que lo hacen en el JS

El 19 de agosto de 2009 17:54, Eduin Carrillo <[hidden email]> escribió:
Asigna el tema del mapa como null y luego crea tu propia hoja de
estilos a partir de la original de OpenLayers.


<style type="text/css" media="all">@import
"/ruta/al/ccs/personalizado/style.css";</style>

...

map = new OpenLayers.Map("mapa", {  theme: null } );


El archivo CSS original está en
http://www.openlayers.org/api/theme/default/style.css


Eduin Yesid Carrillo Vega
Ingeniero Civil, Esp. Sistemas de Información Geográfica
Bogotá D.C., Colombia
_______________________________________________
Spanish mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/spanish



--
---------------------------------------------------------------------
Ahmed Rodríguez Pando
Lic. en Ciencias de la Computación.
---------------------------------------------------------------------

_______________________________________________
Spanish mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/spanish
Eduin Carrillo-2

Re: personalizar OpenLayers

Reply Threaded More More options
Print post
Permalink
Prueba inspeccionando el control con firebug. Yo encuentro los
siguientes elementos css de imagen:

OpenLayers_Control_PanZoomBar_ZoombarOpenLayers.Map_4
OpenLayers.Control.PanZoomBar_3_zoomin_innerImage
OpenLayers.Control.PanZoomBar_3_zoomout_innerImage


Eduin Yesid Carrillo Vega
Ingeniero Civil, Esp. Sistemas de Información Geográfica
Bogotá D.C., Colombia




2009/8/19 Ahmed Rodriguez Pando <[hidden email]>:

> si ya esto hice pero a este control en particular no veo la manera de
> cambiar su CSS ya que aqui
> http://www.openlayers.org/api/theme/default/style.css ellos no lo hacen
> infiero que lo hacen en el JS
>
> El 19 de agosto de 2009 17:54, Eduin Carrillo <[hidden email]>
> escribió:
>>
>> Asigna el tema del mapa como null y luego crea tu propia hoja de
>> estilos a partir de la original de OpenLayers.
>>
>>
>> <style type="text/css" media="all">@import
>> "/ruta/al/ccs/personalizado/style.css";</style>
>>
>> ...
>>
>> map = new OpenLayers.Map("mapa", {  theme: null } );
>>
>>
>> El archivo CSS original está en
>> http://www.openlayers.org/api/theme/default/style.css
>>
>>
>> Eduin Yesid Carrillo Vega
>> Ingeniero Civil, Esp. Sistemas de Información Geográfica
>> Bogotá D.C., Colombia
>> _______________________________________________
>> Spanish mailing list
>> [hidden email]
>> http://lists.osgeo.org/mailman/listinfo/spanish
>
>
>
> --
> ---------------------------------------------------------------------
> Ahmed Rodríguez Pando
> Lic. en Ciencias de la Computación.
> ---------------------------------------------------------------------
>
> _______________________________________________
> Spanish mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/spanish
>
>
_______________________________________________
Spanish mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/spanish