Пример #1
0
  /**
   * helper method
   *
   * @param marker
   */
  public void clickAndOpenPopup(Marker marker, AjaxRequestTarget target) {
    String mapId = getOpenLayerMap().getJSInstance();
    String jsToRun =
        "if ("
            + mapId
            + ".popup != null) {"
            + "		"
            + mapId
            + ".map.removePopup("
            + mapId
            + ".popup);"
            + "		"
            + mapId
            + ".popup.destroy();"
            + "		"
            + mapId
            + ".popup = null;"
            + "}";

    target.prependJavaScript(jsToRun);

    // Currently only support clicking on markers!
    getOpenLayerMap().getInfoWindow().getContent().replaceWith(marker.getPopup());
    getOpenLayerMap().getInfoWindow().setContent(marker.getPopup());
    target.add(marker.getPopup());
    jsToRun =
        mapId
            + ".popup = new OpenLayers.Popup('map', "
            + new LonLat(marker.getLonLat().getLng(), marker.getLonLat().getLat())
            + ", "
            + new Size(195, 250).getJSconstructor()
            + ", document.getElementById("
            + mapId
            + ".popupId).innerHTML, true);"
            + mapId
            + ".popup.setBackgroundColor('white');"
            + mapId
            + ".map.addPopup("
            + mapId
            + ".popup);";

    // open info window
    target.appendJavaScript(jsToRun);
  }
Пример #2
0
 public String getCallBackForMarker(Marker marker) {
   return getCallbackUrl() + "&marker=" + marker.getId();
 }