google-maps-api-3

removing previous marker before adding new marker in google maps

不羁岁月 提交于 2020-01-03 11:46:40
问题 I have below code to display marker in the place that I click on map. Its working perfectly and the thing is I want to remove the previous map marker when adding new marker. Where I should make changes to work perfectly. google.maps.event.addListener(map, "click", function (e) { latLng = e.latLng; console.log(e.latLng.lat()); console.log(e.latLng.lng()); image = clientURL + "/common/images/markers/red.png"; console.log("Marker"); marker = new google.maps.Marker({ position: latLng, map: map,

Do not fire 'zoom_changed' event when calling fitBounds function on map

会有一股神秘感。 提交于 2020-01-03 07:25:29
问题 Is there a way to prevent the zoom_change event from being triggered if it occurs due to fitBounds() ? I am having an issue where I need to do a search on the server from client when there is a zoom change to map but every time I call fitBounds() it causes zoom_change to trigger which causes the client to do another search on the server. I am only interested in zoom_change done by users and not programmatically using fitBounds . 回答1: When you do a fitBounds in your program, set a global flag.

My Directions API request is Invalid, but Why?

百般思念 提交于 2020-01-03 05:52:08
问题 http://maps.googleapis.com/maps/api/directions/json?origin=Central+Hong+Kong&destination=Sai+Kung&sensor=false&mode=transit The request works fine without the mode=transit parameter, but the results only include driving directions. With the last parameter added, I get this: "status" : "INVALID_REQUEST" What can I do to make this work? There are definitively transit options available, they are listed in Google Maps. 回答1: INVALID_REQUEST indicates that the provided request was invalid. Common

Google maps set width for InfoWindow

夙愿已清 提交于 2020-01-03 05:31:06
问题 Hi I am using InfoWindow to get custom popup on google maps, but I can't set it width, I tried setting it inline to wrapper tag, but it doesn't work. In this case I need it to be 750px. Here is jsfiddle: http://jsfiddle.net/xxast/ and here is html file: http://www.mediafire.com/view/?66dbe6xzn1mul10 Here is method that is setting InfoWindow content: function getContent(parts, kmlEvent) { var content = ""+ "<div id='width800' class='google-infobox-content' >" + "<div class='image'>" + "<img

Google Map API PHP Example

断了今生、忘了曾经 提交于 2020-01-03 05:28:10
问题 I am using the creating store locator with PHP, MySQL and Google Maps example provided at https://developers.google.com/maps/articles/phpsqlsearch_v3. I am having issues getting the XML doc to write. I can run the query successful from Querious(DB app), but when attempting to run the provided script, which I modified to mysqli, things aren't working out for me. I am getting nothing returned. The DB is set up as supplied in the example. Here is the modified PHP that I use: PHP <?php require

Google maps distance based on the zoom level

懵懂的女人 提交于 2020-01-03 05:27:31
问题 I have used google maps for displaying some locations using markers, based on the user's current location. User's current location is the center point of the map. The default zoom level is 12 . In default, I displayed markers within 300 miles(approximately in my case) distance only. In that how can I do the following, 1) If decrease the zoom level, I need to increase the distance that should display markers within the increased distance also. how much distance should I increase in miles (i.e.

Reset Bounds on Google Map v3 API

情到浓时终转凉″ 提交于 2020-01-03 04:33:04
问题 This is most definitely the same question as Reset bounds on Google Maps API v3 which has no answer. I want to give a user the opportunity to change the area in which they search. I place markers of locations within the zip code (and "touching" zips). If they want to search a different zip they can enter a new zip code and we repeat the process. I follow the google-suggested way of removing markers and such, but have not yet figured out how to clear the map bounds and start all over with a

Short delay in loading google maps style

落花浮王杯 提交于 2020-01-03 03:17:38
问题 So, I use Ionic Framework to create mobile app. I use AngularJS, and Google Maps API. Recently, I came across one annoying problem. Whenever the map loads, there is a short delay (but noticeable) in loading map style. Since my map style changes the map to black-and-white, this is problematic. It is visible both when I run app in my browser, as well as in my phone. What is the best way to solve this issue? Here is my map: var styledMap = new google.maps.StyledMapType(MAP_STYLE,{name: "Styled

polyline with label in javascript

≯℡__Kan透↙ 提交于 2020-01-03 03:15:27
问题 This is my code which is used to add a polyline ,but i want to add a label on click on polyline.When i click on the polyline,it shows a label . <script> var x=new google.maps.LatLng(52.395715,4.888916); var stavanger=new google.maps.LatLng(58.983991,5.734863); var amsterdam=new google.maps.LatLng(52.395715,4.888916); var london=new google.maps.LatLng(51.508742,-0.120850); function initialize() { var mapProp = { center:x, zoom:4, mapTypeId:google.maps.MapTypeId.ROADMAP }; var map=new google

Adding time delay to google map geocode

与世无争的帅哥 提交于 2020-01-03 03:04:12
问题 I'm working on this map and trying to geocode around 150 markers but I'm hitting the geocode limit. How can I add a time delay to avoid hitting the limit? 回答1: This adds a timer to the geocoding so each marker has a delay. // Adding a LatLng object for each city function geocodeAddress(i) { geocoder.geocode( {'address': address[i]}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { places[i] = results[0].geometry.location; // Adding the markers var marker = new google