Retrieving data on google map - google-maps

I would like to find out what are the companies/businesses around my area of interest. Is there any way that I can download these data (addresses, names) of the companies through google maps?

You may use the google maps' javascript places to do the job. You can use, for example, nearby search witch return you all markets near you. Then, you can specified some names, type of shops, if they are open now...
This is a simply nearby search:
var request = {
location: pyrmont,
radius: '500',
types: ['store']
};
service = new google.maps.places.PlacesService(map);
service.nearbySearch(request, callback);
This is an example of nearby search provided by google.
You also can add the name of the place (the system return you some places with the name that you precise):
var request = {
location: pyrmont,
radius: '500',
types: ['store'],
name: 'Zara'
};
service = new google.maps.places.PlacesService(map);
service.nearbySearch(request, callback);
You may consult the google's documentation.
Tell me if you have some questions.
Note, it is not precise in your question but I use javascript.

Related

Working with php/mysql display information on google maps

I have a MySQL address database which contains all the necessary information to look up the address on google maps. Each row with data contains an extra field naming LATLNG. Which contains the Lat and Lng in the preferred format of google maps. ####, ####. I have already created a viewing page with a ‘show’ button to display the content on a separated html page in Google maps with the address above it.
The problem is that I could find all kinds of tutorials (also from google themselves) with the vast possibility’s that google maps provide. The feature I would like to use however isn’t found in a tutorial. And whatever I do, I seem to get stuck with the result of it.
Example (own database):
After each address field there is a button with the next caption:
echo '<td>Show</td>';
Example (google maps) what opens after pressing the SHOW button:
<script>
function myMap() {
var Lelystad = new google.maps.LatLng(LAT LNG INFORMATION);
var mapCanvas = document.getElementById("map");
var mapOptions = {center: TOWN NAME, zoom: 15};
var map = new google.maps.Map(mapCanvas, mapOptions);
var marker = new google.maps.Marker({position:TOWN NAME});
marker.setMap(map);
var infowindow = new google.maps.InfoWindow({
content: "DISPLAY CONTENT OF ADDRESS ABOVE MARKER"
});
infowindow.open(map,marker);
}
</script>
What I want is that after pressing the ‘show’ button the latlng from that given address is being picked up by google maps and show it.
Hopefully someonw can help me, if some of the information is not clear enough don't hesitate to ask me.
I am not sure you want to use the JavaScript. There is a very simple API giving you the latitude and longitude through a URL:
http://maps.googleapis.com/maps/api/geocode/json?address=eiffel%20tower,paris
where "address" is the address you are looking for. You must first register to obtain a key and you are limited to 2500 requests per day (but you can store the results in the database).
See full documentation here: https://developers.google.com/maps/documentation/geocoding/intro?hl=fr

Restrict google map autocomplete

I want to restrict google to only 'address', '(cities)', '(regions)' et remove commercial market name.
According to the documentation
types
Type: Array
The types of predictions to be returned. Four types are supported: >'establishment' for businesses, 'geocode' for addresses, '(regions)' for >administrative regions and '(cities)' for localities. If nothing is specified, >all types are returned.
But this code return nothing
var options = {
types: ['address', '(cities)', '(regions)']
};
var autocomplete = new google.maps.places.Autocomplete(input, options);
autocomplete.bindTo('bounds', map);
https://jsfiddle.net/7pa4x12L/1/
You're suppose to specify only one type. As Add Autocomplete for places and addresses says:
In general only a single type is allowed.The exception is that you can
safely mix the geocode and establishment types, but note that this
will have the same effect as specifying no types
That's why if you check the sample code from Restrict the search to a specific country you can see that there's only one type specified.
var options = {
types: ['(cities)'],
componentRestrictions: {country: 'fr'}
};
You can see more of this in the Autocomplete sample demo.

How can I order results from Google places autocomplete?

