Trevor Daniel
Trevor Daniel

Reputation: 3964

Google StreetView Different Results in Browser

I am writing a small page to display locations on Google Maps. What I was aiming at was a pushpin for each location that I can click on and it will popup with a steetview of that address.

I have got all the code working but I am getting streetviews for addresses different to the addresses I am sending.

For example.

When I search for "Edwards Buildbase, Scotland Road, Market Harborough, LE16 8AX" in a browser, Google returns a streetview right outside the premises! Perfect! Just what I wanted!

https://www.google.co.uk/maps/preview#!q=Edwards+Buildbase%2C+Scotland+Road%2C+Market+Harborough+LE16+8AX&data=!1m8!1m3!1d3!2d-0.913338!3d52.470683!2m2!1f336.21!2f90!4f75!2m7!1e1!2m2!1snk_a1aOLxAGVE10CAKadLw!2e0!5m2!1snk_a1aOLxAGVE10CAKadLw!2e0!4m15!2m14!1m13!1s0x487771173d853741%3A0x9eebe36787bc4b78!3m8!1m3!1d8924!2d-0.913338!3d52.470683!3m2!1i1280!2i705!4f13.1!4m2!3d52.470992!4d-0.913562&fid=5

But, in my code, what I do is...

Geocode the address "Edwards Buildbase, Scotland Road, Market Harborough, LE16 8AX" and then tell the steetview that the lat/longs it should go to are the results....

And I end up with different streetviews!

This is my geocode function

var address = kmlEvent.featureData.name + ", " + kmlEvent.featureData.description;
            geocoder.geocode({ 'address': address }, function (results, status) {
                var latlng = results[0].geometry.location;
                var panoramaOptions = {
                    position: latlng,
                    pov: {
                        heading: 34,
                        pitch: 10
                    }
                };

This is what I end up with when I click on Edwards Buildbase...

This is what I get

This is what I see in a browser...

enter image description here

I am guessing that because I am geocoding the address and then telling the streetview to focus on a lat/long there is a difference.

This is my demo site if you want to have a closer look at the code

http://googlemap.azurewebsites.net/

Does anyone know the best way to get the images being returned from the browser search please?

Any help would be appreciated!

Trev

Upvotes: 0

Views: 123

Answers (1)

geocodezip
geocodezip

Reputation: 161334

The address in you are geocoding is: "Edwards Buildbase, Scotland Road, Market Harborough, LE16 8AX", that returns a location for "Scotland Road, Market Harborough, Leicestershire LE16, UK" (52.4726594, -0.9118068000000221), which is not what you are looking for.

http://www.geocodezip.com/v3_example_geo2.asp?addr1=Edwards%20Buildbase,%20Scotland%20Road,%20Market%20Harborough,%20LE16%208AX&geocode=1

If you use the Places API (Edwards Buildbase is not an address, it is a place), it returns a better result (52.470992, -0.9135619999999562):

http://www.geocodezip.com/v3_example_geo2.asp?addr1=Edwards%20Buildbase,%20Scotland%20Road,%20Market%20Harborough,%20LE16%208AX&place=1&type=sat

Another option would be to use "17 Scotland Road, Market Harborough, Leicestershire LE16 8AX, UK"

http://www.geocodezip.com/v3_example_geo2.asp?addr1=17%20Scotland%20Road,%20Market%20Harborough,%20Leicestershire%20LE16%208AX,%20UK&geocode=1&type=sat

However, you would probably be better off correcting the coordinates in the KML and using those for the streetview, as both the places API and the geocoding service are subject to rate limits and a quota.

Upvotes: 1

Related Questions