Hello社区我从Gmap Primefaces组件开始,想知道如何更改图标。 我依靠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"));
我已经将图标下载到我的项目中,并且我已经路由,但是只是不起作用,标记图标是样本。
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()));
很好的图像文件路径,但仍然没有考虑它应该是Marker PrimeFaces ???
Console:
D:\springsource\apache tomcat 7.0.53\webapps\geotermica\resources\maps\images\blue-dot.png
答案 0 :(得分:3)
如果要指向文件系统上的文件,则应使用file://
方案。请参阅:How to specify a local file within html using the file: scheme?
如果您想创建相对网址以从网络服务器获取图片,则应使用context path而不是真实路径:
StringBuilder ruta = new StringBuilder();
ruta.append(FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath());
ruta.append("/resources/maps/images/");