JavaScript - Is There Any Geolocation Service That Does Not Require An Api-key?
Hey all,
I'm playing with a greasemonkey script and would like to provide geo-locating. The geolocation services I've found all require dev/api-key. A dev-key means I reveal my well-earned key, or an api-key usually means a server address... there would be none via a greasemonkey script. Any ideas for gathering geolocation services? Any links, tips, ideas welcome! Similar TutorialsHi, I am creating a mobile web application for a zoo which involves a map and user being able to find your location within the zoo. I have a working prototype which works my finding your Longitude and Latitude and based on where your standing the map will move to your location. Here is the code: Code: function getLocation() { // Get location no more than 10 minutes old. 600000 ms = 10 minutes. navigator.geolocation.getCurrentPosition(showLocation, showError, {enableHighAccuracy:true,maximumAge:600000}); if (position.coords.latitude == 37.331689 && position.coords.longitude == -122.030731) camera.className = 'part-penguin', document.getElementById("penguinholder") .src="graphics/penguin-here.png", document.getElementById("link") .href="penguins.html", alert('You are standing nearby the penguins!'); } else alert('You appear to be out of the Zoo grounds! Please return to the area and try again.'); } Currently the user has to be standing at a specific point in order for it to work as it only takes 1 Latitude coordinate and 1 Longitudinal reference point. What I would like it to do would be to check between 2 Latitude points and 2 longitude points (i.e. a square area) and as long as the user is standing between these points it will do what i want. Please help.. Thanks.. Hi. i,m trying to make a map who show me as position A and a target adress as point B.I have made it so i can choose adress a and adress b from a dropdown but i want to automaticly load my position as possition A then choose position B from a dropdownlist. How can i do this ? Thanks Natrox <!DOCTYPE html> <html> <head> <title>Google Maps JavaScript API v3 Example: Map Geolocation</title> <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> <meta charset="UTF-8"> <link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" /> <!-- Include the maps javascript with sensor=true because this code is using a sensor (a GPS locator) to determine the user's location. See: http://code.google.com/apis/maps/doc...ecifyingSensor --> <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=true&language=nb_NO"></script> <!--<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=true&language=nb_NO"> --> <script type="text/javascript"> var map; var directionDisplay; var directionsService; var stepDisplay; var markerArray = []; var initialLocation; //var oslo = new google.maps.LatLng(59.947639, 10.884469); var browserSupportFlag = new Boolean(); function initialize() { directionsService = new google.maps.DirectionsService(); // Create a map and center it on Manhattan. var oslo = new google.maps.LatLng(59.947639, 10.884469); var myOptions = { zoom: 13, mapTypeId: google.maps.MapTypeId.ROADMAP, center: oslo } map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); // Create a renderer for directions and bind it to the map. var rendererOptions = { map: map } directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions) // Instantiate an info window to hold step text. stepDisplay = new google.maps.InfoWindow(); } function calcRoute() { // First, remove any existing markers from the map. for (i = 0; i < markerArray.length; i++) { markerArray[i].setMap(null); } // Now, clear the array itself. markerArray = []; // Retrieve the start and end locations and create // a DirectionsRequest using DRIVING directions. var start = document.getElementById("sart").value; var end = document.getElementById("end").value; var request = { origin: start, destination: end, travelMode: google.maps.DirectionsTravelMode.DRIVING }; // Route the directions and pass the response to a // function to create markers for each step. directionsService.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { var warnings = document.getElementById("warnings_panel"); warnings.innerHTML = "<b>" + response.routes[0].warnings + "</b>"; directionsDisplay.setDirections(response); showSteps(response); } }); } function showSteps(directionResult) { // For each step, place a marker, and add the text to the marker's // info window. Also attach the marker to an array so we // can keep track of it and remove it when calculating new // routes. var myRoute = directionResult.routes[0].legs[0]; for (var i = 0; i < myRoute.steps.length; i++) { var marker = new google.maps.Marker({ position: myRoute.steps[i].start_point, map: map }); attachInstructionText(marker, myRoute.steps[i].instructions); markerArray[i] = marker; } } function attachInstructionText(marker, text) { google.maps.event.addListener(marker, 'click', function() { // Open an info window when the marker is clicked on, // containing the text of the step. stepDisplay.setContent(text); stepDisplay.open(map, marker); }); } // Try HTML5 geolocation if(navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { var pos = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); var infowindow = new google.maps.InfoWindow({ map: map, position: pos, content: 'Du er her.' }); map.setCenter(pos); }, function() { handleNoGeolocation(true); }); } else { // Browser doesn't support Geolocation handleNoGeolocation(false); } function handleNoGeolocation(errorFlag) { if (errorFlag) { var content = 'Error: The Geolocation service failed.'; } else { var content = 'Error: Your browser doesn\'t support geolocation.'; } var options = { map: map, position: new google.maps.LatLng(60, 105), content: content }; var infowindow = new google.maps.InfoWindow(options); map.setCenter(options.position); } function detectBrowser() { var useragent = navigator.userAgent; var mapdiv = document.getElementById("map_canvas"); if (useragent.indexOf('iPhone') != -1 || useragent.indexOf('Android') != -1 ) { mapdiv.style.width = '100%'; mapdiv.style.height = '100%'; } else { mapdiv.style.width = '600px'; mapdiv.style.height = '800px'; } } google.maps.event.addDomListener(window, 'load', initialize); </script> </head> <body onload="initialize()"> <div style="text-align:center"> <select id="start"> <option value="625 8th Avenue, New York, NY, 10018">Port Authority Bus Terminal</option> <option value="staten island ferry terminal, new york, ny">Staten Island Ferry Terminal</option> <option value="101 E 125th Street, New York, NY">Harlem - 125th St Station</option> </select> <select id="end" onchange="calcRoute();"> <option value="Brubakkveien 14 1083 Oslo">Sigvartsen proffavdeling</option> <option value="Sonja Henies plass 3, 0185 Oslo">Oslo plaza</option> <option value="moma, New York, NY">MOMA</option> <option value="350 5th Ave, New York, NY, 10118">Empire State Building</option> <option value="253 West 125th Street, New York, NY">Apollo Theater</option> <option value="1 Wall St, New York, NY">Wall St</option> </select> </div> <div id="map_canvas"></div> <div id="pos"></div> <div id="warnings_panel"></div> </body> </html> Hi There, I'm working on an application that potentially gets 1000s of geolocation queries per day and if I don this (as I've done it till now) in php, it works fine but I quickly run into OVER_QUERY_LIMIT error from the google map apis. Thus I think I'd better do it in javascript and just send the coordinates to the server for caching rather than querying from the server's IP. Now the url that sends back the location information looks like this: http://www.google.com/url?sa=D&q=htt...s3czv6-nMr_nbw and I was wondering how I can send a request to this url and parse the xml string that's returned with JavaScript to pass it on to a php (probably by get variables). Is there a handy method that's compatible accross a bunch of browsers incl. mobile ones? Thanks very much for some input! Ron Dear Sir, I have designed a mail service in java.In my compose page,i want to attach some excel files of text files and to send it.After sending i want to store it my database.Then how can i download or open that file after opening that recipient mail inbox. Regards Debasis Hi In C# I would attach the service reference http://www.anotherdomain.com/Service1.svc?wsdl then write myService MS = new myservice(); string[] s = MS.GetDates(); //return an array of string dates BUT can this be done with only Javascript/Jquery , where the service is on a different domain? Can you please tell me how or point me in the right direction Thanks for the help Hello, I am writing a simple yahoo widget that consumes a web service. I tried by using soapclient.js Here is the code: Code: <action trigger="onLoad"> <!-- <text> <name>txtGroups</name> <color>#FFFFFF</color> <size>20</size> <vOffset>100</vOffset> <hOffset>150</hOffset> </text> include("soapclient.js"); mainWindow.visible = true; function getOffices() { var pl = new SOAPClientParameters(); pl.add("userId", preferences.User.value); pl.add("pwd", preferences.Password.value); SOAPClient.invoke("host:port/ReturnOffices/Config1?wsdl", "getOffices", pl, true, getOffices_callBack); } function getOffices_callBack(r) { txtGroups.data=r; } getOffices(); --> </action> I get error: Code: Your browser does not support XmlHttp Objects soapclient.js line 360 Can anybody please let me know what is the correct way to call a web service in javascript (onLoad)... Thanks Srinivas I have multiple <?php require("../section.php"); ?> on my pages and I would like to insert some Javascript (for Facebook's social bookmarks plugins) in one of these so that it comes right before the </body> tag. Currently my "footer.php" require is in that position so I open the footer.php and place the Javascript at the end. Code: <?php echo ' Footer Content Here's my Javascript '; ?> It gives a syntax error in Dreamweaver halfway through the JS and the footer.php doesn't show at all when uploaded. Can you not insert JS this way? How would I do this? I don't know anything about Javascript so be easy. I am using the below javascript to verify a text input box but I would also like to require atleast 3 characters being entered before allowing the user to search. How do I accomplish that? Thanks in advance! Code: <script language="JavaScript"> <!-- /*********************************************** * Required field(s) validation v1.10- By NavSurf * Visit Nav Surf at http://navsurf.com * Visit http://www.dynamicdrive.com/ for full source code ***********************************************/ function formCheck(formobj){ // Enter name of mandatory fields var fieldRequired = Array("words"); // Enter field description to appear in the dialog box var fieldDescription = Array("Company Name"); // dialog message var alertMsg = "Please complete the following fields:\n"; var l_Msg = alertMsg.length; for (var i = 0; i < fieldRequired.length; i++){ var obj = formobj.elements[fieldRequired[i]]; if (obj){ switch(obj.type){ case "select-one": if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; case "select-multiple": if (obj.selectedIndex == -1){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; case "text": case "textarea": if (obj.value == "" || obj.value == null){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; default: } if (obj.type == undefined){ var blnchecked = false; for (var j = 0; j < obj.length; j++){ if (obj[j].checked){ blnchecked = true; } } if (!blnchecked){ alertMsg += " - " + fieldDescription[i] + "\n"; } } } } if (alertMsg.length == l_Msg){ return true; }else{ alert(alertMsg); return false; } } // --> </script> I've been searching google for the last hour trying to find an example of a form that has 2 fields where at least one must be selected. The only search keywords i could come up with were conditional which was kind of what I was looking for but everyone was doing check boxes and hiding fields. I just want two fields email and phone. They are welcome to fill out both but have to fill out at least one. and I'd like to steer clear from just hiding it because I don't want the form to submit if they haven't entered anything. Hello javascript experts... I am following this blog on calling web service in javascript. I am getting syntax error, in my javascript... Code: <action trigger="onLoad"> <!-- mainWindow.visible = true; <script type="text/javascript" src="prototype.js"></script> <script type="text/javascript" src="ws.js"></script> <script type="text/javascript"> function getSalesXml(name, container) { var call = new WS.Call('<url to the wsdl>'); var nsuri = 'http://example'; var qn_op = new WS.QName('<functionName>',nsuri); var qn_op_resp = new WS.QName('sayHelloResponse',nsuri); call.invoke_rpc( qn_op, new Array( {name:'userId',value:<user>} {name:'pwd',value:<password>} ),null, function(call,envelope) { var ret = envelope.get_body().get_all_children()[0]. get_all_children()[0].get_value(); container.innerHTML = ret; $('soap').innerHTML = arguments[2].escapeHTML(); } ); } </script> --> </action> at line: Code: src="ws.js"></script> Can anybody correct this error..., I have 3 Qs about ajax(1,2) and syntax meaning(3): 1- I want to appear a list of urls from a db table to browser, with their newest Google PAGE RANK every time appear in the webpage, and this rank saved auto to database along with previous.... google provides any web service for this? tell me URLs? I found difficulty contact google... 2- Do you know any internet web service (programming) that you input a Russian word, and get (true or 1) if valid, or (false or 0) if not valid word? 3- what mean the in file attached statements to html main file? script.js?x=5 or style.css?p=5 or xmlfile.xml?x=777. i have a web service at this url http://196.218.16.133/onlinereservat...p=HotelsSearch i use hotel search file with HotelSearch method and method will retrieve xml file contains the matched data. the varialbe that i made post with it is named : HotelData the data of the variable is a string file that contains an xml data like this Code: <HotelsParameters> <CityID>388</CityID> <UserName>admin</UserName> <UserPassword>admin</UserPassword> <DateFrom>4/12/2010</DateFrom> <DateTo>4/13/2010</DateTo> <NumberOfRooms>2</NumberOfRooms> <Room> <RoomSerial>1</RoomSerial> <Adults>1</Adults> <Child> <ChildSerial>1</ChildSerial> <ChildAge>5</ChildAge> </Child> </Room> <Room> <RoomSerial>2</RoomSerial> <Adults>2</Adults> <Child> <ChildSerial>1</ChildSerial> <ChildAge>8</ChildAge> </Child> </Room> <Room> <RoomSerial>3</RoomSerial> <Adults>3</Adults> <Child> </Child> </Room> <CurrencyID>162</CurrencyID> </HotelsParameters> i am trying to get the result by posting HotelData but i did not get the xml result file so can anyone help me my code is: Code: <script language="JavaScript"> function InitializeService() { service.useService("http://196.218.16.133/onlinereservation/service.asmx?WSDL", "HotelsSearch"); } var StrSearch; function GetAge() { StrSearch = document.DemoForm.StringSearch.value; service.HotelsSearchService.callService("HotelsSearch", StrYear); } function ShowResult() { alert(event.result.value); } </script> <form name="DemoForm"> Hotel Name : <input type="text" name="HotelData"/><br /> <button onclick="GetAge()">Get Age</button><br /> </form> the data in input filed is the previous xml file I was wondering if its possible to have javascript stop a service on my machine for instance terminal services and then start it again...Any help provided will be greatly appreciated
So I have the below form. How can I validate that if the user enters a quantity in the field they also must select a reason code. How can I do this.\ Code: <form name="theForm" onsubmit="validate()"> <table> <tr id='Child1'> <td><input type = 'text' MAXLENGTH='3' id='PROD_1_150.00_133.50' style = 'width:40px'; class='textfield' name='quantity[]' ></td> <td><select size='1' STYLE='width: 130px' class='smallDrop' name='reason_codes[]'><option value='' > - SET REASON - </option> <option value='BROKEN' >BROKEN</option> <option value='ENTERED' >ENTERED</option> </select></td> <input type='hidden' value='4395' name='itemid[]' > </tr> <tr id='Child2'> <td><input type = 'text' MAXLENGTH='3' id='PROD_1_150.00_133.50' style = 'width:40px'; class='textfield' name='quantity[]' ></td> <td><select size='1' STYLE='width: 130px' class='smallDrop' name='reason_codes[]'><option value='' > - SET REASON - </option> <option value='BROKEN' >BROKEN</option> <option value='ENTERED' >ENTERED</option> </select></td> <input type='hidden' value='4396' name='itemid[]' > </tr> <tr id='Child3'> <td><input type = 'text' MAXLENGTH='3' id='PROD_1_150.00_133.50' style = 'width:40px'; class='textfield' name='quantity[]' ></td> <td><select size='1' STYLE='width: 130px' class='smallDrop' name='reason_codes[]'><option value='' > - SET REASON - </option> <option value='BROKEN' >BROKEN</option> <option value='ENTERED' >ENTERED</option> </select></td> <input type='hidden' value='4353' name='itemid[]' > </tr> <tr id='Child4'> <td><input type = 'text' MAXLENGTH='3' id='PROD_1_150.00_133.50' style = 'width:40px'; class='textfield' name='quantity[]' ></td> <td><select size='1' STYLE='width: 130px' class='smallDrop' name='reason_codes[]'><option value='' > - SET REASON - </option> <option value='BROKEN' >BROKEN</option> <option value='ENTERED' >ENTERED</option> </select></td> <input type='hidden' value='4355' name='itemid[]' > </tr> </table> </form> hi, i have a javascript code of autosugesstion.i had got it from internet. it works fine,but the problem whenever i type a word.. and then press enter it automatically takes the closest autosugessted word from the list ...for example 1.the list contains the word "an apple"..so when ever i type "app" in the textbox and then press enter ..it takes the word "an apple" from the autosugessted list . example 2..if i type "king"..and then press enter it automatically takes "kingdom".. actually i am looking for this solution : it should only take the word from autosugesstion list if selected from arrow key or mouse other wise it should take word from textbox which is typed by user hence can any one solve it ? kindly have a look at attachement. thanks in advance Hi, I am writing JavaScript code that runs inside HTTP page, I need to make XMLHttpRequest to a REST web service. The service is running on the same site but it only accepts HTTPS. I tried to prefix the URL with https:// and Firefox rejected it as cross-site scripting attempt. It's not really cross site as I am calling the same site. I don't have an option to redirect the entire page to https. Is there a proper way to implement this request? Sergey p.s. (sorry if this is a dumb question, I am a JavaScript newbie) Ok, so the code below will open a DIV under the iframe when right-clicking inside the iframe. The DIV will display the mouse coords where it was clicked. This works in IE, but I can't get it to work in Mozilla (FF, Saf, Op, Chr). Any help appreciated! Code: <html> <body> <script language="JavaScript"> function initialise() { if (navigator.appName == "Microsoft Internet Explorer") { editorContent.document.designMode='on'; editorContent.document.attachEvent("oncontextmenu", showContextMenu); editorContent.document.attachEvent("onclick", hideContextMenu); } else { document.getElementById("editorContent").contentDocument.designMode='on'; editorContent.document.addEventListener("contextmenu", showContextMenu, true); editorContent.document.addEventListener("click", hideContextMenu, true); } } function showContextMenu() { if (navigator.appName == "Microsoft Internet Explorer") { var editorContentWin = document.getElementById('editorContent').contentWindow; var mousex = editorContentWin.event.clientX; var mousey = window.screenTop + editorContentWin.event.clientY; } else { /***************************************/ /* WHAT TO DO HERE TO WORK IN MOZILLA? */ /***************************************/ } document.getElementById("contextMenu").style.visibility = 'visible'; document.getElementById("contextMenu").style.display = ''; document.getElementById("contextMenu").innerHTML = 'X: '+mousex+' Y: '+mousey; if (navigator.appName != "Microsoft Internet Explorer") { document.stopPropagation(); document.preventDefault(); } return false; } function hideContextMenu() { document.getElementById("contextMenu").style.visibility = 'hidden'; document.getElementById("contextMenu").style.display = 'none'; } </script> <iframe id="editorContent" name="editorContent" width="400" height="400" frameborder="1" onLoad="initialise();"></iframe> <div id="contextMenu" style="width: 100px; height: 20px; border: 1px solid black; background-color: yellow; visibility: hidden; display: none"></div> </body> </html> Hi I'm New to javascript how to Call WCF service using Javascript or Jquery in html page.(with out using Activex Objects) Hi everyone, this is my first post here and I hope that you can be of assistance!! I have an issue with a registration form. What I would like to do is only allow a certain email domain in the 'email' field. Eg. Only allowing @gmail.com email addresses, and all others would receive an error. This is the line of code that I believe needs changing: function isEmail(valor){if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(valor)){return(true)}else{return false;}} I am not too familiar with this but through my hours of research, I believe that I need to add something to this line. Thanks in advance. |