WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Directions to: current Google latitude Location

[Resolved] Directions to: current Google latitude Location

Viewing 15 replies - 1 through 15 (of 23 total)
  • indeed this would also solve my problem.

    any progress on this? i got the feeling the this plugin support dies out…
    i am looking into this gps thing myself maybe i can get the code from another script to build it into this one. i i succeed ill post the package here.

    i made some progress this morning.

    using:

    Google Maps V3 and Geolocation

    simply added the code for geo to the js scripts in assets.

    now in google and safari and on mobile it says do you allow the app …. to use your location.

    so far so good. next stop getting de marker to appear at the map and zoom in… its difficult for me cause i dont have the exp with js.

    so its a lot of cut and past.

    so far i used from what i found in the link at the bottom of the 2 framework files then it calls the gps from site / mobile device….

    i think i need to search elsewhere to make it call a marker in the map anybody with js exp can take a look ?

    This is a good start… when I have time I’ll see what I can do!

    according to sites the javascript should be from google so i added that js code to my javascript files.

    this kinda code :

    <script>
     // Load the map scripts
     google.load('maps', '3', {other_params:'sensor=true'});
    
     // Function to create a map and check for geolocation
     function mapInit() {
    
     // Set the options to be used when creating the map
     var myOptions = {
     zoom: 0,
     center: new google.maps.LatLng(0, 0),
     mapTypeId: google.maps.MapTypeId.ROADMAP
    // Check if the browser supports geolocation
     if(navigator.geolocation) {
    
     navigator.geolocation.getCurrentPosition(currentPositionCallback);
    
     } else {
    
     alert('The browser does not support geolocation');
    
     }
    
     }
    
     function currentPositionCallback(position) {
    
     // Create a new latlng based on the latitude and longitude from the user's position
     var user_lat_long = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
    
     // Add a marker using the user_lat_long position
     var marker = new google.maps.Marker({
     position: user_lat_long,
     map: map
     });
    
     // Set the center of the map to the user's position and zomm into a more detailed level
     map.setCenter(user_lat_long);
     map.setZoom(15);
    
     }
    
     google.setOnLoadCallback(mapInit);
    
    </script>

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    is for html documents.but to make it work in the plugin it needs to be added to another file (like html would be added) i tried the php files but no good so far. also in assets / html some files still trying to get it to work do.

    ok for anybody who wants to know or get to my pint of procces on this thing.

    i got the navigation to go but im stuck at displaying the marker on the map.

    go to asstes/js and open cgmp.framework.min.js
    at the bottom of the js add the following code.

    // Check if user support geo-location
    if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
    var latitude = position.coords.latitude;
    var longitude = position.coords.longitude;
    var geolocpoint = new google.maps.LatLng(latitude, longitude);

    var mapOptions = {
    zoom: 8,
    center: geolocpoint,
    mapTypeId: google.maps.MapTypeId.HYBRID
    }
    // Place a marker
    var geolocation = new google.maps.Marker({
    position: geolocpoint,
    map: map,
    title: ‘Your geolocation’,
    icon: ‘http://labs.google.com/ridefinder/images/mm_20_green.png’
    });
    });
    }

    where the following code (last part of it should get a marker on screen at your location.. however its not wich means that getting the markers on the map comes from somewhere else.

    // Place a marker
    var geolocation = new google.maps.Marker({
    position: geolocpoint,
    map: map,
    title: ‘Your geolocation’,
    icon: ‘http://labs.google.com/ridefinder/images/mm_20_green.png’
    });
    });
    }`

    the first part of the code however activates the gps for maps

    but even then we need t put this plugin to load https://maps.googleapis.com/maps/api/js?v=3&sensor=true thats need for the marker to work.

    ok im stuck at this. i tweeted the plugin creator Alexander Zagniotov to ask him for an update with geolocation.

    Just found this how-to, but haven’t had time to test it out.
    looks like a possible solution to our problem/request.

    Google Latitude Mashup with Google Maps:
    http://bestfromgoogle.blogspot.com/2011/05/google-latitude-mashup-with-google-maps.html?m=1

    I’m still actively sourcing a solution so if anyone finds a fix please let us know, thx!

    il look into the link you posted. see if we can make it work. ill let you now.

    i got a script build up.

    its fully no errors should work but its not showing geolocation and the marker on the spot. maybe you guys can take a look.

    http://pastebin.com/xYt55sTA

    i think where nearly there we just need somebody with js experience to alter this script and then i believe it will work.

    sorry made an error below is the correct code.

    the scripts load the page but its terribly slow. ill see if i can get somebody with the js exp to look at it.

    http://pastebin.com/GvZDPFPT

    finnaly some progress.

    it shows a bubble with the text found your location in firefox.

    (using a fake location)

    so far

    http://pastebin.com/vFjZTutj

    here is the working script for anybody to try or upgrade. more help with this is appreciated.

    after map.setCenter(pos); add map.setZoom(18); to zoom on location when location is found.

    map.setCenter(pos);
    map.setZoom(18);

    so geolocation is working next up is a marker and the directions fill. (so point 1 auto fills with location)

    your welcome so far.

    and btw you can easy moddify the tekst from the balloon by edditing the content: ‘Hier bent U’ in
    var infowindow = new google.maps.InfoWindow({
    map: map,
    position: pos,
    content: ‘Hier bent U’
    });

    quick summary:

    copy the code from http://pastebin.com/vFjZTutj and add it to your cgmp.framework.min.js (make sure its the min one) (overwritte the entire page with the code from pastebin) the save.

    you can find the file in the assets folder then js.

    geolocation should now work.

    to zoom in after geo is found:
    after map.setCenter(pos); add map.setZoom(18); to zoom on location when location is found.

    map.setCenter(pos);
    map.setZoom(18);

    to change the geoballoon text.
    edit the content: ”Location found using HTML5′ in
    var infowindow = new google.maps.InfoWindow({
    map: map,
    position: pos,
    content: ”Location found using HTML5′
    });

Viewing 15 replies - 1 through 15 (of 23 total)
  • The topic ‘[Resolved] Directions to: current Google latitude Location’ is closed to new replies.