...

View Full Version : Javascript Geolocation - Help Needed



Phillymajigay
12-02-2012, 01:51 PM
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

xelawho
12-02-2012, 09:02 PM
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?

donna1
12-02-2012, 10:04 PM
small demo


<!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>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum