Post by meerkat on Sept 8, 2015 4:19:06 GMT -5
Display user location and map.
Some browsers have location turned off. If you do not have GPS it uses the location of the router.
Sample code:
Some browsers have location turned off. If you do not have GPS it uses the location of the router.
Sample code:
' ----------------------------
' find user location with map
' ----------------------------
head "<script>
function getGeoLoc() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
document.getElementById('err').innerHTML = 'Geolocation is not supported by this browser.';
}
}
function showPosition(position) {
document.getElementById('lat').value = position.coords.latitude;
document.getElementById('lon').value = position.coords.longitude;
document.getElementById('getLoaLonClick').click();
}
</script>"
CSSClass ".hide", "{visibility: hidden; height:0px; bprder:none}"
' ---------------------------------------------
' hidden button and input
' to communicate with RB program
' ---------------------------------------------
button #getLoaLon,"",[getLoaLonGo]
#getLoaLon setid("getLoaLonClick")
#getLoaLon cssclass("hide")
html "<input type='hidden' name='lat' id='lat' value='' size=30/><BR>" ' hidden latitude holder
html "<input type='hidden' name='lon' id='lon' value='' size=30/><br>" ' hidden longitude holder
' ---------------------
html "<button onclick='getGeoLoc()'>Show Location</button>"
wait
[getLoaLonGo]
lat$ = #request get$("lat") ' get your gps latitude
lon$ = #request get$("lon") ' get your gps longitude
print lat$;" ";lon$
' ------------------------
' show map location
' with size 600 x 450
' size resolution 1024x768
' ------------------------
w = 600
h = 450
html "<iframe src='https://www.google.com/maps/embed?pb=!1m10!1m8!1m3!1d4000!2d";lon$;"!3d";lat$;"!3m2!1i1024!2i768!4f13.1!5e0!3m2!1sen!2sus!4v1441620668047' width=";w;" height=";h;" frameborder=0 style='border:0' allowfullscreen></iframe>"
wait