logo
down
shadow

Map isn't centered on on the coordinates, Google Maps Javascript API V3


Map isn't centered on on the coordinates, Google Maps Javascript API V3

By : user2955183
Date : November 22 2020, 10:38 AM
I hope this helps . I'm trying to make my first app/test on Intel XDK and start with a simple maps app. My problem is when I try to center my map with the coords. The coordinates appear on right-top instead of center. My code: , The following code should work.
HTML
code :
<div id="canvas" style="height:300px;"></div>
var map;
function initialize() {
    var mapOptions = {
       center: new google.maps.LatLng(-19.838491, -44.606999),
       zoom: 14,
       mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById('canvas'), mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);


Share : facebook icon twitter icon
how to get coordinates of the center of the viewed area in google maps using Google Maps JavaScript API v3

how to get coordinates of the center of the viewed area in google maps using Google Maps JavaScript API v3


By : chain85
Date : March 29 2020, 07:55 AM
hop of those help? How to get coordinates using javascript Google Maps JavaScript API v3 of the center of the currently viewed area on google maps? , You can call:
code :
map.getCenter();
How to get the lat/long coordinates of an X mile radius centered at a point via Google maps geolocation or otherwise?

How to get the lat/long coordinates of an X mile radius centered at a point via Google maps geolocation or otherwise?


By : Hacer Doğan
Date : March 29 2020, 07:55 AM
wish helps you Almost the same as what @Skidrow wrote before but in php. Php could be better if you want to check the result you already loaded else you have to iterate all the post in mysql. If that case the mysql version would be better
code :
function calculateDistance($targetLat, $targetLng, $againstLat, $againstLng, $units = 'miles')
{
    $result = 3958.75 * acos(
        sin($targetLat / 57.2958) * sin($againstLat / 57.2958) +
            cos($targetLat / 57.2958) * cos($againstLat / 57.2958) *
                cos($againstLng / 57.2958 - $targetLng / 57.2958)
    );

    switch ($units)
    {
        default:
        case "":
        case "miles":
            $result *= 1;
            break;
    }

    return $result;
}
Google Maps, set the center coordinates to be off centered in the container

Google Maps, set the center coordinates to be off centered in the container


By : Felice Lombardi
Date : March 29 2020, 07:55 AM
Any of those help If you take a look at the Google Maps API you'll see several methods for the Map element.
Using a script like this (not tested) :
code :
var ne = map.getBounds().getNorthEast();
var sw = map.getBounds().getSouthWest();

var lat = sw.lat() + 0.5*(ne.lat() - sw.lat());
var long = sw.lng() + 0.25*(ne.lng() - sw.lng());

map.setCenter(new google.maps.LatLng(lat,long));
GPS coordinates on Google maps with JavaScript

GPS coordinates on Google maps with JavaScript


By : lalopmak
Date : March 29 2020, 07:55 AM
it helps some times You have to request gps url before calling Google Maps API.For example, if jquery is there :
code :
$.get( "http://10.10.10.222/server/latitude.cgi", function( latitude ) {
    $.get( "http://10.10.10.222/server/longitude.cgi", function( longitude ) {

        var map = new google.maps.Map(map_canvas, map_options);
        var point = new google.maps.LatLng(latitude, longitude);
        var marker = new google.maps.Marker({
            position: point,
            map: map,
            icon: 'PointMarkerON.png',
            title: 'Site 1'
        });
    }); 
});
How to search Google Maps centered around coordinates?

How to search Google Maps centered around coordinates?


By : user2978169
Date : March 29 2020, 07:55 AM
I wish this helpful for you Probably you need Place Search , specifically Nearby Search requests:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=1500&type=restaurant&keyword=cruise&key=YOUR_API_KEY
Related Posts Related Posts :
  • clearvalidators not working in angular 6 form control
  • Remove Count Attribute in json data
  • queue up function callbacks
  • How to stop all Soundcloud streams in once?
  • Sliding div onclick left/right
  • RequireJS JQuery shim doesnt work with VS2013
  • What is the Meteor concurrency model?
  • Events on children of contenteditable element
  • Simple jquery not working to print the input value
  • Javascript templating language in reverse
  • Making Pagination in Javascript Scalable (for large # of db results)
  • Performance of Stateless Authentication in SPA and SSO (Single Sign On)
  • Assigning a value for view asynchronously
  • Mocha JS: How to reuse assertions within a spec?
  • Is ember.js stable enough to use in a real world project?
  • jQuery Load() not loading within div
  • encode stream from webCam h264
  • Regex to find pattern, return subpattern
  • Why does this regex to remove empty <p></p> tags from a string fail?
  • Rails: pass data to javascript
  • Quickest way to check if a number is in a set?
  • Phonegap events online/offline not working
  • In HTML5, please explain the meaning of '?' in the statement
  • Form to use AJAX rather than a page refresh but also utilise error handling?
  • JQuery Script looping error
  • different size divs align top left
  • Image fade-in when webpage finishes loading
  • Seeking HTML5 audio element causes delay (breaks sync)
  • How can I read & write data to a new tab in Firefox?
  • jQuery or JS turn all words into italic type
  • iOS css -webkit-transform: scale doesn't offset touch events
  • Populate select list using javascript
  • Can you work out why my .js file doesn't seem to be linking to my html?
  • Make slideToggle effect only one element at a time
  • Output sound using JavaScript
  • What is the analytics.js equivalent of _trackPageview found in ga.js
  • How can I check if a JS file has been included already?
  • hasClass and condition not working
  • EDITED: I'm having issues with a button and its function
  • Importing XML in HTML with javascript
  • Create new function in contentScriptFile in Firefox extension
  • Should I build Node.js from source or download the OS X installer?
  • How to enforce integer sizes in JS? (TypeScript?)
  • How to update the JSON object without deleting old values using javascript
  • Reading a javascript variable containing a string into another file
  • Possible to prevent 403 errors from logging to the web console?
  • Jquery Accordion - Expand and collapse div on hover
  • jquery .hide() function - Hide mobile, Display Desktop
  • Holding password in javascript variable - security implications?
  • JQPlot trouble to render vertical stacked bar and horizontal legend
  • counts days inbetween then add class to those days with nested divs?
  • Marionette.js with Rails (Devise) Authentication
  • javascript anonymous function evaluation idiom
  • Why am I losing the decimal when working this equation in Javascript?
  • Site redirects to index.php after being open while making calls to an API using AJAX
  • How to determine when multiple callbacks are all done
  • How to update Yeoman dependencies?
  • How can I do a /resolve with the Soundcloud Javascript SDK?
  • I'm not able to call a named callback function
  • How to get value of Paragraph element contained in <div> in HTML using JavaScript
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org