google-maps-api-3

Retrieving JSON throws error: Unexpected token :

最后都变了- 提交于 2020-01-05 03:33:08
问题 I'm retrieving the elevation data from the Google Maps API by AJAX. I'm getting the data back I want as if I look at the console in Chrome I can see a 200 status code and can see the data in the response tab. But is throws up 'Uncaught SyntaxError: Unexpected token :' so I can't display anything from the JSON file. This is my code: var theURL = 'http://maps.googleapis.com/maps/api/elevation/json?locations=' + longitude + ',' + latitude + '&sensor=false&callback=?'; $.ajax({ url: theURL, type:

Clear Polyline from Google Maps and then restart it

时间秒杀一切 提交于 2020-01-05 02:14:10
问题 I am playing around with the Google Maps API v3 for a project I am building.The premise is the user can draw a route on the map however at any point can clear it and start again. The issue I am having is restarting the polyline after the map has been cleared. Whilst the markers appear the polyline does not. I have discovered that the line poly.setMap(null); only hides the polyline that is draw and doesn't clear it therefore it is understandable why the line doesn't show. However on finding

Get property from geojson inside polygon using google maps js

僤鯓⒐⒋嵵緔 提交于 2020-01-05 00:50:54
问题 How can I access property of geojson data inside drawn polygon?I have this example: var map; function initMap() { map = new google.maps.Map(document.getElementById('map'), { zoom: 4, center: {lat: -28, lng: 137} }); // Load GeoJSON. map.data.loadGeoJson('https://storage.googleapis.com/mapsdevsite/json/google.json'); // Set the stroke width, and fill color for each polygon map.data.setStyle({ fillColor: 'green', strokeWeight: 1 }); var drawingManager = new google.maps.drawing.DrawingManager({

trying to get location from address using google api v3

 ̄綄美尐妖づ 提交于 2020-01-04 14:13:46
问题 I have this javascript in my html what i want to do here is to get a map representation given the location <script type="text/javascript"> var geocoder; var map; function getmaploc() { geocoder = new google.maps.Geocoder(); var myOptions = { zoom: 8, mapTypeId: google.maps.MapTypeId.ROADMAP }; geocoder.geocode( 'cairo', function(results, status) { if (status == google.maps.GeocoderStatus.OK) { map.setCenter(results[0].geometry.location); var marker = new google.maps.Marker({ map: map,

trying to get location from address using google api v3

心不动则不痛 提交于 2020-01-04 14:12:47
问题 I have this javascript in my html what i want to do here is to get a map representation given the location <script type="text/javascript"> var geocoder; var map; function getmaploc() { geocoder = new google.maps.Geocoder(); var myOptions = { zoom: 8, mapTypeId: google.maps.MapTypeId.ROADMAP }; geocoder.geocode( 'cairo', function(results, status) { if (status == google.maps.GeocoderStatus.OK) { map.setCenter(results[0].geometry.location); var marker = new google.maps.Marker({ map: map,

How to get the width of a road through Google Maps API

。_饼干妹妹 提交于 2020-01-04 14:02:29
问题 I need to find the width of roads in Google Maps. Google Earth can't be used as it doesn't support Linux. Streetviews cannot be used, since it is not available in the area I live. This link: http://osdir.com/ml/google-maps-js-api-v3/2011-05/msg00666.html suggests the method of finding the distance between the two ends of the road by knowing the coordinates of both sides. Therefore the first question is as in title. BTW, I have managed to display the "route" between the two coordinates already

Access-Control-Allow-Origin using Google Maps JavaScript API v3

ⅰ亾dé卋堺 提交于 2020-01-04 13:39:40
问题 I am currently writing a web application using Google Maps JavaScript API v3 (jobadvisor.scriptonite.be)(DUTCH). The application is online for a couple of months now and everything was working just fine. But then at the start of this month, I started adjusting my source code in local host. After a week I updated everything on my localhost an left it there. So, FTR: I currently have my old application on an online host My updated application on my localhost Then 2 weeks went by, but now, when

Google maps api v3 reporting key error

天大地大妈咪最大 提交于 2020-01-04 13:07:28
问题 I've been running a site to give directions for wedding guests to find hotels and B&B's in the area local to our reception. No issues with the API for a few months, did my homeowrk and the code is solid and working without issue. Logged in this evening and I'm getting an invalid key error. I've done the following: Checked that I've not exceeded the 'grace' limits of 25.000 requests per day. In fact the wedding isn't until later this year, there have been a grand total of 124 requests since

Showing Google Maps Marker infoname on Mouseover of a Dynamically Generated DIV

痴心易碎 提交于 2020-01-04 13:07:27
问题 I want to introduce a functionality which allows a marker's infoname to appear or disappear upon mouseover or mouseout of a corresponding DIV element generated from jQuery. However, I am getting a " a is undefined " error on line 19 of main.js. After extensive testing on my script, I realise that this has something to do with the marker in the newly added lines as commented below: function addMarker(A) { var point = new google.maps.LatLng(A.lat, A.lng); var image = new google.maps.MarkerImage

Causing links to pan to and open markers in map

拜拜、爱过 提交于 2020-01-04 09:05:24
问题 JS Fiddle: http://jsfiddle.net/megatimes/NVDLf/7/ I have a map which is creating multiple markers from an array. Below the map are some links which, when clicked, I'd like to cause the map to pan to its respective marker, and open the info window. Given that I don't want to generate the links themselves as part of the loop that creates the markers, how can I do this? I'm fairly certain this is a scope issue since the links below the map each open the last item in the locations array but I can