2017-05-04 60 views
1

我有一个Vaadin应用程序,我想集成Google热图。我正在使用com.vaadin.tapio.googlemaps依赖项来显示地图,它工作正常。但是,我不确定如何在Google地图顶部添加热图层,并且找不到任何相关资源。我的审判代码Vaadin如何添加Google热图

有关部分看起来是这样的:

VerticalLayout rootLayout = new VerticalLayout(); 
    rootLayout.setSizeFull(); 

    // Google Map 
    GoogleMap googleMap = new GoogleMap("api_key", null, null); 
    googleMap.setZoom(10); 
    googleMap.setSizeFull(); 
    googleMap.setMinZoom(4); 
    googleMap.setMaxZoom(16); 

    Panel mapsPanel = new Panel(); 
    mapsPanel.setSizeFull(); 
    mapsPanel.setContent(googleMap); 
    rootLayout.addComponent(mapsPanel); 

    double centerLon = 8.5417; 
    double centerLat = 47.3769; 
    googleMap.setCenter(new LatLon(centerLat, centerLon)); 
    GoogleMapMarker centerMarker = new GoogleMapMarker("Zurich", new LatLon(centerLat, centerLon),true, null); 
    googleMap.addMarker(centerMarker); 


    HeatMapLayer heatMapLayer = HeatMapLayer.newInstance(HeatMapLayerOptions.newInstance()); 
    // Add data to heatmap 
    ... 
    // How can I add this HeatMapLayer to the existing map? 
    // Or do I need a different approach? 

    UI.getCurrent().setContent(rootLayout); 

回答

1

HeatMapLayer是GWT(客户端)的对象,不能直接与GoogleMap这是一个服务器端组件使用它。你可以检查this forkcom.vaadin.tapio.googlemaps,它增加了对HeatMapLayerGoogleMapHeatMapLayer类的支持。

+0

我尝试了叉;然而,他们的热图对我没有任何帮助。我尝试了他们的演示,并将'GoogleMapHeatMapLayer'集成到了我的应用中,但都没有成功。尽管如此,谢谢你的信息。 – Egemen