Hi Chris,
yeap exactly, you are completely right, the error was because of the
mix of different js files.
Now I devided them apart, so have a look at the main page now.
http://easyflat.com.ua the main acting js file is gmap_loop.js.
Now it works, in IE 8.0 in FF 3.6 and even on my android browser.
BUT the array "cities" is written manually within gmap_loop.js.
And I need to pass it from php file that generates the main page. PHP
code that generates the array is //var cities = new Array(<?php echo
implode(",",$clean_cities);?>); Where $clean_cities is php array with
cities list.
You can see in the source of main page the output:
//var cities = new Array(kiev,kharkov,lvov,odessa);
It is commented now to show how it should work.
If I uncomment it and delete the mannually written array cities in
gmap_loop.js - nothing works and even begins to tell what guys written
above like "places.length is null" etc.
Hope now it's clear...
2 Rossko - I deleted not needed commented lines, as you asked.
Thanks
On 10 Грд, 02:05, Chris Broadfoot <[email protected]> wrote:
> Sorry about that last message - my email was lagging and I didn't see the
> latest posts in the thread.
>
> It looks like an JS error is coming up on L4 of gmapinput.js - seems that $
> is undefined. However, jQuery seems to be in scope.
>
> FWIW - everything seems to work anyway. What's the issue now?
>
> Chris
>
>
>
>
>
>
>
> On Fri, Dec 10, 2010 at 9:44 AM, Chris Broadfoot <[email protected]> wrote:
> > As Larry said, please post a link to your page. Pasted code is not
> > easy to debug - you want help, right? Make it easy for us to help you.
>
> > Chris
>
> > On 09/12/2010, at 8:53 PM, Futsutsuka <[email protected]> wrote:
>
> > > Thanks for replies.
> > > 2STU, I don't think its the problem of the format as I tried not only
> > > generate by php, but just manualy write in html after <script> var
> > > cities = [...
>
> > > 2Larry. Well there is no geocoding as I give lat and lng coordinates
> > > to the markers. Can't give you the link as its tested locally.
>
> > > The array that I collect via php works and returns value inside the
> > > code. Actually almost all variable are coming to js file from external
> > > php. Arrays prices, roomss etc. are also collected in php and they
> > > perfectly work withing gmap.js and only array cities doesn't want to
> > > work. If I uncomment //var cities = [... in the code below -
> > > everything works perfectly...
>
> > > gmap.js is included in header of html and variables and arrays are
> > > created already in body but before <div> with map.
> > > Here is the code of gmap.js file
>
> > > (function() {
> > > window.onload = function() {
> > > // Creating a reference to the mapDiv
> > > var mapDiv = document.getElementById('map');
>
> > > // Creating a latLng for the center of the map
> > > var latlng = new google.maps.LatLng(latc, lngc);
>
> > > // Creating an object literal containing the properties
> > > // we want to pass to the map
> > > var options = {
> > > center: latlng,
> > > zoom: zoomvar,
> > > mapTypeId: google.maps.MapTypeId.ROADMAP,
> > > scaleControl: true,
> > > scaleControlOptions: {
> > > position: google.maps.ControlPosition.BOTTOM
> > > },
> > > mapTypeControl: true,
> > > mapTypeControlOptions: {
>
> > > style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
>
> > > }
> > > };
>
> > > // Creating the map
> > > var map = new google.maps.Map(document.getElementById('map'),
> > > options);
> > > // Creating a LatLngBounds object
> > > var bounds = new google.maps.LatLngBounds();
> > > // Creating a variable that will hold
> > > // the InfoWindow object
> > > var infowindow;
> > > // Initializing MarkerManager
> > > var mgr = new MarkerManager(map);
> > > var dotss = [];
>
> > > //add markers from array places []
> > > // Looping through the places array
> > > for (var i = 0; i < places.length; i++) {
>
> > > // Adding the markers
> > > var marker = new google.maps.Marker({
> > > position: places[i],
> > > //map: map,
> > > icon: markerurl,
> > > title: 'Place number ' + i
> > > });
> > > dotss.push(marker);
> > > // Wrapping the event listener inside an anonymous function
> > > // that we immediately invoke and passes the variable i to.
> > > (function(i, marker) {
>
> > > // Creating the event listener. It now has access to the values of
> > > // i and marker as they were during its creation
> > > google.maps.event.addListener(marker, 'click', function() {
>
> > > // Check to see if we already have an InfoWindow
> > > if (!infowindow) {
> > > infowindow = new google.maps.InfoWindow();
> > > }
> > > // Creating the content
> > > var content = '<div id="info">' +
> > > '<table> <tr><td>' +
> > > '<img src=' + markerurl + ' width=75 hights=75 align=left> </
> > > td><td><b>' + streets[i] + '<b><br>' +
> > > '<b>' + prices[i] + '</b> <br>' +
> > > '<b>Êîìíàòû</b>' + roomss[i] + '<br>' +
> > > '<p><a href="#">Ïîäðîáíåå</a></p>' +
> > > '</td></tr></table></div>';
> > > // Setting the content of the InfoWindow
> > > infowindow.setContent(content);
>
> > > // Tying the InfoWindow to the marker
> > > infowindow.open(map, marker);
>
> > > });
>
> > > })(i, marker);
>
> > > // Extending the bounds object with each LatLng
> > > bounds.extend(places[i]);
>
> > > }
> > > //finished adding markers from array places []
>
> > > // Creating a marker that represents Kiev
> > > var kiev = new google.maps.Marker({
> > > position: new google.maps.LatLng(50.4531, 30.5447),
> > > icon: 'http://google-maps-icons.googlecode.com/files/hotel.png'
> > > });
> > > // Adding a click event to the Kiev marker
> > > google.maps.event.addListener(kiev, 'click', function() {
> > > // Setting the zoom level of the map to 10
> > > map.setZoom(10);
> > > // Setting the center of the map to the clicked markers position
>
> > > map.setCenter(kiev.getPosition());
>
> > > });
>
> > > // Creating a marker that represents Odessa
> > > var odessa = new google.maps.Marker({
> > > position: new google.maps.LatLng(46.5171, 30.7356),
> > > icon: 'http://google-maps-icons.googlecode.com/files/hotel.png'
> > > });
> > > // Adding a click event to the Odessa marker
> > > google.maps.event.addListener(odessa, 'click', function() {
> > > // Setting the zoom level of the map to 10
> > > map.setZoom(10);
> > > // Setting the center of the map to the clicked markers position
> > > map.setCenter(odessa.getPosition());
> > > });
>
> > > // Creating a marker that represents Donetsk
> > > var donetsk = new google.maps.Marker({
> > > position: new google.maps.LatLng(48.0134, 37.8060),
> > > icon: 'http://google-maps-icons.googlecode.com/files/hotel.png'
> > > });
> > > // Adding a click event to the Donetsk marker
> > > google.maps.event.addListener(donetsk, 'click', function() {
> > > // Setting the zoom level of the map to 10
> > > map.setZoom(10);
> > > // Setting the center of the map to the clicked markers position
> > > map.setCenter(donetsk.getPosition());
> > > });
>
> > > // Creating a marker that represents Kharkov
> > > var kharkov = new google.maps.Marker({
> > > position: new google.maps.LatLng(49.9592, 36.2157),
> > > icon: 'http://google-maps-icons.googlecode.com/files/hotel.png',
> > > title: 'places.length'
> > > });
> > > // Adding a click event to the Kharkov marker
> > > google.maps.event.addListener(kharkov, 'click', function() {
> > > // Setting the zoom level of the map to 10
> > > map.setZoom(10);
> > > // Setting the center of the map to the clicked markers position
> > > map.setCenter(kharkov.getPosition());
> > > alert (places.length);
> > > });
>
> > > // Creating a marker that represents Dnepropetrovsk
> > > var dnepropetrovsk = new google.maps.Marker({
> > > position: new google.maps.LatLng(48.4615, 34.9825),
> > > icon: 'http://google-maps-icons.googlecode.com/files/hotel.png'
> > > });
> > > // Adding a click event to the Dnepropetrovsk marker
> > > google.maps.event.addListener(dnepropetrovsk, 'click', function() {
> > > // Setting the zoom level of the map to 10
> > > map.setZoom(10);
> > > // Setting the center of the map to the clicked markers position
> > > map.setCenter(dnepropetrovsk.getPosition());
> > > });
>
> > > // Creating a marker that represents Zaporozhye
> > > var zaporozhye = new google.maps.Marker({
> > > position: new google.maps.LatLng(47.8450, 35.1665),
> > > icon: 'http://google-maps-icons.googlecode.com/files/hotel.png'
> > > });
> > > // Adding a click event to the Zaporozhye marker
> > > google.maps.event.addListener(zaporozhye, 'click', function() {
> > > // Setting the zoom level of the map to 10
> > > map.setZoom(10);
> > > // Setting the center of the map to the clicked markers position
> > > map.setCenter(zaporozhye.getPosition());
> > > });
>
> > > // Creating a marker that represents Lvov
> > > var lvov = new google.maps.Marker({
> > > position: new google.maps.LatLng(49.8541, 24.0161),
> > > icon: 'http://google-maps-icons.googlecode.com/files/hotel.png'
> > > });
> > > // Adding a click event to the Lvov marker
> > > google.maps.event.addListener(lvov, 'click', function() {
> > > // Setting the zoom level of the map to 10
> > > map.setZoom(10);
> > > // Setting the center of the map to the clicked markers position
> > > map.setCenter(lvov.getPosition());
> > > });
>
> > > // Creating an array that will contain the markers Kyiv and Odesa
>
> > > var cities = [];
> > > for (var i = 0; i < citiesphp.length; i++) {
> > > cities.push(citiesphp[i]);
>
> > > }
> > > //var cities = [kiev, odessa, donetsk, kharkov, dnepropetrovsk,
> > > zaporozhye, lvov];
>
> > > google.maps.event.addListener(mgr, 'loaded', function() {
> > > // These markers will only be visible between zoom level 1 and 7
> > > mgr.addMarkers(cities, 1, 9);
> > > // These markers will be visible at zoom level 6 and deeper
> > > mgr.addMarkers(dotss, 10);
> > > // Making the MarkerManager add the markers to the map
> > > mgr.refresh();
> > > });
>
> > > // Adjusting the map to new bounding box
> > > map.fitBounds(bounds)
>
> > > };
>
> > > })();
>
> > > Thanks!
>
> > > On 9 Грд, 09:32, stu <[email protected]> wrote:
> > >> Hi
> > >> I'm not sure exactly what you're doing with the data, but it sounds
> > >> like your main problem is getting a php/msql array into a format that
> > >> javascript can use - is that right?
> > >> If so, the trick is to look into using JSON. Do a search on php data
> > >> to javascript and you will find examples, but the basic way is to use
> > >> json_encode to convert the php array into JSON. Then pickup the JSON
> > >> encoded variable in your javascript and convert to a javascript JSON
> > >> object. You can parse JSON with JSON.parse if the browser supports it,
> > >> or use something like jquery which has a JSON parser.
> > >> Hope that is what you wanted.
> > >> ...stu
>
> > >> On Dec 9, 5:25 am, Futsutsuka <[email protected]> wrote:
>
> ...
>
> читати далі »
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.