Firstly please accept my apologies if this article already exists, but my long search efforts hasn't returned anything useful so far.
I'm integrating Google places autocomplete into one of my website, I'm struggling to find the options that will allow us to sort order the results; Currently we have an issue where a user can input the word London and we want London, UK to be the first results not London road in ...!
We still want the user to be able to search by Road, but we don't want this to show above big cities.
Can anyone please point me in the right direction on how to do this with Google Places Autocomplete?
Unfortunately, changing the order result of the autocomplete is not possible.
The Place Autocomplete service will return candidate matches based on this string and order results based on their perceived relevance.
The closest you can make is to add a restriction by adding type and/or componentRestriction. Currently, you can use componentRestrictions to filter by country.
Sample code:
var input = document.getElementById('searchTextField');
var options = {
types: ['(cities)'],
componentRestrictions: {country: 'fr'}
};
autocomplete = new google.maps.places.Autocomplete(input, options);
You can do something like this
const defaultBounds = new google.maps.LatLngBounds({ lat: 42.5214071, lng: -70.9310135 });
autocomplete = new google.maps.places.Autocomplete(
document.querySelector('#autocomplete'), {types: ['geocode'],
bounds: defaultBounds,
strictBounds: false
});
It will help you more.

Google Places API - search vicinity as a place

I have this problem with Google Places API. I'm searching for "Guildhall" in Cambridge. It finds it exactly on maps: https://www.google.pl/maps/place/Guildhall,+Market+Hill,+Cambridge+CB2+3QJ,+Wielka+Brytania/#52.2046916,0.1193167,17z/data=!3m1!4b1!4m2!3m1!1s0x47d870bd9c1c0a5d:0x7228336bd9005dae
But places api doesn't return "Guildhall" as a result: https://maps.googleapis.com/maps/api/place/search/json?location=52.2046916,0.1193167&rankby=distance&keyword=guildhall&sensor=true&key=YOUR_API_KEY
Is it possible to return results like "Guildhall" from Places API?
You can configure the types of places you want returned by specifying the type:
See the documentation here; https://developers.google.com/places/documentation/supported_types
Then pass in the type option when creating your service;
var request = {
location: pyrmont,
radius: '500',
types: ['store'] // specify the types here
};
service = new google.maps.places.PlacesService(map);
service.nearbySearch(request, callback);
UPDATE:
I may have a solution for you: You could try using the Geocode service from Google: https://developers.google.com/maps/documentation/javascript/examples/geocoding-simple
I have put it into a JS Fiddle for you to have a playaround with: http://jsfiddle.net/loanburger/1vhymg6m/
Hope that helps

google Javascript API V3 places search with types=['geocode'] returns ZERO_RESULTS

I am having problem with Google places search. If I choose types: ['geocode'] i get no results (ZERO_RESULTS) regardless of a search term. What am i doing wrong? Here is my code snippet:
...
var params = {
name: searchTerm, //search Term is for example 'lon'
bounds: map.getBounds(),
types: ['geocode']
}
var service = new google.maps.places.PlacesService(map);
service.search(params, function (results, status) {
alert(status); - gives ZERO_RESULTS
}
...
Update:
I want it to behave the same as Javascript AOI places Autocomplete. To get me the same results. I thought they are querying the same data?
var input = document.getElementById('location');
var options = {
bounds: map.getBounds(),
types: ['geocode']
};
autocomplete = new google.maps.places.Autocomplete(input, options);
google.maps.event.addListener(autocomplete, 'place_changed', function() {
....
This one gives me great results. ( reason i am not using autocomplete method over first solution is because i could not manage to auto select first item in autocomplete list once enter (in search fields) is hit. - if you know answer to that please help :)
At this time at least, it is best not to assume that Google Places has a lot of data for a location or that the data is finely categorized. It is entirely likely that Google Places has few or no places of type geocode for you to find.
Since types is optional, remove it and you will likely get results.
UPDATE: Regarding the Autocomplete vs. Places Search stuff that has been added to the question: I have not used Autocomplete, but I would think that it should not give you the same results. A Places Search is trying to find stuff that matches search term XXXXX. Autocomplete is trying to predict given substring XXXXXX what it is you may be trying to type. So it is likely to return more (and different, and in many cases less relevant) results. So what you are seeing (more results with Autocomplete) does not strike me as anomalous.
I have found that by removing the "types" parameter I get way more places. I am using places autocomplete and it definately gives me more options without the types.
I am just catching the enter key and stopping it, to prevent users submitting the form accidentally. Not quite what you wanted but it works for me.
$("#LatLongSearch").keypress(function (event) {
if (event.which == 13) { // make enter key just search map and stop it from submitting form
event.preventDefault();
}
})
try this
$('#searchform').keypress(function(e) {
if (e.which == 13) {
e.preventDefault();
google.maps.event.addListener(autocomplete, 'place_changed', function() {
fillInAddress();
$('#yourform').submit();
}); } });
It work for me