Adding Labels to a Vector Map with Java Mapscript
Alejandro Rico
jarg58 at GMAIL.COM
Sun Jul 23 13:42:20 PDT 2006
Hi!!!
I try what you said, but the method setColor in classObj doesn't exist, then
i didn't modify the part of the style. However running the program it draws
the map with the same labels.
here's the mapfile and the map image.
thanks for your help !!!!!
On 7/23/06, Umberto Nicoletti <umberto.nicoletti at gmail.com> wrote:
>
> Try this modifications:
>
> Capa = new layerObj(Mapa);
> Capa.setName("Vias");
> Capa.setType(mapscriptConstants.MS_LAYER_LINE);
> Capa.setStatus(mapscriptConstants.MS_ON );
> String Comando = new String("the_geom FROM (select gid,
> the_geom, nomb_comun||' '||nomvial as Nombre FROM "+Localidad+" WHERE
> codigo IN ("+CodigoVia+","+CodigoInterseccion+")) AS ViasMapa USING
> UNIQUE gid USING SRID=-1");
> Capa.setData(Comando);
> Capa.setLabelitem("Nombre");
> Capa.setConnection("user=geotrans dbname=Geotrans
> host=localhost");
> Capa.setConnectiontype (mapscriptConstants.MS_POSTGIS);
> Clase = new classObj(Capa);
> // CHANGE FROM HERE
> Clase.setName('Pick a name');
> // comment out the style
> // Estilo = new styleObj(Clase);
> // Estilo.setColor(new colorObj(255,0,0,0));
> // and use this to set the color instead
> Clase.setColor(new colorObj(255,0,0,0));
> // END OF CHANGE
> labelObj Etiquetas = new labelObj();
> Etiquetas.setSize(18);
> Etiquetas.setColor(new colorObj(0,255,255,0));
> Etiquetas.setType(mapscriptConstants.MS_TRUETYPE);
> Etiquetas.setAntialias(mapscriptConstants.MS_TRUE );
> Etiquetas.setPosition(mapscriptConstants.MS_CL);
> // CHANGE: comment this too
> //Etiquetas.setPartials(mapscriptConstants.MS_FALSE);
> //Etiquetas.setMindistance(300);
> Etiquetas.setFont("vera");
> Clase.setLabel(Etiquetas);
> Mapa.draw
> ().save("/usr/local/tomcat/webapps/geotrans/Mapas/mapaAcc",null);
>
> You could also try to save the map to a file to make sure everything
> got setup properly in mapscript. To do this simply call
> Mapa.save('filename'); then post the map file to the list.
>
> Regards,
> Umberto
>
>
> On 7/23/06, Alejandro Rico <jarg58 at gmail.com> wrote:
> >
> > >
> > > Hi !!!
> > > I try with your suggestions but it doesn't work.
> > > here's a sample image of the map generated, and the fontset file
> > >
> > > thanks !!!
> > >
> > >
> > >
> > > On 7/22/06, Umberto Nicoletti < umberto.nicoletti at gmail.com> wrote:
> > > > Can you post a sample generated image with only this layer on and
> your
> > > > fontset file?
> > > > You could also try to remove mindistance and to set the layer's
> status
> > > > to MS_DEFAULT.
> > > >
> > > > Regards,
> > > > Umberto
> > > >
> > > > On 7/21/06, Alejandro Rico < jarg58 at gmail.com> wrote:
> > > > > Hi !!!
> > > > >
> > > > > I'm working with a vector map made in Java Mapscript, with 2
> layers,
> > and i
> > > > > need that one of them has labels to identify a way, but when the
> > program
> > > > > runs, mapserver draws a very little ununderstandable labels,
> and it
> > doesn't
> > > > > take the font size change. Someone can help me with
> this??? thanks.
> > > > >
> > > > > here's my code:
> > > > >
> > > > > Capa = new layerObj(Mapa);
> > > > > Capa.setName("Vias");
> > > > >
> > Capa.setType(mapscriptConstants.MS_LAYER_LINE);
> > > > > Capa.setStatus(mapscriptConstants.MS_ON );
> > > > > String Comando = new String("the_geom FROM (select
> gid,
> > > > > the_geom, nomb_comun||' '||nomvial as Nombre FROM "+Localidad+"
> WHERE
> > codigo
> > > > > IN ("+CodigoVia+","+CodigoInterseccion+")) AS
> > ViasMapa
> > > > > USING UNIQUE gid USING SRID=-1");
> > > > > Capa.setData(Comando);
> > > > > Capa.setLabelitem("Nombre");
> > > > > Capa.setConnection("user=geotrans dbname=Geotrans
> > > > > host=localhost");
> > > > > Capa.setConnectiontype (mapscriptConstants.MS_POSTGIS
> );
> > > > > Clase = new classObj(Capa);
> > > > > Estilo = new styleObj(Clase);
> > > > > Estilo.setColor(new colorObj(255,0,0,0));
> > > > > labelObj Etiquetas = new labelObj();
> > > > > Etiquetas.setSize(18);
> > > > > Etiquetas.setColor(new colorObj(0,255,255,0));
> > > > > Etiquetas.setType(mapscriptConstants.MS_TRUETYPE);
> > > > > Etiquetas.setAntialias(mapscriptConstants.MS_TRUE );
> > > > > Etiquetas.setPosition(mapscriptConstants.MS_CL);
> > > > > Etiquetas.setPartials(mapscriptConstants.MS_FALSE);
> > > > > Etiquetas.setMindistance (300);
> > > > > Etiquetas.setFont("vera");
> > > > > Clase.setLabel(Etiquetas);
> > > > >
> > > > >
> > Mapa.draw
> ().save("/usr/local/tomcat/webapps/geotrans/Mapas/mapaAcc",null);
> > > > > --
> > > > > Alejandro Rico
> > > >
> > >
> > >
> > >
> > >
> > > --
> > >
> > > Alejandro Rico
> > >
> >
> >
> >
> > --
> > Alejandro Rico
> >
>
--
Alejandro Rico
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20060723/7e203928/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mapaAcc.gif
Type: image/gif
Size: 10821 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20060723/7e203928/attachment.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mapa.map
Type: application/octet-stream
Size: 2742 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20060723/7e203928/attachment.obj>
More information about the MapServer-users
mailing list