I’m getting the following error trying to geocode addresses on my shared host:
curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set
Any suggestions for a workaround?
I’m getting the following error trying to geocode addresses on my shared host:
curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set
Any suggestions for a workaround?
There is workaround in official PHP manual comments.
http://www.php.net/manual/en/function.curl-setopt.php#102121
Hopefully it helps.
Have you tried the extension EHttpClient ? Check its example two also sets its maxredirects
I would like to inform you to all those willing to help make this library better that I have uploaded the extension to a google.code repository: http://code.google.com/p/egmap/
Anyone willing to help, please contact me.
Thanks!
I am having some problems with the automatic zoom calculation, seems like when I have more than a few markers (44 in my case), the zoom calculation returns "Number.NEGATIVE_INFINITY", and the world map is shown, but all my markers are near each other (all of them in Brazil in this case).
var mapOptions = {center:new google.maps.LatLng(-19.1106879, -47.5556376),
zoom:Number.NEGATIVE_INFINITY,
mapTypeId:google.maps.MapTypeId.ROADMAP};
The zoom calculation code seems pretty complicated, I just came asking here first if anyone had this problem before digging to understand it.
Never been facing that issue, I’ll have a look at it
Antonio,
I have not yet upgraded to EGMap 2.0, but I was wondering if there is a way to use my own image instead of a map. See here for an example.
It certainly looks like they are using the google maps api.
Thanks!
Antonio,
First of all, thank you VERY much for this excellent extension. I have a specific implementation need that I’m not sure how to go about. Here’s what I’m trying to do:
Ask user for a zip code
Geocode the zip code and center map on zip code (got this working with no problems)
Get the map boundaries and do a db query of items within boundary (got it working)
<-- problems -->
Add a listener to keep track of user moving the map or changing zoom levels
If map is moved or zoom level is changed, trigger an ajax event to requery the database to get the items for the new boundary
I’m not sure how to go about steps 4 and 5. My PHP skills are excellent, but I pretty much suck at JavaScript/AJAX. I’m guessing this is done using the EGMapEvent class, but I would appreciate any guidance or help you can provide. Thanks!
Currently without Internet at home (i moved to another house). As soon as I am up an running will answer.
This message has been posted from my BB.
Cheers
Thanks! Eagerly looking forward to hearing from you.
BTW, I had another question related to clusters. Is it possible to have different clusters based on icon types. For example, if I wanted to group items of different type using a different cluster icon/size, etc. From looking at the EGMap class, it looks like each map supports one EGMapMarkerClusterer object.
In order to achieve step number 4 you need to add two events to the map to check for ‘center_changed’ and ‘zoom_changed’. On any of the events, make an ajax call and send the information…
-----
$ce= new EGMapEvent('center_changed', "makeAjaxRequest();", false, EGMapEvent::TYPE_EVENT_DEFAULT);
$ze= new EGMapEvent('zoom_changed', "makeAjaxRequest();", false, EGMapEvent::TYPE_EVENT_DEFAULT);
-----
You can add the makeAjaxRequest() function as an afterInit event (the parameter on the renderMap function -see phpDoc). Remember that for the ajax request you need to call the id of the map and then use the javascript API function ‘.getCenter()’ . If you need help with the function let me know, provide me with the details you require to send to your PHP file and I help you out.
Cheers
I’ll take a peek at it then, you seem to do the math yourself and not using any google code, do you have any pointers of what math you used to calculate the zoom / center on markers?
Thanks Antonio. OK, I tried to put some of my code in here, but the forums won’t let me because I haven’t posted much here. Basically what I have is a controller that initially makes a model call for the initial items for the map. Then the view is rendered with the map and all the items are added as markers with an infowindow. Now, when someone moves the map or changes zoom level, I would like a PHP action to be called via ajax to refresh the data. From what I understand, the ajax call is done via the javascript function that I provide in the $afterInit parameter for the renderMap() method? Unfortunately this is where you lost me because I have pretty much no js skills.
What I need the js file to do is to provide the PHP action information about the boundary of the map so that I can pull the related records. So any help with that would be greatly appreciated. Also, how would the PHP action round-trip the data back to the map? Thanks!
HI TwinMoons,
The call to PHP is quite simple and the return will be obviously to work with google v3 api to clear all markers on the map and render new points received from PHP script.
I do not have much time nowadays but I give it a try asap.
Cheers
The math calculation was made by other programmer (as specified in the comments by Fabrice Bernahrd). Nevertheless, I guess that it could be a better option to do it on rendered Javascript (as written on this example: http://blog.shamess.info/2009/09/29/zoom-to-fit-all-markers-on-google-maps-api-v3/) as Google v3 does support it naturally.
Tell me what do you think about it and I will include this change in next release.
Cheers
I’ve got most of it working so far, but I can’t seem to find a way to clear the map markers. How do I do this in V3? There is no clearOverlays() method in V3 and I can’t find another way to do it.
Here’s what I have for the javascript code so far:
function makeAjaxRequest(){
var center = EGMap0.getCenter();
var bounds = EGMap0.getBounds();
var southWest = bounds.getSouthWest();
var northEast = bounds.getNorthEast();
var swLat = southWest.lat();
var swLng = southWest.lng();
var neLat = northEast.lat();
var neLng = northEast.lng();
var markers = [];
jQuery.post('index.php?r=site/getListings', {swLat: swLat, swLng: swLng, neLat: neLat, neLng: neLng}, function(data){
var i = 0;
var infowindow;
jQuery(data).find("marker").each(function(){
var marker = jQuery(this);
var latlng = new google.maps.LatLng(parseFloat(marker.attr("lat")),
parseFloat(marker.attr("lng")));
var title = marker.attr("title");
var info = marker.attr("info");
var marker = new google.maps.Marker({ position: latlng,
map: EGMap0,
title: title,
icon: new google.maps.MarkerImage("http://google-maps-icons.googlecode.com/files/library.png", new google.maps.Size(32,37), new google.maps.Point(0,0), new google.maps.Point(16,16.5))
});
(function(i, marker) {
google.maps.event.addListener(marker, 'click', function() {
if(!infowindow){
infowindow = new google.maps.InfoWindow();
}
infowindow.setContent(info+" "+markers.length);
infowindow.open(EGMap0, marker);
});
})(i, marker);
markers.push(marker);
i++;
});
var cluster = new MarkerClusterer(EGMap0, markers, {maxZoom:15, styles: [{'width':'53','height':'52','url':'http://localhost/m1.png','textColor':'#ffffff'},{'width':'56','height':'55','url':'http://localhost/m2.png','textColor':'#000000'},{'width':'66','height':'65','url':'http://localhost/m3.png','textColor':'white'},{'width':'78','height':'77','url':'http://localhost/m4.png','textColor':'white'},{'width':'90','height':'89','url':'http://localhost/m5.png','textColor':'white'}]});
});
}
Please check the following: http://stackoverflow.com/questions/1544739/google-maps-api-v3-how-to-remove-all-markers
I think if there is a JS api for this, it should be better handled by it, as many things can go into the decision of centering on markers, like the marker size, leaving some margins so the marker is not over the div border, etc.
But as it also can be usefull to know at php time this information, I think it is better the keep the current option too.
Great Rangel, will do, I know the JS Google API for that, will do it asap, thanks for your feedback.
First of all, congrats Antonio! it’s a really nice extension!
I also found the function clearMarkers() from markerClusterer: (i can’t insert links) but I don’t really know how I can integrate this in your extension.
The thing that I’m trying to do is: I have a map and a radiobutton with 3 fields “Show all”, “Show only friends”, “Show only team members”. At the beginning the map shows all the users positions (markers) but if the user selects another button the view does an ajax call to the controller that returns the new markers positions and at this point I want clear all the markers and set the new ones without reload the map if it’s possible:
View:
First I create the map as in your blog example Sidebar marker trigger
Then the radiobutton:
<div class="compactRadioGroup">
<?php
$data = array(0=>'Show All', 1 => 'Show only friends', 2 => 'Show only team members');
echo CHtml::radioButtonList('filters',0,$data,
array('onchange'=>CHtml::ajax(
array(
'type'=>'POST',
'url'=>array("Trackingphp/filter"),
'success' => 'function (response,status)
{
resp=$.parseJSON(response);
var ids=resp.ids;
var lat=resp.lat;
var lon=resp.lon; }
lat and lon are the new positions of the markers and I don’t know how I can paint them…
Thanks for your help, (this is for a PFC for the University of Vigo)