Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
madiha
Posts: 107
Registered: ‎05-26-2011
My Device: Torch
My Carrier: Mobilink

cant drag Google Map on non touch device 9780(os-6)

$(document).ready(function() {
        if (navigator.geolocation) {
    
            initializeMap('{enableHighAccuracy : true}');

        }
    });
function initializeMap(params) {
        try {
            var options;
            if (navigator.geolocation) {
                options = eval("options = " + params + ";");

                navigator.geolocation.getCurrentPosition(initialize,
                        geolocationError, options);

                alert('fff');
            }
        } catch (err) {
            alert('Could not subscribe to scroll events. Error: '
                    + err.description);
        }
    }
function initialize(position) { //alert('gsdsdf' + position); var centLoc; var centLoc; if (position == 1 || position == 2) { centLoc = new google.maps.LatLng(29.327767, 47.980817); } else { centLoc = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); } alert('fdfdf'); var mapOptions = { center : centLoc, zoom : 17, mapTypeId : google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); var marker1 = new google.maps.Marker({ map : map, position : centLoc }); var input = document.getElementById('searchTextField'); var autocomplete = new google.maps.places.Autocomplete(input); autocomplete.bindTo('bounds', map); var infowindow = new google.maps.InfoWindow(); var marker = new google.maps.Marker({ map : map }); google.maps.event .addListener( autocomplete, 'place_changed', function() { infowindow.close(); marker.setVisible(true); input.className = ''; var place = autocomplete.getPlace(); if (!place.geometry) { // Inform the user that the place was not found and return. input.className = 'notfound'; return; } // If the place has a geometry, then present it on a map. if (place.geometry.viewport) { map.fitBounds(place.geometry.viewport); } else { map.setCenter(place.geometry.location); map.setZoom(17); // Why 17? Because it looks good. } var image = new google.maps.MarkerImage(place.icon, new google.maps.Size(71, 71), new google.maps.Point(0, 0), new google.maps.Point(17, 34), new google.maps.Size(35, 35)); marker.setIcon(image); marker.setPosition(place.geometry.location); var address = ''; if (place.address_components) { address = [ (place.address_components[0] && place.address_components[0].short_name || ''), (place.address_components[1] && place.address_components[1].short_name || ''), (place.address_components[2] && place.address_components[2].short_name || '') ] .join(' '); } infowindow.setContent('<div><strong>' + place.name + '</strong><br>' + address); infowindow.open(map, marker); }); function setupClickListener(id, types) { var radioButton = document.getElementById(id); google.maps.event.addDomListener(radioButton, 'click', function() { autocomplete.setTypes(types); }); } setupClickListener('changetype-all', []); setupClickListener('changetype-establishment', [ 'establishment' ]); setupClickListener('changetype-geocode', [ 'geocode' ]); // loadGeocodes(); } function geolocationError(error) { alert("An unexpected error occurred [" + error.code + "]: " + error.message); }

...css style
#map-canvas {
    height: 100%;
    width: 100%;
 }

 

I have added google maps in my app thru above code

It works fine ...map loads  and also i can drag it  on touch devices

but on non touch devices (i tried on 9780) moving the cursor along the screen doesnot drag the map it seems to be freezd.

 any help will be appreciated...

Please use plain text.