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.