PrimeFaces Gmap标签忽略模型issuse

时间:2016-07-23 19:06:26

标签: javascript jsf primefaces ejb

我在primefaces 6.0中使用gmap时遇到问题,我尝试在此URL中使用primefaces示例www.primefaces.org/showcase/ui/data/gmap/markers.xhtml

我的代码完全相同,但地图上没有显示

<script type="text/javascript"  
src="https://maps.googleapis.com/maps/api/js?key=myapikey">  


    

@ManagedBean
public class MarkersView implements Serializable {

/**
 * 
 */
private static final long serialVersionUID = 1L;
private MapModel simpleModel;

@PostConstruct
public void init() {
    simpleModel = new DefaultMapModel();

    //Shared coordinates
    LatLng coord1 = new LatLng(36.879466, 30.667648);
    LatLng coord2 = new LatLng(36.883707, 30.689216);
    LatLng coord3 = new LatLng(36.879703, 30.706707);
    LatLng coord4 = new LatLng(36.885233, 30.702323);

    //Basic marker
    simpleModel.addOverlay(new Marker(coord1, "Konyaalti", "http://maps.google.com/mapfiles/ms/micons/blue-dot.png"));
    simpleModel.addOverlay(new Marker(coord2, "Ataturk Parki"));
    simpleModel.addOverlay(new Marker(coord3, "Karaalioglu Parki", "http://maps.google.com/mapfiles/ms/micons/blue-dot.png"));
    simpleModel.addOverlay(new Marker(coord4, "Kaleici", "http://maps.google.com/mapfiles/ms/micons/blue-dot.png"));
}

public MapModel getSimpleModel() {
    return simpleModel;
}
}

我也尝试添加折线,多边形,圆形,矩形......等,但地图上没有任何显示 我测试其他组件,如按钮,输入,grwl..etc一切正常与ejb 唯一的问题是gmap模型

我想知道它是否是错误的表面

1 个答案:

答案 0 :(得分:0)

找到解决方案,但我仍然无法理解为什么?

我将代码更改为

@ManagedBean
public class MarkersView implements Serializable {

/**
 * 
 */
private static final long serialVersionUID = 1L;
private MapModel simpleModel;


public MarkersView() {
    simpleModel = new DefaultMapModel();

    //Shared coordinates
    LatLng coord1 = new LatLng(36.879466, 30.667648);
    LatLng coord2 = new LatLng(36.883707, 30.689216);
    LatLng coord3 = new LatLng(36.879703, 30.706707);
    LatLng coord4 = new LatLng(36.885233, 30.702323);

    //Basic marker
    simpleModel.addOverlay(new Marker(coord1, "Konyaalti", "http://maps.google.com/mapfiles/ms/micons/blue-dot.png"));
    simpleModel.addOverlay(new Marker(coord2, "Ataturk Parki", "http://maps.google.com/mapfiles/ms/micons/yellow-dot.png"));
    simpleModel.addOverlay(new Marker(coord3, "Karaalioglu Parki", "http://maps.google.com/mapfiles/ms/micons/blue-dot.png"));
    simpleModel.addOverlay(new Marker(coord4, "Kaleici", "http://maps.google.com/mapfiles/ms/micons/blue-dot.png"));
}



public MapModel getSimpleModel() {
    return simpleModel;
}
}

它的工作精细显示标记,但没有从URL更改标记外观 任何人都明白为什么这个代码工作,第一个没有?