I've got a real trouble trying to start my web app because of wrong adress returns from Google Geocoder when passing LatLng values to it.
http://jsfiddle.net/3kUx7/
geocoder.geocode({'latLng': latLong}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results) {
The main problem is that coordinates pair 50.393386951159684,30.612979531288147
returns the wrong address "улица Заречная, 9А"
The same pair tested in new and old google maps and even regular google search returns correct address "Днепровская наб., 26Г, Киев, город Киев 02000"
The code i use for reverse geocode is the same as in jsfiddle.
That area was newly built (5-7 years ago :) ) adn google has some wrong building on a regular map but address almost correct.
Reverse Geocoding Test App
http://reverse-geocoding.appspot.com/
gives the SAME WRONG RESULT but showing 2014 copyright!
I just don't understant what am i doing wrong. Or google has different DBs for online maps and JS API. if so GOOGLE PLEASE SYNCRONIZE! The world had changed for past 5 years!
Related
I am trying to make an uber type app with nativescript but I am struggling to find a way to center a position when an app opens just like when you open uber app. I am using google maps API
Thank you
If you're using the nativescript-google-maps-sdk (which I think you are since you also posted the question over there) then you can do this:
// Any value from 2 to 20
mapView.zoom = 15;
// Moves the map
mapView.latitude = lat;
mapView.longitude = lng;
// Places the marker at the point
marker.position = mapsModule.Position.positionFromLatLng(lat, lng);
We're using Google Maps API to show a list of all our clinics on our website and I'm in the process of writing a 'Show all clinics near me' feature. Everything is working fine and I have a circle being drawn on the map using the Google Maps Circle call from the geometry library.
We want to return a list of all clinics that fall within that circle. Our clinics are loaded via a $.get(); call from a separate .js file. I've been messing with the google.maps.geometry.spherical.computeDistanceBetween(pointA, pointB); function to test if each clinic falls within the circle, where pointB is the center of the circle and pointA is the position of the clinic- both of which are being defined via new google.maps.LatLng(clinic.lat, clinic.long));.
ComputeDistanceBetween keeps returning NaN for every clinic. Due to some sensitivity issues I cannot share the exact code I'm working with but I modified a Google Maps API fiddle for marker clustering HERE because we're also using marker clustering and the lat/longs load similarly to ours.
I already checked this post and it didn't work out for me.
You have a typo in your code. locations[x].long doesn't exist, that should be be locations[x].lng
so your function should be:
var mylocation = new google.maps.LatLng(locations[0].lat, locations[0].lng);
console.log(mylocation);
var marker_lat_lng = new google.maps.LatLng(locations[2].lat, locations[2].lng);
console.log(marker_lat_lng);
var distance_from_location = google.maps.geometry.spherical.computeDistanceBetween(mylocation, marker_lat_lng);
document.getElementById('feedback').innerHTML = distance_from_location;
proof of concept fiddle
I am currently integrating Google Maps Javascript API. I would like for the user to be able to type an address and have a "google street view" map generated for him. Preferrably, this street view map should be looking "inside" the office building. Example:
I am searching for "Zar Restaurant & Bar, Rosenheimer Straße, Munich, Germany" in Google Maps (link: https://www.google.bg/maps/place/Zar+Restaurant+%26+Bar/#48.1141096,11.6115833,17z/data=!3m1!4b1!4m5!3m4!1s0x479ddf9443819fc1:0xb242780e5bdc5ce5!8m2!3d48.114106!4d11.613772?hl=en). One business is found, and if you click on the image in the side panel, you are shown a 3d-view inside the restaurant.
Alternatively, if a Google organic search is made with the same keywords, the business listing is displayed on the right and there is a button saying "see inside" that gets you there. I would like to achieve such a 3d-view map (showing the inside view) embedded on the site, as shown here: http://www.zar-bar.de/galerie.php . I am sure that this can be easily achieved by embeding the iframe google generates for you, but i would like NOT to use this method.
Question: How to get the same 3d view inside the business through Google Maps Javascript API?
I know that the same map can be displayed by the JS API when you enter the lat & lng. I managed to find the needed lat & lng from this tool of theirs: https://developers.google.com/maps/documentation/embed/start. From here, i saw the lat & lng from the params in the iframe src just below the imag . Then i placed the coordinates in google maps js api and it worked. Working code:
google.maps.event.addDomListener(window, 'load', initialize);
function initialize() {
var position = {lat: 48.1141, lng: 11.6138};
var map = new google.maps.Map(document.getElementById('someDiv'), {
center: position,
zoom: 14
});
var panorama = new google.maps.StreetViewPanorama(
document.getElementById('someDiv'), {
position: position,
pov: {
heading: 240,
pitch: 10
}
});
map.setStreetView(panorama);
}
JS Fiddle: https://jsfiddle.net/cdfnvrj0/3/. This lead me to believe that i need to get the lat & lng from a an address.
What i have tried:
Requesting Google Maps geocode API to get lat & lng from an address with the following request URL:
"https://maps.googleapis.com/maps/api/geocode/json?address=Zar%20Restaurant%20Bar,%20Rosenheimer%20Stra%C3%9Fe,%20Munich,%20Germany%20&key=AIzaSyBLASrj4k7gOpG62kdBWwGrGyHnfM71FT4"
This API finds the address and returns some geolocation data, but when i place these coordinates in my google maps JS api, the displayed position is not exactly the same. It places me somewhere on the street, not a 3d view of the searched business. This leads me to believe that this API returns geolocation based on the address as it is, and not an address of a business, i.e does not work for businesses. So, how does one figure out if there is a Google My Business address corresponding to a given address (through an API), and if there is such a business, how can i find out if it has an "inside view", and how can i take it's lat&lng to place it on a map? Is this currently possible with Google APIs?
I would be very thankful of all feedback and suggestions. Thank you for your time.
The geocoder is for postal addresses. To find a "place" (like "Zar Restaurant Bar"), use the Places API
Places API result for "Zar Restaurant Bar, Rosenheimer Straße, Munich, Germany":
Rosenheimer Str. 240, 81669 München, Germany (48.114106, 11.61377200000004)
Geocoder API result for "Zar Restaurant Bar, Rosenheimer Straße, Munich, Germany":
Rosenheimer Str., München, Germany (48.1232636, 11.602944500000035) ["GEOMETRIC_CENTER"/"partial_match"]
What I'm doing and what I've tried
I'm using Google Geo coding web service to get the latitude and longitude of an address I pass, like this:
$.getJSON("http://maps.googleapis.com/maps/api/geocode/json?address=Boston&sensors=true",function(data){
//Do my programming here
});
It was, for some reason working perfectly, initially, but then it stopped working and and I discovered this was the issue, that is using Google client side API.
I also read the answer on that SO question, which says the <script> tags help get over the cross site scripting issue.
My problem :
I'm using RequireJs, so I include the files like this :
var Google = require("http://maps.google.com/maps/api/js?sensor=false");
So, how do I get my Google API working again and how do I do that with requireJS
requirejs will load the Maps-API asynchronous, but the URL you have used cannot be used for asynchronous loading(see async loading javascript with document.write) .
What to do: add the callback-parameter to the URL to be able to load the Maps-API asynchronously and execute the google-maps-related code in a function with a name equal to the value of the provided callback-parameter.
function geocodeaddr(){
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': 'Boston' }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
console.log(results[0].geometry.location);
}
else {
console.log("Geocoding failed: " + status);
}
});
}
require(["http://maps.google.com/maps/api/js?sensor=false&callback=geocodeaddr"]);
I am facing a weird issue with Google Maps Geocoding API v3. It works fine for all other addresses that i have tried so far but it's giving me an issue with the following address.
35 & 36, Rajiv Gandhi Infotech Park, Pune, 411057, India
OR
Plot No 35/36,Rajiv Gandhi Infotech Park,Phase 1,MIDC,Hinjawadi,Pune,411057,India
Even for: Rajiv Gandhi Infotech Park, Pune, 411057, India
The GeocoderStatus is ZERO_RESULTS.
Below is the code snippet.
var geocoder = new google.maps.Geocoder();
geocoder.geocode({
'address' : address
},
function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
....
}
else{...}
However, the same address is returning a valid lat/long with 'OK' status in json result at the below link.
http://maps.googleapis.com/maps/api/geocode/json?address=35&36+Rajiv+Gandhi+Infotech+Park,+Pune,+411057,+India&sensor=true
Can anyone please tell me what is the cause of this issue and its resolution?
Perhaps that particular address is recently added to Google's database.
Why do the Google Maps APIs Geocoders provide different locations than Google Maps?
The API geocoder and Google Maps geocoder sometimes use different data sets (depending on the country). The API geocoder occasionally gets updated with new data, so you can expect to see results changing or improving over time.
taken from: http://code.google.com/apis/maps/faq.html#geocoder_differences