Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    What is this code about?

    Hi,

    I'm working with a developer and I am not sure if he is being legit. Now, this code below is suppose to be about adding social media buttons to the bubble that is clicked on a google maps pins. Is this what this code is trying to do? He's been trying to upload it to his and our server unsuccessfully.

    Is this code about social media buttons its sharing functions?

    <script type="text/javascript">
    //<![CDATA[
    if (GBrowserIsCompatible()) {

    // === Global variable that can be used by the context handling functions ==
    var clickedPixel;
    // ===Global variable for passing the clicked overlay reference via HTML ==
    var clickedOverlay;

    var map = new GMap2(document.getElementById("map"));
    map.addControl(new GLargeMapControl());
    map.addControl(new GMapTypeControl());
    map.setCenter(new GLatLng(43.25,-79.25),8);
    // === create the context menu div ===
    var contextmenu = document.createElement("div");
    contextmenu.style.visibility="hidden";
    contextmenu.style.background="#ffffff";
    contextmenu.style.border="1px solid #8888FF";
    map.getContainer().appendChild(contextmenu);


    // ===context menu HTML for varioys situations ===

    mapContextHtml = '<a href="javascript:zoomIn()"><div class="context">&nbsp;&nbsp;Zoom in&nbsp;&nbsp;<\/div><\/a>'
    + '<a href="javascript:zoomOut()"><div class="context">&nbsp;&nbsp;Zoom out&nbsp;&nbsp;<\/div><\/a>'
    + '<a href="javascript:zoomInHere()"><div class="context">&nbsp;&nbsp;Zoom in here&nbsp;&nbsp;<\/div><\/a>'
    + '<a href="javascript:zoomOutHere()"><div class="context">&nbsp;&nbsp;Zoom out here&nbsp;&nbsp;<\/div><\/a>'
    + '<a href="javascript:centreMapHere()"><div class="context">&nbsp;&nbsp;Centre map here&nbsp;&nbsp;<\/div><\/a>';

    markerContextHtml = '<a href="javascript:deleteoverlay()"><div class="context">&nbsp;&nbsp;Delete Marker&nbsp;&nbsp;<\/div><\/a>';

    polylineContextHtml = '<a href="javascript:redline()"><div class="context">&nbsp;&nbsp;Red&nbsp;&nbsp;<\/div><\/a>'
    + '<a href="javascript:greenline()"><div class="context">&nbsp;&nbsp;Green&nbsp;&nbsp;<\/div><\/a>'
    + '<a href="javascript:blueline()"><div class="context">&nbsp;&nbsp;Blue&nbsp;&nbsp;<\/div><\/a>'
    + '<a href="javascript:deleteoverlay()"><div class="context">&nbsp;&nbsp;Delete Line&nbsp;&nbsp;<\/div><\/a>';



    // === listen for singlerightclick ===
    GEvent.addListener(map,"singlerightclick",function(pixel,tile,overlay) {
    // store the "pixel" info in case we need it later
    // adjust the context menu location if near an egde
    // create a GControlPosition
    clickedPixel = pixel;
    var x=pixel.x;
    var y=pixel.y;
    if (x > map.getSize().width - 120) { x = map.getSize().width - 120 }
    if (y > map.getSize().height - 100) { y = map.getSize().height - 100 }
    var pos = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(x,y));
    // == was the click on the map? ==
    if (!overlay) {
    // insert the map HTMP, apply the position to the context menu, and make it visible
    contextmenu.innerHTML = mapContextHtml;
    pos.apply(contextmenu);
    contextmenu.style.visibility = "visible";
    } else {
    // == was the click on a GMarker? ==
    if (overlay instanceof GMarker) {
    // insert the marker HTML, apply the position to the ovelay context menu, and make it visible
    contextmenu.innerHTML = markerContextHtml;
    pos.apply(contextmenu);
    contextmenu.style.visibility = "visible";
    clickedOverlay = overlay;
    }
    // == was the click on a GPolyline? ==
    if (overlay instanceof GPolyline) {
    // insert the polyline HTML, apply the position to the ovelay context menu, and make it visible
    contextmenu.innerHTML = polylineContextHtml;
    pos.apply(contextmenu);
    contextmenu.style.visibility = "visible";
    clickedOverlay = overlay;
    }
    }
    });




    // === functions that implement the context menu options ===
    function zoomIn() {
    // perform the requested operation
    map.zoomIn();
    // hide the context menu now that it has been used
    contextmenu.style.visibility="hidden";
    }
    function zoomOut() {
    // perform the requested operation
    map.zoomOut();
    // hide the context menu now that it has been used
    contextmenu.style.visibility="hidden";
    }
    function zoomInHere() {
    // perform the requested operation
    var point = map.fromContainerPixelToLatLng(clickedPixel)
    map.zoomIn(point,true);
    // hide the context menu now that it has been used
    contextmenu.style.visibility="hidden";
    }
    function zoomOutHere() {
    // perform the requested operation
    var point = map.fromContainerPixelToLatLng(clickedPixel)
    map.setCenter(point,map.getZoom()-1); // There is no map.zoomOut() equivalent
    // hide the context menu now that it has been used
    contextmenu.style.visibility="hidden";
    }
    function centreMapHere() {
    // perform the requested operation
    var point = map.fromContainerPixelToLatLng(clickedPixel)
    map.setCenter(point);
    // hide the context menu now that it has been used
    contextmenu.style.visibility="hidden";
    }
    function deleteoverlay() {
    map.removeOverlay(clickedOverlay);
    // hide the context menu now that it has been used
    contextmenu.style.visibility="hidden";
    }
    function redline() {
    clickedOverlay.setStrokeStyle({color:"#FF0000"});
    // hide the context menu now that it has been used
    contextmenu.style.visibility="hidden";
    }
    function greenline() {
    clickedOverlay.setStrokeStyle({color:"#00FF00"});
    // hide the context menu now that it has been used
    contextmenu.style.visibility="hidden";
    }
    function blueline() {
    clickedOverlay.setStrokeStyle({color:"#0000FF"});
    // hide the context menu now that it has been used
    contextmenu.style.visibility="hidden";
    }



    // === If the user clicks on aything, close the context menus ===
    GEvent.addListener(map, "click", function() {
    contextmenu.style.visibility="hidden";
    });



    // === Create some markers ===
    function createMarker(point,html) {
    var marker = new GMarker(point);
    GEvent.addListener(marker, "click", function() {
    marker.openInfoWindowHtml(html);
    });
    return marker;
    }

    map.addOverlay(createMarker(new GLatLng(43,-79),"Marker One"));
    map.addOverlay(createMarker(new GLatLng(43.5,-79),"Marker Two"));
    map.addOverlay(createMarker(new GLatLng(43,-79.5),"Marker Three"));
    map.addOverlay(createMarker(new GLatLng(43.5,-79.5),"Marker Four"));


    // === Create some polylines ==
    map.addOverlay(new GPolyline([new GLatLng(43,-79),new GLatLng(43.5,-79.5)]));
    map.addOverlay(new GPolyline([new GLatLng(43.5,-79),new GLatLng(43,-79.5)]));
    }
    // display a warning if the browser was not compatible
    else {
    alert("Sorry, the Google Maps API is not compatible with this browser");
    }

    // This Javascript is based on code provided by the
    // Community Church Javascript Team
    // http://www.bisphamchurch.org.uk/
    // http://econym.org.uk/gmap/

    //]]>
    </script>

  • #2
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,758
    Thanks
    41
    Thanked 191 Times in 190 Posts
    it seems as though it is working with google maps. Why is there so much mistrust? If the relationship is that bad it is probably best to part ways. But keep in mind, sometimes the problem is soooooooooo simple- but it is not always soooooooo simple to find it. I would trust that the developers is doing what he says he's doing.

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •