How change icon Marker Gmap Primefaces?

夙愿已清 提交于 2019-12-11 11:57:21

问题


Hello community I'm starting with Gmap Primefaces component, and want to know how to change the icons. I have relied on the showcase of Primefaces:

this.advancedModel.addOverlay(new Marker(coord1, "Konyaalti", "konyaalti.png", "http://maps.google.com/mapfiles/ms/micons/blue-dot.png"));
this.advancedModel.addOverlay(new Marker(coord2, "Ataturk Parki", "ataturkparki.png"));
this.advancedModel.addOverlay(new Marker(coord4, "Kaleici", "kaleici.png", "http://maps.google.com/mapfiles/ms/micons/pink-dot.png"));
this.advancedModel.addOverlay(new Marker(coord3, "Karaalioglu Parki", "karaalioglu.png", "http://maps.google.com/mapfiles/ms/micons/yellow-dot.png"));  

I've downloaded the icons to my project, and I've routed, but just does not work and marker icons are samples.

StringBuilder ruta = new StringBuilder();
ruta.append(getContext().getRealPath(Constantes.DIVISOR));
ruta.append("resources/maps/images/");

StringBuilder bluedot = new StringBuilder(); 
bluedot.append(ruta);
bluedot.append("blue-dot");
bluedot.append(Constantes.EXTENSION_FORMATO_PNG);

StringBuilder pinkdot = new StringBuilder(); 
pinkdot.append(ruta);
pinkdot.append("pink-dot");
pinkdot.append(Constantes.EXTENSION_FORMATO_PNG);

StringBuilder yellowdot = new StringBuilder(); 
yellowdot.append(ruta);
yellowdot.append("yellow-dot");
yellowdot.append(Constantes.EXTENSION_FORMATO_PNG);

System.out.println("---> "+bluedot.toString());

//Icons and Data
this.advancedModel.addOverlay(new Marker(coord1, "Konyaalti", "konyaalti.png", bluedot.toString()));
this.advancedModel.addOverlay(new Marker(coord2, "Ataturk Parki", "ataturkparki.png"));
this.advancedModel.addOverlay(new Marker(coord4, "Kaleici", "kaleici.png", pinkdot.toString()));
this.advancedModel.addOverlay(new Marker(coord3, "Karaalioglu Parki", "karaalioglu.png", yellowdot.toString()));

Being well the image file path, but still does not consider the Marker PrimeFaces, to which it should be ???

Console:

D:\springsource\apache tomcat 7.0.53\webapps\geotermica\resources\maps\images\blue-dot.png

回答1:


If you want to point to a file on your file system you should use the file:// scheme. See: How to specify a local file within html using the file: scheme?

If you want to create a relative URL to fetch the image from your webserver you should use the context path instead of the real path:

StringBuilder ruta = new StringBuilder();
ruta.append(FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath());
ruta.append("/resources/maps/images/");


来源:https://stackoverflow.com/questions/27176166/how-change-icon-marker-gmap-primefaces

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!