Software Archive
Read-only legacy content
17061 Discussions

Google Maps Widget

Andrejs_V_
Beginner
228 Views

Hi, All!

Is any tutorials for correct marker adding/modifying in Google Map widget?

I create 2 buttons in test projects

1 button for geolocation (I set up geolocation plug-in & and he is work ok)

2. set up new location 

it's also ok

 

But when I try add marker(s) nothing happenns :(

============================

google maps API key is and work ok

that's is my code for button1 & button2 

 var longit=40.000;
 var latit=-100.000;
     
    
     
     /* button  My Location */
    $(document).on("click", ".uib_w_11", function(evt)
    {
        /* your code goes here */ 
        
           navigator.geolocation.getCurrentPosition(function(position){
                longit=position.coords.latitude;
                latit=position.coords.longitude;
                alert('Latitude: '          + position.coords.latitude          + '\n' +
                      'Longitude: '         + position.coords.longitude                              
                     )});
        
              
         return false;
    });
     
    
        /* button  Button */
    $(document).on("click", ".uib_w_12", function(evt)
    {
        /* your code goes here */ 
        
         var myLatlng = new google.maps.LatLng(longit,latit);
         var mapOptions = {
                        zoom: 4,
                        center: myLatlng
                        }
         
         var marker = new google.maps.Marker({
                position: myLatlng,
                title:"Hello World!"
                });
         
        
         var mymap = googleMaps.getObjectBySelector('#gmap');
        
        
        /* Working code */
         mymap.setCenter(new google.maps.LatLng(longit, latit)); 
       

        /* Not working code */
         mymap.createMarker(marker); 
       
         marker.setMap(mymap);
         
                  
        
         return false;
        
    });

====================================================

 

Or, maybe  , any can to see how to use functions

createMarker

createMarkers

 

from google_maps.js ?

 

 

Thanks for answers  

 

 

 

 

 

0 Kudos
3 Replies
Pamela_H_Intel
Moderator
228 Views

Andrejs,

Take a look at the Geolocation sample app in XDK (PROJECTS: Samples and Demos --> General --> Geolocation Demonstration)

Pamela

0 Kudos
Andrejs_V_
Beginner
228 Views

Thanks for answer!

I took a look at this sample. And I can manage map throought Googla MAPS JavaScript API. 

But it is not so "visual" with "hand-make" <div for map> in App Designer enviroment.

May be any can put some samples for standart operation with widgets?

Create marker(s), Calculate distance , geocoding &etc. ? 

Some simple samples ?

0 Kudos
PaulF_IntelCorp
Employee
228 Views

Andrejs -- our support is limited to helping you with the mechanics of debugging and building Cordova apps with the XDK. We are not staffed to provide samples and support for general HTML5 questions. For that we recommend you use StackOverflow, W3 Schools, HTML5 Rocks, etc.

0 Kudos
Reply