Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion web/mapComparison-body.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
//AntwebUtil.log("mapComparison-body.jsp taxon:" + thisChild);

innerloop = 0;
while (innerloop < 3) {
while (innerloop < 1) {

//AntwebUtil.log("mapComparison-body.jsp taxon:" + thisChild + " innerloop:" + innerloop);

Expand Down
213 changes: 71 additions & 142 deletions web/maps/googleMapInclude.jsp
Original file line number Diff line number Diff line change
@@ -1,162 +1,91 @@

<!-- googleMapInclude.jsp -->


<%@ page import="org.calacademy.antweb.Map" %>
<%@ page import="org.calacademy.antweb.util.UserAgentTracker" %>

<%
boolean displayMap = true;

if (HttpUtil.isBot(request)) {
out.println("<a href='" + AntwebProps.getDomainApp() + "/login.do'>Log In</a> to see maps.");
displayMap = false;
} %>

<%
/*
Here we generate the actual map.

Includes /maps/googleMapPreInclude.jsp and /maps/googleMapInclude.jsp
dynamicMap-body.jsp
specimen-body.jsp
group-body.jsp:
collection-body.jsp:
taxonPage-body.jsp:
locality-body.jsp:
search/fieldGuide-body.jsp:
mapComparison-body.jsp
overview-body.jsp

googleMapPreInclude.jsp
script /maps/drawGoogleMap.js

googleMapInclude.jsp
calls.push("< %= googleMapFunction % >");

// V2?
includeMap.jsp
Not used? Yes it is. In the edit geolocale curator page and for localityOverviews that don't have a map but do have a centroid.
Probably cases that should be eliminated.
include /maps/googleMap.jsp

googleMap.jsp
google.maps.event.addDomListener(window, 'load', makeMap)

map.jsp
not used? Testing. http://localhost/antweb/maps/map.jsp
google.maps.event.addDomListener(window, 'load', initialize);

map.jsp, googleMap.jsp and includeMap.jsp to be removed once the above is resolved (see incudeMap.jsp).
*/
out.println("<a href='" + AntwebProps.getDomainApp() + "/login.do'>Log In</a> to see maps.");
displayMap = false;
}
%>


<%
//A.log("googleMapInclude.jsp map:" + map + " displayMap:" + displayMap);

// We assume that map, object{"specimen", "taxon", "locality", "collection"}, mapType, and objectName are already set
if (map != null && displayMap) {

String googleMapFunction = map.getGoogleMapFunction();

if ((googleMapFunction != null) && (googleMapFunction.length() > 0)) {

//A.log("googleMapInclude.jsp object:" + object + " objectName:" + objectName + " mapType:" + mapType);
//AntwebUtil.logStackTrace();
Map.addToDisplayMapCount();
Map.addToDisplayMapCount(mapType);

//String divName = map.getMapName();
int n = googleMapFunction.indexOf("', '") + 4;
int o = googleMapFunction.indexOf("'", n);
String divName = googleMapFunction.substring(n, o);
String mapSize = "small";
if (object.equals("dynamic")) {
mapSize = "large";
googleMapFunction = googleMapFunction.replaceFirst("small","big");
}

if ("large".equals(mapSize)) {
if (map.getSubtitle() != null) out.println("<h3>" + map.getSubtitle() + "</h3>");
}

//A.log("googleMapInclude.jsp divName:" + divName + " googleMapFunction:" + googleMapFunction + " object:" + object);
// String heightAndWidth = (!object.equals("dynamic")) ? "height:232px;width:232px;" : "height:400px;width:926px;";
String heightAndWidth = new String();
if (object.equals("dynamic")) {
heightAndWidth = "height:650px;width:974px;";
} else if (object.equals("thirds")) { // fieldGuide and mapComparison?
heightAndWidth = "height:262px;width:262px;";
} else {
heightAndWidth = "height:232px;width:232px;";
}
if (map != null && displayMap) {
String googleMapFunction = map.getGoogleMapFunction();

if (googleMapFunction != null && googleMapFunction.length() > 0) {
Map.addToDisplayMapCount();
Map.addToDisplayMapCount(mapType);

int n = googleMapFunction.indexOf("', '") + 4;
int o = googleMapFunction.indexOf("'", n);
String divName = googleMapFunction.substring(n, o);

String mapSize = "small";
if ("dynamic".equals(object)) {
mapSize = "large";
googleMapFunction = googleMapFunction.replaceFirst("small", "big");
}

if ("large".equals(mapSize) && map.getSubtitle() != null)
out.println("<h3>" + map.getSubtitle() + "</h3>");

String heightAndWidth;
if ("dynamic".equals(object)) {
heightAndWidth = "height:650px;width:974px;";
} else if ("thirds".equals(object)) {
heightAndWidth = "height:262px;width:262px;";
} else {
heightAndWidth = "height:232px;width:232px;";
}
%>

<div id="<%= divName %>" style="<%= heightAndWidth %>border:1px solid #b9b9b9; overflow:hidden"></div>

<%
// We now prevent this on the server by disallowing more than 1000 points.
//if (googleMapFunction.length() > 70000) {
// AntwebUtil.log("info", "taxonPage-body.jsp: googleMapFunction length is " + googleMapFunction.length() + " for " + HttpUtil.getRequestInfo(request));
//}

if ((!object.equals("thirds")) && (!object.equals("dynamic"))) {
String overviewParam = "";


//A.log("googleMapInclude.jsp overview:" + overview);
// This was thought to be unnecessary. It is here: http://localhost/antweb/description.do?genus=tetramorium&species=simillimum&rank=species&countryName=Brazil
if (overview != null) {
overviewParam = overview.getParams(); //"&" +
}

//A.log("googleMapInclude.jsp object:" + object + " objectName:" + objectName + " overviewParam:" + overviewParam);
String objectParam = "";
//when is this necessary?
if ("taxonName".equals(object)) {
objectParam = object + "=" + objectName + "&";
}
if ("specimen".equals(object)) {
objectParam = object + "=" + objectName + "&";
}
if ("locality".equals(object)) {
objectParam = object + "=" + objectName + "&";
overviewParam = "";
}
if ("collection".equals(object)) {
objectParam = object + "=" + objectName + "&";
overviewParam = "";
}

%>
<div style="text-align:center"><a href="<%= AntwebProps.getDomainApp() %>/bigMap.do?<%= objectParam %><%= overviewParam %>">Enlarge Map</a></div>
<%
} // We have a googleMapFunction
<!-- Leaflet map container -->
<div id="<%= divName %>"
style="<%= heightAndWidth %>border:1px solid #b9b9b9; overflow:hidden;">
</div>

<% if (!"thirds".equals(object) && !"dynamic".equals(object)) {
String overviewParam = "";
if (overview != null) overviewParam = overview.getParams();

String objectParam = "";
if ("taxonName".equals(object) || "specimen".equals(object)) {
objectParam = object + "=" + objectName + "&";
} else if ("locality".equals(object) || "collection".equals(object)) {
objectParam = object + "=" + objectName + "&";
overviewParam = "";
}
%>

<!-- googleMapFunction -->
<div style="text-align:center; margin-top:4px;">
<a href="<%= AntwebProps.getDomainApp() %>/bigMap.do?<%= objectParam %><%= overviewParam %>">
Enlarge Map
</a>
</div>
<% } %>

<!-- Run Leaflet-compatible map after short delay -->
<script type="text/javascript">
calls.push("<%= googleMapFunction %>");
document.addEventListener("DOMContentLoaded", function() {
setTimeout(function() {
try {
<%= googleMapFunction %>;
} catch (err) {
console.error("Map init failed:", err);
}
}, 400);
});
</script>
<!-- end googleMapFunction -->

<%
//A.log("googleMapInclude.jsp googleMapFunction:" + googleMapFunction);
if ("large".equals(mapSize)) {
if ((AntwebProps.isDevMode() || LoginMgr.isAdmin(request)) && map.getInfo() != null) out.println("Map Info: " + map.getInfo());
}
%>

<%
} else {
if (AntwebProps.isDevMode()) {
String aMessage = "No googleMapFunction";
A.log("googleMapInclude.jsp " + aMessage);
out.println(aMessage);
}
} else {
if (AntwebProps.isDevMode()) {
String msg = "No map data found for " + object + " (" + objectName + ")";
out.println("<div style='color:red'>" + msg + "</div>");
}
}
}
} // map != null
%>

<!-- end googleMapInclude.jsp -->
<!-- end googleMapInclude.jsp -->
18 changes: 8 additions & 10 deletions web/maps/googleMapPreInclude.jsp
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
<%-- /web/maps/googleMapPreInclude.jsp (Leaflet) --%>
<%
// Point this to YOUR existing microservice
final String MAPS_BASE = "http://localhost:8081";
%>
<%-- /web/maps/googleMapPreInclude.jsp (Local Leaflet Integration) --%>
<% if (!HttpUtil.isBot(request)) { %>
<!-- Leaflet + MarkerCluster from CDN -->

<!-- Leaflet core and plugins -->
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"/>
<link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster@1.5.3/dist/MarkerCluster.css"/>
<link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster@1.5.3/dist/MarkerCluster.Default.css"/>
<link rel="stylesheet" href="https://unpkg.com/leaflet.fullscreen@1.6.0/Control.FullScreen.css"/>

<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<script src="https://unpkg.com/leaflet.markercluster@1.5.3/dist/leaflet.markercluster.js"></script>
<script src="https://unpkg.com/leaflet.fullscreen@1.6.0/Control.FullScreen.js"></script>

<!-- Your microservice SDK -->
<script src="/maps/sdk/drawMap.js"></script>
<!-- Local SDK and adapter -->
<script src="/maps/sdk/drawMap.js" type="text/javascript"></script>
<script src="/maps/drawGoogleMap.js" type="text/javascript"></script>

<!-- AntWeb adapter that keeps drawGoogleMap* function names -->
<script src="<%= AntwebProps.getDomainApp() %>/maps/drawGoogleMap.js" type="text/javascript"></script>
<% } %>
Loading