I am using bing maps ajax control in a webapplication with a bing maps enterpise key.One of the modules include a functionality to geocode a list of addresses requested by the user.I am using the following code snippet to do the geocoding.
for (var i = 0, j = addresses.length; i < j; i++) {
searchManager.geocode({
where : addresses[i],/*<address>,<city>,<state>,<country>,<zip>*/
count : 5,
callback : success,
errorCallback : failure
});
};
The success% is very less.Close to 10% even after multiple tries(about 150 addresses to geocode).
So,I wanted to know if there is any way we can use the Address class(http://msdn.microsoft.com/en-us/library/hh868069.aspx) for geocoding instead of giving address as a string.The official documentation mentions only about giving address as a string(http://msdn.microsoft.com/en-us/library/hh868060.aspx). The reason I wanted to check with address class instead of string is because,with the bing maps SOAP api in a silverlight application,i had found the success% to be more while using Address class.
Thanks in advance for any help in this issue.
First off, if you have the address data somewhere you should geocode it ahead of time. Geocoding all your address in JavaScript with your map is slow and it also uses a lot of transactions thus making you run out of free usage fast. Is there a reason why you are geocoding addresses in a loop in a JavaScript app rather than geocoding a head of time?
It is often better to pass in the address as a single string and allow the geocoder to parse it. This is actually a tip the is used for the REST services as well when geocoding.
Related
I need to create a function in Google sheet to get my external (public) IP address
I tried use function =IMPORTXML("https://api.myip.com","//body"), but this method shows diffrint IP address not my external IP address
the reason the IP is different is because you are getting the IP of Google Sheets location not your IP
The following solution makes use of a custom menu in the Spreadsheets -
function onOpen(e) {
SpreadsheetApp.getUi()
.createMenu('My Menu')
.addItem('Get IP', 'getIP')
.addToUi();
}
function getIP() {
SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().appendRow([JSON.parse(UrlFetchApp.fetch('https://api6.ipify.org?format=json')).ip]);
}
You're free to modify the script to place said IP anywhere in the sheet, as required.
Also, I'm making use of the IPv6 address, as opposed to IPv4 but should you want to switch it to IPv4, replace the URL from the code to https://api.ipify.org?format=json - you may find this resource here.
I've asked out & around and this cannot (in any way) be achieved via a custom formulae, as such formulas run within a wrapper of sorts (that do not interact with any client-side elements). Hope this helps.
Edit note
Adding a way to insert external IP using custom menu to the specific cell (current cell, to be precise) -
function onOpen(e) {
SpreadsheetApp.getUi()
.createMenu('My Menu')
.addItem('Get IP', 'getIP')
.addToUi();
}
function getIP() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var currentCell = sheet.getCurrentCell();
var ip = JSON.parse(UrlFetchApp.fetch('https://api6.ipify.org?format=json')).ip;
currentCell.setValue(ip)
}
By using this method, the IP would be added to the cell that has been selected.
You may wonder why current cell was chosen instead of active cell - well, the answer to that is because the document prefers us to do so :) I bet it would work even if we were to use active cell (haven't tested that though but I don't see a reason why it wouldn't)
It's not possible to use a Google Sheets custom function or Google Apps Script server side address to get you external IP because the related code is executed on the server side and Google Apps Script services doesn't include methods to get that but you could use client-side code to the get the external IP address. Additional, if it is required to send the IP address to an spreadsheet, the you could use do that by using google.script.run or the Google Sheets API.
NOTE: The closest Google Apps Script classes are Class Session and Class User.
Related
How to get client's IP address using JavaScript?
References
https://developers.google.com/apps-script/reference
I need to make a Reverse Geocoding for my SD app with Genexus X Ev3 U7, to show a location through aa given address in the map within the app. I've struggled for some time figuring out how to make it work with no luck.
I've already read all the documentation, followed the steps to get the API key from google (with Geocoding and Geolocation APIs enabled) and tried different ways with the methods shown in it and i haven't made it work.
Should I consider something else? Does anyone have done this before?
thanks before hand
Yes, there are two methods in Geolocation external object: GetAddress() and GetLocation().
If you are using it on the client-side, then both Android and iOS implementations use the platform's native implementation.
If the code runs on the server-side (C# or Java), then the implementation uses Google's geocoding services. The problem here is that there is no way to provide an API Key, so the number of allowed requests by day may be too low (depending on your usage).
Well, the main problem was that i was capturing the values of the Address Domain Collection variable all wrong.
All i had to do was to declare an &Address variable that read an &Addresses collection variable and to give it to a &Adrs VarChar variable:
For &Address in &Addresses
&Adrs = &Address
Load
EndFor
where &Addresses = GeoLocationAPI.GetAddress(&GeoLocation)
I don't know how i didn't come up with this before.
Thanks everyone :)
I am working on an Android App. I want to get list of all restaurant around me within a specified radius(let say 5 miles). I tried using Google places API and it works, however it limits the number results returned to 20, what if there are more than 20 restaurant in that radius around me. How do I get an exhaustive list of all the restaurants? What is the best way to do this? Is there something other than Google Places API that I can use? Thanks for your help in advance.
If you want to do it server side you can use this guy's class :
http://andrenosalsky.com/blog/2011/google-places-api-php-class/
and you have to get an api key as it is explaned here :
http://code.google.com/intl/fr/apis/maps/documentation/places/
then you can send data in JSON format to your Android
What is the most up to date, accurate, turn-key code to inject into a page to automatically read a user's IP and spit out their city... on this page we are borrowing from goingtorain.com I want it to display ... within 3 miles of (dynamic city)
http://www.drillavailable.neighborrow.com/
Another one we've been looking at to use is http://www.maxmind.com/app/geolitecity. Looks to be fairly simple to setup and is open source/free with apis for most popular languages.
Not done much other than play with it for 5 mins but looks promising.
I'd go with location aware browsing. Look into the W3C GeoLocation API.
For example, try Google Gears Geolocation module.
These technologies allow your clients to be geolocalized not only by looking and their IP (which can have 200km offsets) but also by triangulating SSID information from nearby wireless Access Points, and this can be extremely precise.
Once you have the (lon,lat) coordinates, it's just a matter of calling some webservice to get the nearest city's name.
I would choose the locator API at http://ipinfodb.com You can access it via XML or JSON, send it your API key and an IP and it will return the city, state, zip, country, etc. You can then parse the results in your language of choice. Its the simplest way to achieve this without actually storing any information about IP/location routing.
Yes, you only need to use the ClientLocation object in the google.loader namespace. In total the whole code is.
<script src="http://www.google.com/jsapi" language="javascript"></script>
<script language="javascript">
if (google.loader.ClientLocation != null) {
alert(google.loader.ClientLocation.address.city);
} else {
alert("Not found");
}
</script>
The properties available are
google.loader.ClientLocation.latitude
google.loader.ClientLocation.longitude
google.loader.ClientLocation.address.city
google.loader.ClientLocation.address.country
google.loader.ClientLocation.address.country_code
google.loader.ClientLocation.address.region
is there a way to use core location or google or some other api to provide two points on the map and get the resulting set of latitude/longitude pairs for the route?
i have seen in this tutorial Drawing polyines or routes on a MKMapView that how to draw driving direction using core graphics...but in the sample code it has route.csv which has predefined set of longitudes and latitudes.....how do i make pair of longitudes and latitudes so that i can draw driving directions.
Companies invest millions of dollars into developing routing algorithms, so I very much doubt that you'll be able to get it for free anywhere (I'm happy to be wrong, though). For example, the Google Maps JavaScript API supports routing, so I guess you could hack that up. The results wouldn't be fast or pretty, mind you.
If you have a limited use of the directions request (less than a certain amount per day) and always display results on a Google map, you do qualify for the free Google Directions API.
https://developers.google.com/maps/documentation/directions/
Read the license part thoroughly to know the limits. You should easily be able to request a json response that will b easier to parse than an xml one (plus Apple added json parser in iOS).
For example
http://maps.googleapis.com/maps/api/directions/json?origin=Boston,MA&destination=Concord,MA&waypoints=Charlestown,MA|Lexington,MA&sensor=false
If you are over the limit, you should look into their business licenses.
Old question but MTDirectionsKit was recently open sourced and it works great:
MTDirectionsKit
with Google API you can get directions from two points, the only problem is you just can use it once a day if you don't pay.
Search how to get the key API from google, there are a lots of videos on youtube talking about it.
Furthemore, i got a library which hepls you to draw the line between points this one https://github.com/jd-alexander/Google-Directions-Android
After you implemented it in build.gradle(Module:app), implement the library in the class like
public class LocationMapActivity extends AppCompatActivity implements RoutingListener
will appear a error to implemets the methods (obligatory to implement them but It's not necessary to use them).
I just did this:
public void route(){
Routing routing = new Routing.Builder()
.travelMode(/* Travel Mode */)
.withListener(/* Listener that delivers routing results.*/)
.waypoints(/*waypoints*/)
.key(/*api key for quota management*/)
.build();
routing.execute();
}
More info in the link.