Web aplikacije, web servisi i software Frameworks, web servisi, programi, plugin-ovi, ekstenzije korisni za razvoj web sajtova. Sponzor: |
|
Alati teme | Način prikaza |
|
05. 06. 2011. | #1 |
expert
Expert
Datum učlanjenja: 15.03.2011
Poruke: 518
Hvala: 16
20 "Hvala" u 17 poruka
|
google map marker
Gde gresim u sledecem kodu:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <head> <title>Maps Example</title> <?php $db = mysql_connect("localhost","dnusername","dbpassword "); mysql_select_db("dbname", $db); ?> <script src="http://maps.google.com/maps?file=api&v=2&key=jkasdfisaiuefisefnks dfnksdfnksjdf_gI_TAKO_DALJE" type="text/javascript"></script> <script type="text/javascript"> function createMarker(point,html) { var marker = new GMarker(point); GEvent.addListener(marker,"click",function(){ top.location = "http://www.sdfsdfsdfs.com/show_marker.php?country="+point }); return marker; } function initialize() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("markers"),{ size: new GSize(580,400) } ); map.removeMapType(G_HYBRID_MAP); map.setCenter(new GLatLng(44.703250,20.416741,0), 1); var mapControl = new GMapTypeControl(); map.addControl(mapControl); map.addControl(new GLargeMapControl()); <? $exe1="SELECT lat,lon FROM baza"; $result1 = mysql_query($exe1, $db)or die(mysql_error()); while(list($lat,$long) = mysql_fetch_row($result1)){ echo "\n var point = new GLatLng(".$lat.",".$lon.");\n"; echo "var marker = createMarker(point,'');\n"; echo "map.addOverlay(marker);\n"; echo "\n"; } ?> } } </script> </head> <body onload="initialize()" onunload="GUnload()"> <div id="markers" style="width: 580px; height: 300px"></div> </body> </html> ONO STO MI TREBA JE DA DODAM MARKERE NA GOOGLE MAPU ALI DA KOORDINATE PREUZMEME IZ MYSQL baze... MAPA SE NE POJAVLJUJE KAO NI MARKERI kako da uradim ovo sa google map API v3? |
05. 06. 2011. | #2 |
Web designer
Professional
|
Off Topic: probaj http://gmap.nurtext.de/examples.html |
05. 06. 2011. | #3 |
expert
Expert
Datum učlanjenja: 15.03.2011
Poruke: 518
Hvala: 16
20 "Hvala" u 17 poruka
|
Ma nije mi to potrebno vec izvlacenje iz mysql baze koordinata ... tj. vec sam napisao kod ali neznam zasto se ne pojalvjuje mapa???
|
05. 06. 2011. | #4 |
Goran Pilipović
Sir Write-a-Lot
|
A jesi se ti autorizovao za korišćenje google maps?
__________________
Goran Pilipović a.k.a. Ugly Fingers Bradley f.k.a. bluesman I don't always know what I'm talking about but I know I'm right! |
05. 06. 2011. | #5 |
expert
Expert
Datum učlanjenja: 15.03.2011
Poruke: 518
Hvala: 16
20 "Hvala" u 17 poruka
|
Mislis na API kod ... imam api kod... da to nije problem. Jesi na to mislio ili na nesto drugo? Valjda je to autorizacija? Takodje me zanima koji su limiti za koriscenje google mape i u kojim slucajevima vaze jer sam video nesto tipa 2500 query-a dnevno i sl. O cemu se radi?
|
05. 06. 2011. | #6 |
banned
Professional
Datum učlanjenja: 04.06.2005
Poruke: 371
Hvala: 0
738 "Hvala" u 83 poruka
|
Prijavljuje li se kakva greška? Desni klik u browser-u pa "View source" ili pogledaj u konzoli browser-a.
__________________
Don't look at me; I'm lost too. “If you can't dazzle them with brilliance, baffle them with bul*s**t.” Poslednja izmena od Br@nkoR : 05. 06. 2011. u 10:08. |
05. 06. 2011. | #7 |
expert
Grand Master
Datum učlanjenja: 11.04.2010
Poruke: 998
Hvala: 141
959 "Hvala" u 153 poruka
|
Ne treba ti API key za V3...
HTML kôd:
<div id="markers" style="height:300px"></div> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> function gmaps(){ var myLatlng = new google.maps.LatLng(44.703250,20.416741); var myOptions = { zoom: 7, center: myLatlng, mapTypeId: google.maps.MapTypeId.HYBRID } var map = new google.maps.Map(document.getElementById("markers"), myOptions); var marker = new google.maps.Marker({ position: new google.maps.LatLng(44.703250,20.416741), title: "", icon: "http://www.google.com/intl/en_us/mapfiles/ms/icons/red-dot.png" }); marker.setMap(map); } gmaps(); </script> |
05. 06. 2011. | #8 |
expert
Expert
Datum učlanjenja: 15.03.2011
Poruke: 518
Hvala: 16
20 "Hvala" u 17 poruka
|
Da, to je Ok. Radi! ali ono sto meni treba je da izvuce koordinate iz baze i da prikaze markere ali kod koji sam predstavio ne radi... takodje imam i xml fajl odakle mogu da se preuzmu koordinate. Zna li neko gde na netu moze da se nadje kod za dodavanje markera iz baze ili iz xml fajla... i kako je sigurnije da se radi?
|
05. 06. 2011. | #9 |
expert
Grand Master
Datum učlanjenja: 11.04.2010
Poruke: 998
Hvala: 141
959 "Hvala" u 153 poruka
|
Br@nkoR ti je sugerirao, a to što pitaš su trivijalne stvari tako da sigurno nema.
|
06. 06. 2011. | #10 |
expert
Expert
Datum učlanjenja: 15.03.2011
Poruke: 518
Hvala: 16
20 "Hvala" u 17 poruka
|
Ma znam ja to ... ali jednostavno pitam zasto ne radi... naravno da sam probao sam brankov savet ... Takodje sam probao i sledeci kod ali google mapa se jednostavno ne prikazuje:
<? $dbname ='insert mysql database name'; //Name of the database $dbuser ='insert mysql user name'; //Username for the db $dbpass ='insert mysql password'; //Password for the db $dbserver ='insert mysql database server address'; //Name of the mysql server $dbcnx = mysql_connect ("$dbserver", "$dbuser", "$dbpass"); mysql_select_db("$dbname") or die(mysql_error()); ?> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>GUGL MAPA</title> <style type="text/css"> body { font: normal 10pt Helvetica, Arial; } #map { width: 350px; height: 300px; border: 0px; padding: 0px; } </style> <script src="http://maps.google.com/maps/api/js?v=3&sensor=false" type="text/javascript"></script> <script type="text/javascript"> var icon = new google.maps.MarkerImage("http://maps.google.com/mapfiles/ms/micons/blue.png", new google.maps.Size(32, 32), new google.maps.Point(0, 0), new google.maps.Point(16, 32)); var center = null; var map = null; var currentPopup; var bounds = new google.maps.LatLngBounds(); function addMarker(lat, lng, info) { var pt = new google.maps.LatLng(lat, lng); bounds.extend(pt); var marker = new google.maps.Marker({ position: pt, icon: icon, map: map }); var popup = new google.maps.InfoWindow({ content: info, maxWidth: 300 }); google.maps.event.addListener(marker, "click", function() { if (currentPopup != null) { currentPopup.close(); currentPopup = null; } popup.open(map, marker); currentPopup = popup; }); google.maps.event.addListener(popup, "closeclick", function() { map.panTo(center); currentPopup = null; }); } function initMap() { map = new google.maps.Map(document.getElementById("map"), { center: new google.maps.LatLng(0, 0), zoom: 14, mapTypeId: google.maps.MapTypeId.ROADMAP, mapTypeControl: false, mapTypeControlOptions: { style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR }, navigationControl: true, navigationControlOptions: { style: google.maps.NavigationControlStyle.SMALL } }); <? $query = mysql_query("SELECT * FROM mojatabela"); while ($row = mysql_fetch_array($query)){ $name=$row['name']; $lat=$row['lat']; $lon=$row['lon']; $desc=$row['desc']; echo ("addMarker($lat, $lon,'<b>$name</b><br/>$desc');\n"); } ?> center = bounds.getCenter(); map.fitBounds(bounds); } </script> </head> <body onload="initMap()" style="margin:0px; border:0px; padding:0px;"> <div id="map"></div> </html> |
|
|