User location in database - database

first of all I would like to clarify that I am not very professional in laravel or angular. I am trying to make a simple application in which I keep user ads. And I have no idea how to implement geolocation. With geolocation I mean the location of the user. I do not know if it would be better to save only the coordinates or the address in the database. What I'm looking for with this is when I show the ads of the users, I also get what part of the world they come from. And also be able to do searches from the location (Ads closer to the user or distant)
Thanks in advance.

You could store coordinates for the user. That's pretty much all you would need to do. All maps API's have a radius search feature that allows you to search within X miles or kilometers of a given coordinate. After you have your user's coordinates and know the coordinates of where your ads are relevant, you can then do a query to determine if the user is within the ad's reach.
If you want to simplify things a bit and not have to make a ton of API calls each time a page is loaded, you could simply assign a region to each user when they store their address. And then for each ad, you would assign the regions where you would like to show the ad. For example, if a
user is in region=USA and the ad is relevant for region=[USA,Canada,Mexico], then the user would see the ad. I don't know how granular you need to get, but this would most likely be the simplest implementation of what you're trying to do.

Related

How to use google maps api in angularjs to get list of cities between two markers (cities)

I'm trying to show list of via point major cities when user enters/selects starting and end locations. I'm using angularjs and google maps api. Please let me know if this is possible or not?
What you're asking is most definitely possible, but not trivial. In addition to the google maps API, you will likely need to use another tool provided by google: their Places API.
This API would allow you to input a location and receive information about nearby landmarks, establishments, etc. The places API could be called from an Angular 1 service and then filtered or further manipulated to retrieve only results that are considered "major" to your users.
Depending on how accurate/specific you need your data to be, you should also consider using the American Census data API. You can compare the results from your google places API results and use real, accurate government data to check the population of regions or cities.
So to answer your question: Yes, it is most definitely possible although it certainly doesn't require Angular.

Google Places API: store Places in DB

I am building a web app where all the users belong to some type of places, lets say "bank". Each user belongs to only 1 bank but 1 bank can have more then one user.
I need to display their bank name and location in user profile and to be able to search by bank names inside specific city. So I need to connect users and banks somehow.
Is it safe to use the Place ID for that for each bank in terms of app scalability and life-cycle?
The manual says:
Place IDs are exempt from the caching restrictions stated in Section
10.5.d of the Google Maps APIs Terms of Service. You can therefore store place ID values indefinitely.
So Google says I can but is it the best practise? Do I need to store a full address additionally to be safe in case Google will deprecate these IDs in future?
Let's say I can get the bank Place ID with the help of Place Autocomplete during the user registration. Then I need to save it to DB to be able to display it later and search by bank.
The DB Structure could be:
Or Just
But I think the 1st way it better with unique place_id column?
As Google says, you may store PlaceID, but they also tell you that it is a good practice to "refresh" these stored PlaceIDs each 100 days, they do not assure you that your stored PlaceID will be for the same place that you stored.
https://developers.google.com/places/place-id

Access VisualForce Page without salesforce account

