Edit C:\Users\Administrator\Desktop\Back\galaxie - Copy\marketing\populationv2\map.jsp
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <% /****************************************************************************** * Copyright (c) 2000-2004 e-Deal * * e-Deal S.A. * 55 rue Brillat Savarin * 75013 Paris * France * * T: +33 (0)1 53 80 80 30 * F: +33 (0)1 73 01 69 77 * http://www.e-deal.com * * La diffusion de ce code source sous quelque forme que ce soit sans * l'autorisation de E-DEAL est interdite. * * Vous êtes autorisés à modifier ce code source uniquement pour votre usage * propre et sous réserve que les mentions de copyright demeurent intactes. * * Ce code est fourni en l'état. Aucune garantie d'aucune sorte, explicite ou * implicite n'est donnée. En aucun cas E-DEAL ne pourra être tenu pour * responsable des dommages pouvant résulter de l'utilisation de ce code * source. * * ******************************************************************************/ %><%@page session="true" import="com.edeal.frontline.*,com.edeal.frontline.navigation.*,java.net.*,java.io.*, java.util.*"%> <%@taglib uri="http://www.e-deal.com/taglib/fl" prefix="fl" %> <% final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory.getLog(getClass()); FlRequest flRequest = new FlRequest(request); FlContext context = flRequest.getContext(); String key=(String) context.getContextParameter("GoogleMapKey"); String entsLocalized = (String)flRequest.getAttribute("entsLocalized"); String entsToLocalize = (String)flRequest.getAttribute("entsToLocalize"); %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <title>Map</title> <script src="http://maps.google.com/maps?file=api&v=2.x&key=<%=key%>" type="text/javascript"></script> <script type="text/javascript" src="<fl:webapp/>/js/master_js.jsp"></script> <script type="text/javascript" src="<fl:webapp/>/js/edeal/libraries/jquery/jquery.js"></script> <script type="text/javascript" src="<fl:webapp/>/js/progressbar/jquery.progressbar.min.js"></script> <script type="text/javascript"> //<![CDATA[ // delay between geocode requests - at the time of writing, 100 miliseconds seems to work well var delay = 100; // ======= A JSON of locations that we want to Geocode ======== var addresses = <%=entsToLocalize%>; var localizedAddresses = <%=entsLocalized %>; // ======= Global variable to remind us what to do next var nextAddress = 0; //User notification of the status var progress = 0; var status = "UNKNOWN"; var message = ""; var nbAddressToLocalize = addresses.Enterprise.length; var nbAddressInitiallyLocalized = localizedAddresses.markers.length; var nbAddressFreshlyLocalized = 0; if (GBrowserIsCompatible()) { // ====== Create a Client Geocoder ====== var geo = new GClientGeocoder(); // ====== Array for decoding the failure codes ====== var reasons=[]; reasons[G_GEO_SUCCESS] = "Success"; reasons[G_GEO_MISSING_ADDRESS] = "Missing Address: The address was either missing or had no value."; reasons[G_GEO_UNKNOWN_ADDRESS] = "Unknown Address: No corresponding geographic location could be found for the specified address."; reasons[G_GEO_UNAVAILABLE_ADDRESS]= "Unavailable Address: The geocode for the given address cannot be returned due to legal or contractual reasons."; reasons[G_GEO_BAD_KEY] = "Bad Key: The API key is either invalid or does not match the domain for which it was given"; reasons[G_GEO_TOO_MANY_QUERIES] = "Too Many Queries: The daily geocoding quota for this site has been exceeded."; reasons[G_GEO_SERVER_ERROR] = "Server error: The geocoding request could not be successfully processed."; reasons[403] = "Error 403: Probably an incorrect error caused by a bug in the handling of invalid JSON."; // ====== Geocoding ====== function getAddress(enterprise, next) { geo.getLocations(enterprise.EntAddress, function (result) { // If that was successful if (result.Status.code == G_GEO_SUCCESS) { // Lets assume that the first marker is the one we want var p = result.Placemark[0].Point.coordinates; var lat=p[1]; var lng=p[0]; localizedAddresses.markers.push({lng: lng, lat: lat, label: enterprise.label, html: enterprise.html}); doAjax("<fl:webapp/>/update_enterprise_geocode.fl?id="+enterprise.EntID+"&EntLa="+parseFloat(lat)+"&EntLo="+parseFloat(lng)+"&status=G_GEO_SUCCESS"); nbAddressFreshlyLocalized++; } // ====== Decode the error status ====== else { // === if we were sending the requests to fast, try this one again and increase the delay if (result.Status.code == G_GEO_TOO_MANY_QUERIES){ if(delay < 5000) { nextAddress--; delay++; }else{ status = "KO"; message = reasons[G_GEO_TOO_MANY_QUERIES]; doAjax("<fl:webapp/>/update_enterprise_geocode.fl?id="+enterprise.EntID+"&status=G_GEO_TOO_MANY_QUERIES"); load_map(); plotMarkers(); } } else { var reason="Code "+result.Status.code; if (reasons[result.Status.code]) { reason = reasons[result.Status.code]; doAjax("<fl:webapp/>/update_enterprise_geocode.fl?id="+enterprise.EntID+"&status="+result.Status.code); } } } next(); } ); } // ======= Function to call the next Geocode operation when the reply comes back function theNext() { progress = (nextAddress/addresses.Enterprise.length)*100; if (nextAddress < addresses.Enterprise.length) { enterprise = addresses.Enterprise[nextAddress]; setTimeout('getAddress(enterprise,theNext)', delay); nextAddress++; } else { status = "OK"; load_map(); plotMarkers(); } } var map = null; var geocoder = null; var side_bar_html = ""; var gmarkers = []; var htmls = []; var i = 0; var bounds = new GLatLngBounds(); function load_map() { map = new GMap2(document.getElementById("map")); map.addControl(new GSmallMapControl()); map.addControl(new GMapTypeControl()); map.setCenter(new GLatLng(0,0),0); map.enableScrollWheelZoom(); } function createMarker(point,name,html) { var marker = new GMarker(point); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); // save the info we need to use later for the side_bar gmarkers[i] = marker; htmls[i] = html; // add a line to the side_bar html side_bar_html += '<a href="javascript:myclick(' + i + ')">�' + name + '<\/a><br>'; i++; return marker; } // This function picks up the click and opens the corresponding info window function myclick(i) { gmarkers[i].openInfoWindowHtml(htmls[i]); } // === Plot the markers === function plotMarkers(){ for (var index=0; index<localizedAddresses.markers.length; index++) { var point = new GLatLng(localizedAddresses.markers[index].lat, localizedAddresses.markers[index].lng); var marker = createMarker(point, localizedAddresses.markers[i].label, localizedAddresses.markers[i].html); map.addOverlay(marker); bounds.extend(point); } map.setZoom(map.getBoundsZoomLevel(bounds)); map.setCenter(bounds.getCenter()); // put the assembled side_bar_html contents into the side_bar div document.getElementById("side_bar").innerHTML = side_bar_html; } // This function picks up the click and opens the corresponding info window function myclick(i) { gmarkers[i].openInfoWindowHtml(htmls[i]); } //setTimeout("getStatus();", 1000); function getStatus(){ $('#detail').html(" A géolocaliser: "+nbAddressToLocalize+", Nouvellement géolocalisées: "+nbAddressFreshlyLocalized + ", délai entre 2 appels: "+delay/1000+"s"); if(status == 'UNKNOWN'){ $('#pbar').progressBar(progress); $('#detail').append(' ...'); setTimeout("getStatus();",1000);return false; }else if(status == 'KO'){ //$("#message").html(""); $('#pbar').hide(); $('#pbarcontainer').html(' <img src=<fl:webapp/>/js/progressbar/images/failure.png alt="'+message+'" title="'+message+'" />'); //$('#detail').html(data.Message); }else if(status == 'OK'){ //$("#message").html(""); $('#pbar').hide(); //$('#pbarcontainer').append(' <img src=<fl:webapp/>/js/progressbar/images/success.png />'); } } // ======= Call that function for the first time ======= $(document).ready(function(){ $("#pbar").progressBar(progress, { showText: true, barImage: '<fl:webapp/>/js/progressbar/images/progressbg_blue.gif'} ); theNext(); getStatus(); }); } // display a warning if the browser was not compatible else { alert("Sorry, the Google Maps API is not compatible with this browser"); } //]]> </script> <link rel="stylesheet" type="text/css" href="<fl:webapp/>/css/common_css.jsp"> <link rel="stylesheet" type="text/css" href="<fl:webapp/>/css/master_css.jsp"> </head> <body onunload="GUnload()"> <%--<div id="message"> <%=entsLocalized %> </div--%> <div id="container"> <table> <tr><td valign="top"><span class="progressBar" style="vertical-align: bottom;" id="pbar"/></span><span id="pbarcontainer"></span><span id="detail"></span></td></tr> </table> </div> <table width="100%" height="700px"> <tr> <td width="80%" valign="top"><div id="map" style="width: 810px; height: 745px"></div></td> <td valign="top"><div id="side_bar" style="overflow:scroll;height:745px"></div></td> </tr> </table> </body> </html>
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de