google maps iframe parameters - javascript

This is my first time to use google maps iframe and i am lost with these params geocode , fll , fspn , st , rq , ll , spn
all of these params should be equaled with a latitude and longitude .. i have json array retrieve my location of data but i am lost which data should be sent to each param :(
results->geometry->bounds->northeast->lat
results->geometry->bounds->northeast->lng
results->geometry->bounds->southwest->lat
results->geometry->bounds->southwest->lng
results->geometry->location->lat
results->geometry->location->lng
results->geometry->viewport->northeast->lat
results->geometry->viewport->northeast->lng
results->geometry->viewport->southwest->lat
results->geometry->viewport->southwest->lng

This web page has a good explanation of all the parameters:
http://www.seomoz.org/ugc/everything-you-never-wanted-to-know-about-google-maps-parameters

Related

Localising the Search Region of Google Map

I made a google Map and someone noticed that if you type, say "Brighton" into the search, it takes the user to the USA Brighton - what's desired is the UK's Brighton.
I went to the Google Docs page for it: https://developers.google.com/maps/documentation/javascript/localization#Region
And tried to amend my script url to:
<script async defer src="https://maps.googleapis.com/maps/api/js?key=SECRET_KEY&callback=initMap&region=GB"></script>
but performing the "Brighton" search still takes me to the USA.
What am I doing wrong? Tried in a private window to ensure it wasn't a cache thing ...
Although this script in particular loads the map on the page load, I have a function for searching the user's entered data which appeared like this:
# get lat lng values based on postcode / address
$geo = file_get_contents('https://maps.googleapis.com/maps/api/geocode/json?address='. urlencode($data['address']) .'&sensor=false&key=SECRET_KEY');
$geo = json_decode($geo, true);
Adding the &region=GB param here makes it work with user search.
# get lat lng values based on postcode / address
$geo = file_get_contents('https://maps.googleapis.com/maps/api/geocode/json?address='. urlencode($data['address']) .'&sensor=false&key=SECRET_KEY&region=GB');
$geo = json_decode($geo, true);

Mapbox data with google sheets

I am working to develop a crowdsourcing website that takes input from google forms and displays this information on a map. I am working with mapbox and am looking for a way to get the data points in my google spreadsheet (with lat/long info) to automatically show up on the map. Any tips would be appreciated, thanks!
I'm working on a similar project.
I 'published' my google spreadsheet: file > Publish To Web.
You should get a popup window with a URL for your sheet:
https://docs.google.com/spreadsheets/d/[your ID here]/pubhtml
Once you have the ID you can use it on your website:
// ID of the Google Spreadsheet
var spreadsheetID = 'fakeExample';
// Make sure it is public or set to `Anyone with link can view`
var url = "https://spreadsheets.google.com/feeds/list/" + spreadsheetID + "/od6/public/values?alt=json";
$.getJSON(url, function(data) {
var entry = data.feed.entry;
$(entry).each(function(){
//do stuff with each entry in your spreadsheet
// for example, build a GeoJSON object with your lat/lons or add an individual marker
// ex: add the 'country' column to the `results` box
$('.results').prepend('<h2>'+this.gsx$country.$t+'</h2>);
});
});
I suppose you could use any mapbox js map with omnivore, for example.
The form results go in a google sheet - geocode it automatically with some script - publish the sheet to the web with results in csv - the coordinates are pulled automatically to the map which updates upon loading.

Integrate google map direction with 8 + way points in angularjs

I have requirement to integrate google map api with multiple waypoints.
Available data I have is array of latitude , longitude & timestamp. say :
$scope.locations = [
{latitude : 22.152454, longitude:88.455454 , timestamp:"21451457451"},
{latitude : 32.152454, longitude:88.44554 , timestamp:"21451457451"},
{latitude : 12.152454, longitude:88.875454 , timestamp:"21451454451"},
{latitude : 54.152454, longitude:88.8755454 , timestamp:"21521457451"}
]
Now I want to have google map displayed in my application with markers showing datetime of waypoints.
I tried ngmap but this dosen't support more then 8 points also I didnt found it much effective .
If you're not limited in using AngularJS, this sample from the Google Maps API developer site seems to fit with what you want to do.

How to pass parameters to URL and retrieve with PHP?

I noticed that there are a lot of these questions but I can't find something that relates to my particular project. I am building a Instagram and Google maps app. What I'm trying to do is I'm pulling all JSON format endpoints from Instagram with PHP. With Google maps, I'm adding the longitude and latitude coordinates that this certain API call passes through so you can see where the user has taken the photo at the time it was created. What I'm working on is using Google's event methods I am able to center longitude and latitude coordinates to the URL using the function parent.location.hash.
google.maps.event.addListener(map, 'center_changed', function(){
var control_center = map.getCenter();
var lng = control_center.lng();
var lat = control_center.lat();
parent.location.hash="&lng="+lng +"&lat="+lat;
$('.lng').append(lng);
console.log(map.getCenter());
console.log(lng +', ' +lat);
});
The issue I'm now running into is when I tried to retrieve lng and lat with PHP $_GET it was not working. I found out because it's a fragment and it never gets sent to the server. I found other tips and tricks like parse_url but that echos one string. Here is a snippet of what the current URL looks like when someone has done a search and moving Google maps around in the viewport -> api.php?location=houston#&lng=-95.34908043923292&lat=29.74942788453117.
The concept behind this API mashup is you have a search box, and you type in Houston, TX. Google maps will load and a feed from Instagram with display that have coordinates that are within Houston, Tx. The map will show where exactly where those photos taken. You move the map and we want more Instagram photos to show up but I can't pass the lng and lat variables to instagrams api. This is a bit of a long one, sorry.
Pastebin
can you try this and let me know,
$url=parse_url("http://domain.com/api.php?location=houston#&lng=-95.34908043923292&lat=29.74942788453117");
$myurl = $url["fragment"];
echo $myurl;
Update, to get individual variables
$url=parse_url("http://domain.com/api.php?location=houston#&lng=-95.34908043923292&lat=29.74942788453117");
$myurl = $url["fragment"];
echo $myurl.'<br>';
parse_str($myurl);
echo $lng.'<br>';
echo $lat;

Passing Javascript to Rails controller on POST + clickable Google Maps markers

In my Rails application I am using the Google Maps AutoComplete API to allow users to search for locations like so:
The javascript code (Gist here...) returns a JSON hash and places a new marker with the choice from the drop down box. I have a listener for the marker that does nothing right now, which leads to my question.
How do I make the 'click' event for the marker pass the the result hash (in this case 'place') to a rails controller?
More generally, how does one pass JavaScript data to a Rails controller at all?
I've looked over other answers and can't find a solution. Any help would be greatly appreciated.
Thanks!
~Dan B,
#thoughtpunch
JQuery can serialize data in all of it's ajax related methods; you can use this to post raw json to the server:
$.post("/foo", {place: {foo: "bar"}})
On your controller:
def action
render :text => "Got: #{params[:place]}" # output: 'Got : {"foo":"bar"}'
end
You'll probably want to either only post the fields from your locations you care about or use JSON.parse to unserialize your json strings for manipulation server-side.
You'd use jQuery to do a 'GET' and pass the parameters you need. So based on your gist, you have an address string you built. In your controller you would send back the response which would be handled in the callback. You could send back the JSON and do something with that client-side or just send back the html to insert.
google.maps.event.addListener(marker, 'click', function() {
// maybe a loader here?
// $('#reviews').html('loading reviews for ' + address + '...');
$.get('/reviews', {address: address}, function(data) {
$('#reviews').html(data);
});
});
And that data could be anything that you want as a param. You could send the whole place if you wanted. '{place: place}'

Categories