Google Maps does not show correct coordinates JQueryMobile

0

I am developing an Android application that uses the Google Maps APIs. The way to invoke and draw the maps is with Jquery mobile. The function is as follows:

       function mapas(opc) {




        $(document).on("pageinit", "#map-page", function () {
                  if (opc = 1) {
                    alert('opcion 1');
                    var defaultLatLng = new google.maps.LatLng(38.384716, -0.510933); 
                } else if (opc = 2) {
                    alert('opcion 2');
                    var defaultLatLng = new google.maps.LatLng(35.384716, -0.510933);  
                }
               drawMap(defaultLatLng);
                function drawMap(latlng) {
                    var myOptions = {
                        zoom: 14,
                        center: latlng,
                        mapTypeId: google.maps.MapTypeId.ROADMAP
                    };var map = new google.maps.Map(document.getElementById("map-canvas"), myOptions);
                    // Add an overlay to the map of current lat/lng
                    var marker = new google.maps.Marker({
                        position: latlng,
                        map: map,
                        title: "Greetings!"
                    });

            });'

Where #map-page is the ID of the div that forms the page and #map-canvas is the ID of the div where the map will be drawn. The fact is that when I invoke this function as it appears with opc=1 , it shows the map as it touches. On the other hand, I want that by pressing a button, it shows the coordinates of another site, I invoke the function mapas(2) , however, redraws the map with the coordinates of option 1.

Why can this happen?

Thank you for your time. Greetings.

    
asked by Vikk 03.10.2016 в 10:10
source

1 answer

2

Welcome to SOes, I hope you find it useful:

 if (opc = 1) {
...
 } else if (opc = 2) {

Replace with:

 if (opc === 1) {
...
 } else if (opc === 2) {

To be considered in JavaScript:

link

    
answered by 03.10.2016 в 10:19