facebook

Current location – inforwindow pop up

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #332299 Reply

    Visal Veng
    Member

    Hi guys,

    So iv managed to get my current location running with marker etc.. but how do I get the infor window to pop up with the street address like google map??

    cheers

    vee

    #332316

    Hi Visal,

    Please see this example on our Map Developers Guide:
    https://www.genuitec.com/mobile/docs/usingMaps/usingMaps.html#add_markers

    #332332

    Visal Veng
    Member

    Thanks octavio

    So iv got my current location working & when i tap the marker it pops up with window but it only says “Position 1 info”…?? no adress details

    here is my custom.js so far:

    function showLocation(gmap, pos) {
    gmap.setCenter(pos);

    //add marker

    var marker = new google.maps.Marker({
    position: pos,
    map: gmap,
    animation: google.maps.Animation.DROP,
    title: “Current Location”,
    clickable: true
    });
    var infowindow1 = new google.maps.InfoWindow({
    content: “Position 1 info”
    });
    google.maps.event.addListener(marker, ‘click’, function() {
    infowindow1.open(gmap,marker);
    });

    }

    in title area im i suppost to add a line of code so it will show my location address etc..?

    sorry if this sounds stupid. im new to code

    cheers

    vee

    #332360

    Hi Visal,

    Next Google Maps Javascript API Doc should be helpful for you: https://developers.google.com/maps/documentation/javascript/geocoding#ReverseGeocoding

    #332376

    Visal Veng
    Member

    thanks octavio,

    here is my custom.js so far:

    * Called when document is loaded.
    */
    phoneui.documentReadyHandler = function() {
    var init = function() {
    $(‘[id$=map1]’).gmapready(function(gmap) {
    navigator.geolocation.getCurrentPosition(
    function(geoPosition) {
    var mapPos = new google.maps.LatLng(geoPosition.coords.latitude,
    geoPosition.coords.longitude);
    showLocation(gmap,mapPos)
    },
    function() {
    alert(‘Unable to find current position’);
    });
    });
    };

    if (“PhoneGap” in window) {
    document.addEventListener(“deviceready”, init, false);
    } else {
    init();
    }
    }

    function showLocation(gmap, pos) {
    gmap.setCenter(pos);

    //add marker
    var marker = new google.maps.Marker({
    position: pos,
    map: gmap,
    zoom: 10,
    animation: google.maps.Animation.DROP,
    title: “Current Location”,
    clickable: true
    });

    var geocoder;
    var map;
    var infowindow = new google.maps.InfoWindow();
    var marker;
    function initialize() {
    geocoder = new google.maps.Geocoder();
    var latlng = new google.maps.LatLng(geoPosition.coords.latitude,
    geoPosition.coords.longitude);
    var mapOptions = {
    zoom: 8,
    center: latlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    map = new google.maps.Map(document.getElementById(“map_canvas”), mapOptions);
    }

    function codeLatLng() {
    var input = document.getElementById(“latlng”).value;
    var latlngStr = input.split(“,”,2);
    var lat = parseFloat(latlngStr[0]);
    var lng = parseFloat(latlngStr[1]);
    var latlng = new google.maps.LatLng(lat, lng);
    geocoder.geocode({‘latLng’: latlng}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
    if (results[1]) {
    map.setZoom(11);
    marker = new google.maps.Marker({
    position: latlng,
    map: gmap
    });
    infowindow.setContent(results[1].formatted_address);
    infowindow.open(map, marker);
    }
    } else {
    alert(“Geocoder failed due to: ” + status);
    }
    });
    }​

    Im not getting anything, what am i doing wrong?

    cheers

    vee

    #332524

    Hi Visal,

    I’ve reviewed your code, it seems that you did a copy/paste and as you see, the result is a nogo. Will coordinate with Wayne to help you on this request.

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: Current location – inforwindow pop up

You must be logged in to post in the forum log in