logo
down
shadow

google map geocoding longlat


google map geocoding longlat

By : Zeizei
Date : November 16 2020, 06:23 AM
will be helpful for those in need Use google.maps.LatLngBounds. Add all the marker positions to it, then call google.maps.Map.fitBounds on the result.
code :
$(document).ready(function () {
    var map;
    var elevator;
    var myOptions = {
        zoom: 2,
        center: new google.maps.LatLng(0, 0),
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map($('#map_canvas')[0], myOptions);

    var addresses = [
        ['4355 Ashford Dunwoody Road NE, Atlanta, GA 30346, US'],
        ['313 North Highland Ave NE, Atlanta, GA 30307'],
        ['1989 Cheshire Bridge Road, Atlanta, GA 30324, US'],
        ['1210 Howell Mill Rd NW, Atlanta, GA 30318, US']
    ];
    var bounds = new google.maps.LatLngBounds();
    for (var x = 0; x < addresses.length; x++) {
        $.getJSON('http://maps.googleapis.com/maps/api/geocode/json?address=' + addresses[x] + '&sensor=false', null, function (data) {
            var p = data.results[0].geometry.location;
            var latlng = new google.maps.LatLng(p.lat, p.lng);
            bounds.extend(latlng);
            new google.maps.Marker({
                position: latlng,
                map: map
            });
            map.fitBounds(bounds);
        });
    }

});
$(document).ready(function () {
    var map;
    var elevator;
    var myOptions = {
        zoom: 2,
        center: new google.maps.LatLng(0, 0),
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map($('#map_canvas')[0], myOptions);

    var addresses = [
        ['4355 Ashford Dunwoody Road NE, Atlanta, GA 30346, US'],
        ['313 North Highland Ave NE, Atlanta, GA 30307'],
        ['1989 Cheshire Bridge Road, Atlanta, GA 30324, US'],
        ['1210 Howell Mill Rd NW, Atlanta, GA 30318, US']
    ];
    var bounds = new google.maps.LatLngBounds();
    for (var x = 0; x < addresses.length; x++) {
        $.getJSON('http://maps.googleapis.com/maps/api/geocode/json?address=' + addresses[x] + '&sensor=false', null, function (data) {
            var p = data.results[0].geometry.location;
            var latlng = new google.maps.LatLng(p.lat, p.lng);
            bounds.extend(latlng);
            new google.maps.Marker({
                position: latlng,
                map: map
            });
            map.fitBounds(bounds);
        });
    }

});
html, body, #map_canvas {
    width:100%;
    height:100%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://maps.google.com/maps/api/js"></script>
<div id="map_canvas"></div>


Share : facebook icon twitter icon
Google geocoding: Place Id are different when geocoding business/company name and address

Google geocoding: Place Id are different when geocoding business/company name and address


By : Neptun
Date : March 29 2020, 07:55 AM
Hope this helps Use nearbySearch on the location.
code :
var service = new google.maps.places.PlacesService(map);
var radius = 100;
service.nearbySearch({
  location: new google.maps.LatLng(55.93366899999999, 12.258698299999992),
  radius: radius,
  type: "store"
}, callback);
var infowindow;
var map;

function initialize() {
  map = new google.maps.Map(
    document.getElementById("map_canvas"), {
      center: new google.maps.LatLng(55.93366899999999, 12.258698299999992),
      zoom: 13,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });
  infowindow = new google.maps.InfoWindow();
  var service = new google.maps.places.PlacesService(map);
  var radius = 100;
  var circle = new google.maps.Circle({
    map: map,
    center: map.getCenter(),
    radius: radius
  });
  map.fitBounds(circle.getBounds());
  service.nearbySearch({
    location: map.getCenter(),
    radius: radius,
    type: "store"
  }, callback);
}

function callback(results, status) {
  if (status === google.maps.places.PlacesServiceStatus.OK) {
    console.log(results.length + " results");
    for (var i = 0; i < results.length; i++) {
      createMarker(results[i]);
    }
  } else console.log("status=" + status);
}

function createMarker(place) {
  var placeLoc = place.geometry.location;
  var marker = new google.maps.Marker({
    map: map,
    position: place.geometry.location
  });

  google.maps.event.addListener(marker, 'click', function() {
    infowindow.setContent(place.name + "<br>placeId:" + place.place_id);
    infowindow.open(map, this);
  });
  google.maps.event.trigger(marker, 'click');
}


google.maps.event.addDomListener(window, "load", initialize);
html,
body,
#map_canvas {
  height: 100%;
  width: 100%;
  margin: 0px;
  padding: 0px
}
<script src="https://maps.googleapis.com/maps/api/js?libraries=places"></script>
<div id="map_canvas"></div>
Geocoding a React state property using Google Maps Geocoding API

Geocoding a React state property using Google Maps Geocoding API


By : Christoph X Dohrmann
Date : March 29 2020, 07:55 AM
should help you out Edit--- scratch that...
You need to wait until you have set a value for this.state.location before you can initialize this.state.address
code :
fetchApi(url) {
    fetch(url)
      .then((res) => res.json())
      .then((data) => {
        this.setState({
          avatar: data.avatar_url,
          username: data.login,
          realName: data.name,
          location: data.location,
          followers: data.followers,
          following: data.following,
          repos: data.public_repos,
          address: [your function from the constructor])
        }
      });
  }
Google Maps - Pass map id and marker longlat to a hidden input element

Google Maps - Pass map id and marker longlat to a hidden input element


By : John Bigelow
Date : March 29 2020, 07:55 AM
With these it helps Upon checking your code and analyzing what you are trying to achieve, I found out that there's a better way to implement it. Instead of creating a new hidden input on every click, let's just store the coordinates and mapId in an array. Btw, the reason you are having this undefined is because the id you are referencing is a non-existing property.
For example, you have 3 maps on your page, the ids are: map1, map2, and map3.
code :
var marker = [];
var coords = [];
  function currentMap(mapObject, mapId) {
    mapObject.addListener('click', function(e){
        var marker = new google.maps.Marker({
            position: e.latLng,
            map: mapObject
        });    
      coords.push({
        mapId: mapId,
        lat: e.latLng.lat(),
        lng: e.latLng.lng()
      });
      //console.log(coords);
    });
  }
{
 lat:-27.059125784374057
 lng:122.080078125
 mapId:"map1"
}
  function initMap() {
    var myLatLng = {lat: -25.363, lng: 131.044};
    for ( var i = 1; i <= 3; i++ ) {
      map[i] = new google.maps.Map(document.getElementById('map'+i), {
        zoom: 4,
        center: myLatLng
      }); 
      currentMap(map[i], 'map'+i);
    } 
  }
      // Note: This example requires that you consent to location sharing when
      // prompted by your browser. If you see the error "The Geolocation service
      // failed.", it means you probably did not give permission for the browser to
      // locate you.
      var map = [];
      var marker = [];
      var coords = [];
      function initMap() {
        var myLatLng = {lat: -25.363, lng: 131.044};
        for ( var i = 1; i <= 3; i++ ) {
          map[i] = new google.maps.Map(document.getElementById('map'+i), {
            zoom: 4,
            center: myLatLng
          }); 
          currentMap(map[i], 'map'+i);
        } 
      }
      function currentMap(mapObject, mapId) {
        mapObject.addListener('click', function(e){
            var marker = new google.maps.Marker({
                position: e.latLng,
                map: mapObject
            });    
          coords.push({
            mapId: mapId,
            lat: e.latLng.lat(),
            lng: e.latLng.lng()
          });
          //console.log(coords);
        });
      }
      /* Always set the map height explicitly to define the size of the div
       * element that contains the map. */
      .map {
        height: 200px;
        padding:10px 0;
        display:block;
        margin:10px 0;
        width:100%;
        float:left;
        overflow:hidden;
      }
      /* Optional: Makes the sample page fill the window. */
      html, body {
        height: 100%;
        margin: 0;
        padding: 0;
      }
    <div id="map1" class="map"></div>
    <div id="map2" class="map"></div>
    <div id="map3" class="map"></div>
    <script async defer
    src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCzjs-bUR6iIl8yGLr60p6-zbdFtRpuXTQ&callback=initMap">
    </script>
Can I force Google geocoding API to include the postcode on geocoding request?

Can I force Google geocoding API to include the postcode on geocoding request?


By : Chase.Turner
Date : March 29 2020, 07:55 AM
will help you In example that you provided, request https://maps.googleapis.com/maps/api/geocode/json?address=New%20York%2C%20USA&key=YOUR_API_KEY returns a feature of type locality (place ID ChIJOwg_06VPwokRYv534QaPC8g).
Note that this feature refers to entire city, not to the position of the center of the city.
How to perform Batch Geocoding on google or some other geocoding service provider?

How to perform Batch Geocoding on google or some other geocoding service provider?


By : user3909944
Date : March 29 2020, 07:55 AM
will help you Probably BatchGeo.com will help you out, it's based on the Google Maps API but you can choose to use Yahoo's geocoding service too. BatchGeo does a very decent job. Otherwise there are quite a few (commercial) API based solutions like http://maplarge.com/geocoder
Check out the wikipedia page on geocoding, it has a pretty comprehensive list.
Related Posts Related Posts :
  • TableTools plugin export buttons are not working
  • Prepopulate jquery token input textbox
  • Open a fancybox link with ajax
  • Getting jQuery and AngularJS content assist / auto-complete in eclipse for standalone HTML "file"
  • TR alternate background colour with unequal number of TD
  • DATATABLE jQuery TH and TD alignment
  • Jquery UI Convert Select's to Range Slider
  • Change text in text field according to link that has been clicked
  • Animate addClass + removeClass transitions?
  • knockout ajax call data-BIND
  • How do I create a variable with a number based on an element's number position using jquery?
  • Prevent fixed position element from flickering during jQuery animation
  • points are not visible clearly in nvd3 ghaph
  • How to write a regular expression for IP address format
  • Animate 3 DIVs from right to left when page is loading.
  • How to pivot columns in free jqgrid 4.15.4
  • the jquery method works fine but when made as a function not working
  • Show/hide text doesn't work when targeting link within div
  • multiple autocomplete search input fields
  • Display image in cell using Jquery jTable
  • jQuery and Wordpress - Scripts not working
  • flickering when mouse over, .hover() show/hide div(s)
  • Using Django's JSONResponseMixin to respond to AJAX requests
  • Unable to render charts using Wicked PDF
  • Style to dynamically created elements
  • hover not working for items in list
  • Keep server session alive automatically based on activity / input, using JQuery
  • jQuery load() taking a long time
  • Change / Exchange values in textboxes on text change in jquery
  • Unslider arrow code overriding slider options
  • what is the traditional way of sorting search results?
  • Do the action when the DIV comes in the display area of the browser with jQuery
  • jQuery slideshow overlapping CSS ribbon
  • JQuery animate function dont work
  • problems charts jquery highcharts
  • How to reset the select box values in Jquery sumoselect Multi select plugin
  • css absolute position on top of another element
  • How use jQuery String variable in html body
  • Get a row from table in view on modal bootstrap using codeigniter
  • How to make the effect of a div that covers an other div when scrolling?
  • Data binding using a button
  • How do i replace all dot in string to Underscore?
  • grab non-sibling element with jquery
  • Select a word and click it
  • Trigger modal instead redirect to /users/sign_in path, Rails 4 with devise
  • Combining Parent theme JS and CSS
  • Angular ui-grid - DropDown Selection shows Id
  • jquery addclass when there is content on body
  • JQUERY : CSS does not apply to dynamically created elements
  • Bootstrap multiselect dropdown checkbox not working on paginated table
  • JQuery scroll to dynamic id
  • Jquery first time tried ajax
  • Disable the link on the active tab (Bootstrap)
  • How to handle this validation when a div is added?
  • how to show/hide and check/uncheck checkboxes dynamically inside kendo grid
  • Conditional parameters for AJAX function
  • Jquery add class to input checkbox field
  • Bootstrap countdown timer Jquery
  • Open the closest modal of jQuery clicked element
  • change background color of specific button on click
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org