Welcome Guest, Not a member yet? Register   Sign In
CI Google Maps Library - Markers doesn´t work ```BIOSTALL`
#1

[eluser]Tilt[/eluser]
Hello there.

I am having a problem with setting markers on google maps. I have an app in wich i managed to insert a map, but even following documentation of a library - some of you must know it - i cannot show a marker.

This is the page with the library: http://biostall.com/codeigniter-google-m...pi-library. I aprecciate the help, a lot. I ask here becouse this seems a popular library.

This is the controller code:

Code:
$endereco = $dados['perfil']['rua'].",".$dados['perfil']['numero'].",".$dados['perfil']['cidade'].",".$dados['perfil']['cep'];
  $config['center'] = $endereco;
  $config['zoom'] = '15';
  $config['region'] = 'brazil';
  $config['places'] = TRUE;
  $this->googlemaps->initialize($config);

  $marker = array();
  $marker['position'] = $endereco;
  $this->googlemaps->add_marker($marker);
  $dados['map'] = $this->googlemaps->create_map();
#2

[eluser]BIOSTALL[/eluser]
Hi Tilt,

Thanks for using my library. I can't see any immediate problems with your code.

Are you able to tell me an example of what your $endereco variable is set to when it doesn't work?

Also, do you have a link to a page where I can see the map in action?

Let me know and I'll respond as quickly as I can to get you up and running.

Speak soon Smile

BIOSTALL
#3

[eluser]Tilt[/eluser]
Thanks a lot for the answer. Well, this is a upcomming project, so i have no link. The map appears pretty clean and in a correct place. The only problema is the marker.

I use an adress($endereco) in a database.

An example is like "Street Jon Doe, x, NY, zip code" .

Since it is a simple library code, i also think is something with the database, even if the map is showing the wanted adress.

Thanks

#4

[eluser]Tilt[/eluser]
Code:
$endereco = $dados['perfil']['rua'].",".$dados['perfil']['numero'].",".$dados['perfil']['cidade'].",".$dados['perfil']['cep'];

This is Street, number, city, zip code.
#5

[eluser]BIOSTALL[/eluser]
Ok. The next thing to do is to view the page source code and see if there is a latitude and longitude being included in the JavaScript where the marker is being added.

If you can't see, or if you need further guidance please feel free to post the JavaScript from the page source here and I'll take a look for you.

Thanks Smile
#6

[eluser]Tilt[/eluser]
This is the javascript i found.There is a function who creates the marker

Code:
var map; // Global declaration of the map
var iw = new google.maps.InfoWindow(); // Global declaration of the infowindow
var lat_longs = new Array();
var markers = new Array();
var placesService;
function initialize() {
  var myLatlng = new google.maps.LatLng(-3.1090237, -60.0187195);
var myOptions = {
zoom: 15,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    var placesRequest = {
    };
  
placesService = new google.maps.places.PlacesService(map);
placesService.search(placesRequest, placesCallback);

      var myLatlng = new google.maps.LatLng(-3.1090237, -60.0187195);
      var markerOptions = {
  map: map,
  position: myLatlng  
   };
   marker_0 = createMarker(markerOptions);
  }

function createMarker(markerOptions) {
   var marker = new google.maps.Marker(markerOptions);
markers.push(marker);
lat_longs.push(marker.getPosition());
return marker;
  }
function placesCallback(results, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
     for (var i = 0; i < results.length; i++) {
  var place = results[i];
  var placeLoc = place.geometry.location;
  var placePosition = new google.maps.LatLng(placeLoc.lat(), placeLoc.lng());
   var markerOptions = {
     map: map,
           position: placePosition
           };
         var marker = createMarker(markerOptions);
        marker.set("content", place.name);
        google.maps.event.addListener(marker, "click", function() {
            iw.setContent(this.get("content"));
            iw.open(map, this);
           });

        lat_longs.push(placePosition);
   }
   }
   }
   window
  
   //]]>
#7

[eluser]BIOSTALL[/eluser]
Hey Tilt.

Thanks for that. The code looks fine. I see you're using the Places API too. I wonder if this is conflicting with the marker and causing it not to show.

Would you please do me a favour and temporarily turn off Places to see if it appears?

If it does then I'm guessing there is a bug with the library which I can resolve within the next couple of days.

Thanks.
#8

[eluser]Tilt[/eluser]
You mean, if a comment this line?


Code:
$config['places'] = TRUE;

I did not start this project but my colegues here told me they did not use Places API.
-------------------------------------------------------------------

WOW! I just did that I wrote and the marker appeared like magic! Thanks a lot, man, I think i will even donate you something for such help Smile lol

There may be a bug you might fix.
#9

[eluser]BIOSTALL[/eluser]
No problemo! Does sound like a slight bug there when you have the places API on AND you try and add custom markers. Shall take a look over the weekend.

Thanks for pointing it out and enjoy the library Smile




Theme © iAndrew 2016 - Forum software by © MyBB