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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript Geolocation - Help Needed

    Hi all,

    Was hoping someone could help me. I'm creating a map using the Google map api with drop down boxes to various locations. I have the longitude and latitude of said locations & created an array. The problem i'm having is how to 'wire up' the locations to the drop down box and for them then to present themselves within the map canvas.

    Any help would be appreciated

    Kind Regards,

    Pippa

  • #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,981
    Thanks
    56
    Thanked 557 Times in 554 Posts
    It sounds simple enough EXCEPT for the fact that I have no idea what you are trying to do, or what "wiring up" may entail. Can you explain what you want to happen when the user selects an option? And show us what your array looks like?

  • #3
    New Coder donna1's Avatar
    Join Date
    Nov 2012
    Location
    london
    Posts
    99
    Thanks
    9
    Thanked 4 Times in 4 Posts
    small demo
    Code:
    <!DOCTYPE HTML>
    <html>
    <body>
    <canvas id="myCanvas" width="800" height="600">>Your browser does not support the canvas tag.</canvas>
    <script>
    var canvas = document.getElementById('myCanvas');
    var ctx = canvas.getContext('2d');
    
    var stores = ["Handbags","Hairdressers","Clothes","McDonalds"];
    var storex = [50,200,510,300];
    var storey = [400,100,50,200];
    var i=0;
    
    function displayStore(){
     canvas.width=canvas.width;
     ctx.beginPath();
     ctx.rect(storex[i],storey[i],75,25);
     ctx.closePath();
     ctx.stroke();
     ctx.fillText(stores[i],storex[i]+5,storey[i]+15);
    }
    
    function rotateStores(){
     displayStore();
     i++;
     if(i==stores.length){ i=0;}
    }
    
    setInterval("rotateStores()",1000);
    
    </script>
    </body>
    </html>
    Last edited by donna1; 12-02-2012 at 10:32 PM.


  •  

    Posting Permissions

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