I'd like to create visualforce page that inserts a record into salesforce account object. However, I expect some of the page users won't have salesforce accounts. Can they still access it? If not, what are the alternatives that can be used to visualforce page in this case? (Please don't consider Web to Lead Forms).
Thanks,
Yes, it's possible. Go read about Salesforce Sites. For a start:
http://wiki.developerforce.com/page/Websites
http://wiki.developerforce.com/page/An_Introduction_to_Force.com_Sites
(of course it's also possible to write that page in say Java/.NET/PHP and use integration via SOAP or REST to talk to Salesforce... but these 2 main links will keep the whole solution within SF so no need to need to learn new language, have extra maintenance effort etc)
Sites are VF pages that expose a bit of your company's data without need to log in. You can use them to input data too, just remember that in theory anybody could learn the link and spam you (not too different from web2lead, inbound email handlers etc). You specify security in a way similar to Profiles, the records will have "Created By = {site name} Guest User".
I don't think there's anything out of the box to restrict visibility, they're open to whole world. So if you would want something similar to login IP ranges (so only sales reps from your office's network can enter data) - you might have to write some logic in the controller.

Geocoding out of Salesforce.com (large number of static adresses)

We have developed an application in Salesforce.com to geocode and display account information (address information) on Google Maps within Salesforce.com. We have around 750k addresses for the initial (one-time) geocoding process (static address data), as we store the lat/lon with the account.
Is their any way to get this geocoded done in one 'batch' as we seem to hit the daily allowance of request per day (3k)?
Thanks for your support and feedback.
If you'd like to use Google to do this and you need to precompute the lat/lon coordinates, you'll need to upgrade to the Google Maps API for Business. The table on that link provides a detailed overview of the limit differences, and I suspect that the terms of use may also be more in line with what you're developing too.
If your goal is to create a Google Map from the addresses, you may also consider just passing the address data instead of the latitude and longitude. Their static maps will work fine as long as you know which locations that you'd like to use on the map, you don't have too many locations in one map and you don't need interactivity. Otherwise, you should use the javascript API and their documentation is very good for that.
If you don't know which locations you'd like to use on the map, you could use the lat/lon coordinates of their zip codes (which are freely available) to create a view port.
If you'd like a static map of the locations (whether or not you precompute the lat/lon), I'd recommend taking a look at the apexgooglestaticmap Github repository. It makes it quite easy to make certain types of static Google maps in APEX and VisualForce. Here's an example from that README:
APEX Controller
String[] homes = new String[]{'Albany, NY','Wellesley, MA','New York, NY','Pittsburgh, PA','01945','Ann Arbor, MI','Chicago, IL'};
GoogleStaticMap.MapPath moves = new GoogleStaticMap.MapPath(homes).color('0x000000ff');
String movesUrl = new GoogleStaticMap().addPath(moves).url;
Visualforce Page
<apex:image value="{!movesUrl}">
Google Maps URL and Image
https://maps.google.com/maps/api/staticmap?sensor=false&size=500x350&markers=label:0%7CAlbany%2C+NY&markers=label:1%7CWellesley%2C+MA&markers=label:2%7CNew+York%2C+NY&markers=label:3%7CPittsburgh%2C+PA&markers=label:4%7C01945&markers=label:5%7CAnn+Arbor%2C+MI&markers=label:6%7CChicago%2C+IL&markers=label:0%7CAlbany%2C+NY&markers=label:1%7CWellesley%2C+MA&markers=label:2%7CNew+York%2C+NY&markers=label:3%7CPittsburgh%2C+PA&markers=label:4%7C01945&markers=label:5%7CAnn+Arbor%2C+MI&markers=label:6%7CChicago%2C+IL&path=weight:5%7Ccolor:0x000000ff%7CAlbany%2C+NY%7CWellesley%2C+MA%7CNew+York%2C+NY%7CPittsburgh%2C+PA%7C01945%7CAnn+Arbor%2C+MI%7CChicago%2C+IL&
There are also many other geocoding APIs available. They each have their own terms of service, so make sure that your application matches the acceptable uses before you build anything with them. I've personally used PCMiler Web Services with success, and Geonames for reverse geocoding (they have a number of other great features too).
Google only allows that max per IP Address. If you were able to maximize the locations you were doing them from, max out at work, home or maybe your local starbucks, you could be able to hit the goal easily. If you have more than 250 employees just assign the 'homework' of going home and geocoding it! Spread the wealth, and the fun, of geocoding!
The other solution is using Google Maps API For Business, which allows you to do a max of 100,000 requests per day. For more information look at: http://code.google.com/apis/maps/documentation/geocoding/ ; for more information specifically on Geoogle Maps API For Business: http://code.google.com/apis/maps/documentation/business/index.html
I use this geocoder, and add my list and use yahoo to get the lat and long.
We have FindNearby installed, so once I get all the addresses geo-coded, I add them back into my excel worksheet in the respective column that has the Record ID. Since we use FindNearby, I have to add a column that is titled Mapping Status, and all cells under this say Located. I used ApexData loader to mass upload into SF. Note, geocoder has a limit of only 1000 records at a single "code" click, but it has no limit of how many lists you can process per day.
I changes some code to use Bing map services instead of google. There limits are based on keys and are much larger. Also when the key hits its max requests, then you can just get a new free key and apply it.

How to share data between webapp users over GAE?

I have a webapp deployed on GAE and users can sign-in using OpenID. Once users are signed-in they can access the data store for their own data.
Now, if I want to establish a "shared data space", how can I achieve such a thing? Can I give access to user A to data from user B? We share entities? How can I overcome access restrictions?
Any help on this aspect will be greatly appreciated.
EDIT 1
Not quite the BigTable expert. I'm not looking for magical kingdom solution, just pointer on how to tackle this problem (blog, article, tutorial, etc).
But if I get it right, data is accessible by anyone with access to the application (if access control is available). So if I give the a {KEY, entity} pair to user B from user A he will be able to access it no problem?
Maybe I'm just confusing concepts...
The GAE datastore is a database. Data stored in it is in no way restricted to a single user. BTW, you don't even have to sign in to use a GAE application. Just query for the data you want, and you'll get it, whether the current user stored it or anyone else is irrelevant.

Resources