problem when loading google map
hi,
phpdevshell is the first framework i ever used. During the development, i encounter some issue.
Below is the code i paste into track.tpl file in views folder
{literal}
<script type="text/
<script type="text/
function initialize() {
map = new google.
center: new google.
zoom: 8,
mapTypeId: google.
scaleControl: true,
mapTypeControl: true,
zoomControl: true,
zoomControl
style: google.
},
mapTypeContro
style: google.
},
streetViewCon
navigationControl: true,
navigationCont
style: google.
}
});
}
</script>
<script>
window.onload = initialize;
</script>
{/literal}
{$test}
<div id="map_canvas" style="
the issue is my ggogle map toolbar is not appear in chrome and IE.
I did not encounter this issue when load into blank php page without using framework.
Thank in advance. I hope i can use this framework on my next project
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- PHPDevShell Edit question
- Assignee:
- No assignee Edit question
- Last query:
- 2013-08-14
- Last reply:
- 2013-09-03
Greg (gregfr) said : | #1 |
Hi
You should never use things like:
function initialize() { .. }
window.onload = initialize;
for two reasons:
- first another plugin may also declare a initialize() function
- second because window.onload is a single value, therefore you're erase any previous value
To write clean code, you must:
- use more specific function name, such as MYPROJECT_
- use an event to trigger your init code
So, in your case:
- rename your init function:
function MYPROJECT_
map = new google.
...
}
- trigger it with:
$(document)
MYPROJECT_
}
joha (johagood) said : | #2 |
Dear Greg,
I have change my code according your suggestion and unfortunately, my web page doesn't display any map.
below is my code
{literal}
<script type="text/
<script type="text/
function MYProject_
map = new google.
center: new google.
zoom: 8,
mapTypeId: google.
scaleControl: true,
mapTypeControl: true,
zoomControl: true,
zoomControl
style: google.
},
mapTypeContro
style: google.
},
streetViewCon
navigationControl: true,
navigationCont
style: google.
}
});
}
</script>
<script>
$(document)
MYProject_
}
</script>
{/literal}
{$test}
<div id="map_canvas" style="
Launchpad Janitor (janitor) said : | #3 |
This question was expired because it remained in the 'Open' state without activity for the last 15 days.
Greg (gregfr) said : | #4 |
I'm reopening the question
Greg (gregfr) said : | #5 |
Sorry I had a typo, you should write:
$(document)
MYProject_
});
(notice the last 2 characters).
It's in fact a javascript error that your browser you have displayed. When browser do you work with?
joha (johagood) said : | #6 |
Dear Greg,
I'm really sorry because i have change to another framework called yii. The reason is I need something to complete within very short time and i'm not able to waiting for your answer. I have done the same thing in Yii framework with less hassle. Anyway thank you for your framework cause i'm able to understand MVC in very short time.
Thank you
Can you help with this problem?
Provide an answer of your own, or ask joha for more information if necessary.